我无法从新创建的 cocoa pod 导入 类

I can't import classes from a newly created cocoa pod

我刚刚从单个 git 存储库 (https://github.com/snakajima/bonjour-http) 创建并发布了两个新的 public cocoa pods。

这是第二个 pod 的 Podspec。

Pod::Spec.new do |s|
  s.name             = 'bonjour-http-server'
  s.version          = '0.4.0'
  s.summary          = 'HTTP over Bonjour in Swift.'
 
  s.description      = <<-DESC
  HTTP over Bonjour in Swift for iOS and macOS.
                       DESC
 
  s.homepage         = 'https://github.com/snakajima/bonjour-http'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Satoshi Nakajima' => 'satoshi.nakajima@gmail.com' }
  s.source           = { :git => 'https://github.com/snakajima/bonjour-http.git', :tag => s.version.to_s }
 
  s.ios.deployment_target = '13.0'
  s.osx.deployment_target = '10.14'
  s.source_files = 'core/BonjourService.swift', 'core/BonjourRequest.swift', 'core/BonjourResponse.swift', 'core/BonjourParser.swift'
  s.swift_versions = '5.0'
  s.dependency 'CocoaAsyncSocket'
end

现在,我正在尝试使用另一个项目中的第二个 pod (bonjour-http-server)。我将以下行添加到 Podfile 和 运行“pod install”,成功将其添加到项目中。

  pod 'bonjour-http-server', :git => 'https://github.com/snakajima/bonjour-http.git'

当我尝试从 swift 文件导入此模块时,Xcode 将像这样完成代码。

import bonjour_http_server

但是,我无法使用此模块中的任何 类,例如 BonjourService。 Xcode 不会对其进行代码补全,编译器会失败。

我是 Cocoa Pods 的新手,我很可能在某个地方犯了错误 - 无论是在发布阶段还是在导入阶段。

如果有人能帮我解决这个问题,我将不胜感激。完整的源代码可在 https://github.com/snakajima/bonjour-http.

获得

基于Access Control官方文档:

All entities in your code (with a few specific exceptions, as described later in this chapter) have a default access level of internal if you don’t specify an explicit access level yourself. As a result, in many cases you don’t need to specify an explicit access level in your code.

如果您这样声明 class:(来自您的存储库的示例)

@objc class BonjourService: NSObject {
    ...
}

默认情况下只能从同一模块内的访问

因此,要向外界公开一个 class、一个函数等,(在您的模块之外)您至少需要将其声明为 public:

@objc public class BonjourService: NSObject {
    ...
}

您可以在上述文档中找到有关 Swift 的 访问级别 的更多详细信息。