将一个目标中的框架用作本地另一个目标中的Pod

时间:2019-07-09 15:39:32

标签: ios objective-c frameworks cocoapods

我在使用我在其他目标(同一项目)中使用模块化导入编写的框架时遇到了麻烦。我正在使用Cocoapods。尝试使用模块化导入(@import CMPComapiFoundation;)导入模块时,出现无法构建模块错误。我将链接附加到repo以获得更多信息。

我确实尝试了本地(:path =>)和远程(:git =>)在Podfile中提取SDK的方法,但似乎都没有用。值得注意的是,如果通过Cocoapods在单独的项目中添加代码,则可以编译代码并且可以导入SDK。

SDK的.podspec文件:

Pod::Spec.new do |s|
  s.name             =  'CMPComapiFoundation'
  s.version          =  '1.2.2'
  s.license          =  'MIT'
  s.summary          =  'Foundation library for connecting to and consuming COMAPI services'
  s.description      = <<-DESC
# iOS SDK for Comapi
Client to connect your iOS application with [Comapi](http://comapi.com/) services and add it as a channel to our cloud messaging platform. Written in Objective-C.
For more information about the integration please visit [the website](http://docs.comapi.com/reference#one-sdk-ios).
                        DESC
  s.homepage         = 'https://github.com/comapi/comapi-sdk-ios-objc'
  s.author           = { 'Comapi' => 'support@comapi.com' }
  s.source           =  { :git => 'https://github.com/comapi/comapi-sdk-ios-objc.git', :tag => s.version.to_s }
  s.social_media_url = 'https://twitter.com/comapimessaging'

  s.ios.deployment_target = '10.0'
  s.requires_arc        = true
  s.source_files        = 'Sources/**/*.{h,m}'
  s.resources           = []

  s.dependency 'SocketRocket'

end

这是我用于整个项目的Podfile:

platform :ios, '10.0'
use_frameworks!

def shared
  pod 'CMPComapiFoundation', :path => '/Users/dominik.kowalski/Documents/comapi-sdk-ios-objc'
  pod 'JWT'
end

target 'CMPComapiFoundation' do
  pod 'SocketRocket'
end

target 'CMPComapiFoundationTests' do
  shared
end

target 'ComapiFoundationSample' do
  shared
end

target 'ComapiFoundationSample-Swift' do
  shared
  pod 'SnapKit'
end

我希望测试目标和示例目标能够导入模块并编译代码。

1 个答案:

答案 0 :(得分:0)

好吧,我设法自己修复了它。一些头文件缺少Target成员身份,但是Xcode给了我误导性提示。