【问题标题】:"dyld: Library not loaded" error when using Alamofire in tvOS Top Shelf Extension on device在设备上的 tvOS Top Shelf Extension 中使用 Alamofire 时出现“dyld:未加载库”错误
【发布时间】:2015-10-16 17:02:18
【问题描述】:

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

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 的问题。我被卡住了。

【问题讨论】:

    标签: xcode cocoapods alamofire tvos


    【解决方案1】:

    事实证明,您还必须在主要目标中包含扩展所需的 pod。它现在对我有用,这就是我的 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

    【讨论】:

    • 请注意不再需要指定 tvOS 分支,因为它已与主分支合并。
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

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

      link_with 'MyAppName'
      

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

      【讨论】:

      • 这似乎对我不起作用。我遇到了和@Jeff 一样的问题。
      • 感谢@frakman1 的建议。 link_with 不过对我不起作用。通过将 pod 包含在扩展目标和我的主要目标中来让它工作。查看我刚刚添加的答案,@nortchuck。
      猜你喜欢
      • 1970-01-01
      • 2016-06-23
      • 2014-07-25
      • 2018-08-14
      • 2019-11-08
      • 1970-01-01
      • 2014-09-22
      • 2020-06-18
      • 2018-11-07
      相关资源
      最近更新 更多