微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用cocoapods在watchKit 2.0中加载动态库

我无法使用我安装的 CocoaPods成功运行WatchKit应用程序,并且正在获取“dyld:未加载库…原因:未找到图像”错误.

环境如下:Swift 2.0,WatchKit 2.0,CocoaPods 0.38.2,Xcode 7 Beta 4,项目使用我开发的一些内部CocoaPods,用于带有WatchKit扩展的iPhone应用程序.

我已经构建了许多内部使用的CocoaPods,它们包含我想从我的主应用程序和WatchKit扩展中调用的公共代码.下面是Podfile:

source 'https://github.com/CocoaPods/Specs.git'
source 'http://<local-git>/podspecs.git'

use_frameworks!

target 'Destinations511' do
  platform :ios,'9.0'

  pod 'GoogleMaps'
  pod 'apikit',:path => '~/Documents/Libraries/apikit'
  pod 'DestinationsKit',:path => '~/Documents/Libraries/DestinationsKit'
end

target 'Destinations511 WatchKit Extension' do
   platform :watchos,'2.0'

   pod 'apikit',:path => '~/Documents/Libraries/apikit'
   pod 'DestinationsKit',:path => '~/Documents/Libraries/DestinationsKit'
end

我可以构建我的主应用程序,它按预期运行.我可以编译监视工具包应用程序,但是当它运行时,我得到以下内容

dyld: Library not loaded: @rpath/apikit.framework/apikit Referenced from (...) Reason: image not found.

我尝试过针对其他dylib问题提到的解决方案,包括

>确保我的Target-> Build Settings-> Runpath搜索路径包括@ executable_path / Frameworks
>尝试将apikit.framework添加到Target-> General->嵌入式二进制文件(由于某种原因,我选择它时甚至不会添加框架)
>由Podfile解体并重建它.
>将apikit.framework添加到Target-> General-> Linked Frameworks and Libraries

当我在Xcode中查看我的Pods目录时,我看到每个Framework的两个实例(我假设是因为有一个用于应用程序,一个用于监视).即使我成功构建并运行iPhone应用程序,它们都会保持红色.

可能相关,但不确定如何解决,是当我编译(无论目标)时,我得到了一些警告:

ld: warning: linking against dylib not safe for use in application extensions: /Users/dan/Library/Developer/Xcode/DerivedData/MyProject-dlixiemzyqyquocjthlseirhdxcm/Build/Products/Debug-watchsimulator/Pods_MyProject_WatchKit_Extension.framework/Pods_MyProject_WatchKit_Extension

为了完成,这里是apikit的PodSpec

Pod::Spec.new do |s|

  s.name         = "apikit"
  s.version      = "1.1"
  s.summary      = "apikit provides the basic classes and methods common to a number of our apps"

  s.homepage     = "http://.../apikit.git"
  s.license      = { :type => "MIT",:file => "LICENSE" }
  s.author             = { "me" => "[email protected]" }

  s.platform     = :ios
  s.ios.deployment_target = "9.0"
  s.watchos.deployment_target = "2.0"

   s.source       = { :git => "http://my-git-location/apikit.git",:tag => "#{s.version}" }

  s.source_files  = "apikit"

  s.frameworks = "UIKIt","CoreLocation"

  s.requires_arc = true

end

解决方法

这有点违反直觉,当您安装/更新pod时会导致CocoaPods发出警告,但我通过在WatchKit Extension的构建设置中将EMbedDED_CONTENT_CONTAINS_SWIFT设置为NO来解决此问题,即使它包含Swift.该应用程序仍然运行,它在App Store中,但CocoaPods仍然警告我这个设置.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐