"dyld: Library not loaded" 在设备上的 tvOS Top Shelf Extension 中使用 Alamofire 时出错

"dyld: Library not loaded" error when using Alamofire in tvOS Top Shelf Extension on device

我已经为我的 tvOS 应用构建了一个 Top Shelf Extension。它在模拟器中正常工作。当我 运行 在设备上(开发工具包 运行ning tvOS beta 3)并尝试加载 Top Shelf Extension 时,我的应用程序出现致命错误:

dyld: Library not loaded: @rpath/Alamofire.framework/Alamofire
  Referenced from: /private/var/mobile/Containers/Bundle/Application/5EF46962-235C-4330-9723-623E80E3D8BE/MyApp.app/PlugIns/MyApp TV Services Extension.appex/MyApp TV Services Extension
Reason: image not found

我在 "tvOS" branch 上使用 Xcode 7.1 beta 3、Cocoapods 0.39.0 和 Alamofire 3.0.0。我的Podfile如下:

platform :tvos, '9.0'
use_frameworks!

target 'MyApp' do

end

target 'MyApp TV Services Extension' do
  pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'tvOS'
  pod 'SwiftyJSON', :git => 'https://github.com/jeffbowen/SwiftyJSON.git', :commit => 'fa3fc27c14602e43f69e8d70da4fc2f9a084a987'
end

不确定这是否是 Alamofire、Cocoapods 或 tvOS beta 3 的问题。我被卡住了。

我认为你需要在你的 podfile 中包含这个:

link_with 'MyAppName'

我使用过 Alamofire,当它与这个 tvOs 项目一起使用时可以显示找到的 YouTube 视频 here

事实证明,您还必须在主目标中包含扩展所需的 pods。它现在对我有用,这就是我的 Podfile 的样子:

platform :tvos, '9.0'
use_frameworks!

def shared_pods
  pod 'Alamofire', '~> 3.0'
  pod 'SwiftyJSON', :git => 'https://github.com/jeffbowen/SwiftyJSON.git', :commit => 'fa3fc27c14602e43f69e8d70da4fc2f9a084a987'
end

target 'MyApp' do
  shared_pods
end

target 'MyApp TV Services Extension' do
  shared_pods
end

我学会了shared_pods技巧here

您需要从您的开发者帐户中删除您的设备和配置证书,并为两者创建新证书。创建证书后,下载该证书并拖入钥匙链访问。现在您可以看到带有名称的新证书(不要忘记删除以前的证书并从钥匙链中删除)所以现在您的工作已完成并转到:-

  1. 转到 xcode select 团队开发者帐户。
  2. ios 开发人员(在代码签名身份和 select 任何 [=48] 开发人员资料中以 select 代码登录=] 用于 调试和发布的 SDK).
  3. 将 Embedded-content-contains swift 代码设置为 Yes 默认情况下是 NO
  4. 从设备中删除应用程序。
  5. Shift + Command + k 清理构建。
  6. Command + B 创建新版本。
  7. 一旦构建成功...现在您可以 运行(Command + R) 并且它工作正常。