3

花了几个小时后,我绝对需要你的帮助。

我想创建一个包含 Spotify SDK(这里.framework)和 Deezer SDK(这里*.a lib)的 pod,以便进行一些工作。

两个 SDK 都是用Objective-C编写的,我想用Swift 2 (iOS 8) 编写我的 pod。此外,包含此 pod 的项目位于 Swift 2 (iOS 8) 中。

在创建 pod 项目后,pod create lib我首先尝试在 pod 项目中直接添加Spotify.framework,但无法编译...

因此,我尝试通过编写 podspec 来像 pod 一样包含 Spotify.framework,这里是spotify.podspec.json

{
  "name": "FakeSpotify",
  "version": "1.1",
  "summary": "Spotify iOS SDK",
  "homepage": "https://developer.spotify.com/technologies/spotify-ios-sdk/",
  "license": "MIT",
  "authors": {
    "jjt": "jeanjaques@thierry.com"
  },
  "source": {
    "git": "https://github.com/spotify/ios-sdk.git",
    "tag": "beta-13"
  },
  "platforms": {
    "ios": "8.0"
  },
  "requires_arc": true,
  "preserve_paths": "Spotify.framework",
  "public_header_files": "Spotify.framework/Versions/A/Headers/*.h",
  "vendored_frameworks": "Spotify.framework",
  "xcconfig": {
    "OTHER_LDFLAGS": "-ObjC"
  }
}

我还在Podfile上添加了一行:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'SpoTest_Example', :exclusive => true do
  pod 'SpoTest', :path => '../'
  pod 'FakeSpotify', :podspec => './spotify.podspec.json'
end

target 'SpoTest_Tests', :exclusive => true do
  pod 'SpoTest', :path => '../'
end

现在,在 之后pod install,创建了一个文件夹“FakeSpotify”,其中包含 Spotify.framework。这部分没问题,但还不够:我不能使用它......

我既不能在示例项目中导入 Spotify,也不能在开发 pod 文件(都在 Swift 中)中导入 Spotify。

我试图添加#import <Spotify/Spotify.framework伞文件(SpoTest-umbrella.h),但出现错误:Include of non-modular header inside framework module 'SpoTest'

在打了自己和一些搜索之后,我尝试通过添加这个帖子脚本来编辑我的 podfile:

post_install do |installer|
    installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
        configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
    end
end

没有更好的,同样的错误。好吧好吧,我该怎么办?嗯,我试图删除之前在伞文件中添加的导入,并编辑了我的 pod podspec (SpoTest.podspec)。我哭了“哦,我真的很糟糕,我们还需要告诉我们在这个 podspec 中存在依赖关系,即使是用于开发测试......”。

所以我添加了这条漂亮的线:s.dependency 'FakeSpotify'

我很高兴,......也很伤心:pod install现在命令出现新错误:

[!] The 'Pods-SpoTest_Example' target has transitive dependencies that include static binaries: (/Users/jjt/Documents/dev/ios/LIBS/SpoTest/Example/Pods/FakeSpotify/Spotify.framework)

哎哟,这么近!好的,让我们尝试一些方法来处理它。我通过添加预安装脚本编辑了我的 Podfile:

pre_install do |installer|
    # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
    def installer.verify_no_static_framework_transitive_dependencies; end
end

到此,命令行就ok了,安装就完成了。但我仍然无法使用它。如果我在伞中导入框架,仍然会出现错误。

你还有什么想法吗?我目前没有更多:)

或者也许没有 cocoapods 有更好的方法?我的目标是用这两个 SDK 创建一个东西,并将其轻松地包含在其他实际项目中。

谢谢。

4

0 回答 0