gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:06:16 24 4
gpt4 key购买 nike

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

环境如下:Swift 2.0、WatchKit 2.0、CocoaPods 0.38.2、Xcode 7 Beta 4 和一个使用我为带有 WatchKit 扩展的 iPhone 应用程序开发的内部 CocoaPods 的项目。

我已经构建了许多内部使用的 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

我可以构建我的主应用程序并按预期运行。我可以编译 watch 套件应用程序,但是当它运行时,我得到以下信息:
 dyld: Library not loaded: @rpath/APIKit.framework/APIKit Referenced from (...) Reason: image not found.

我已经尝试过针对其他 dylib 问题提到的解决方案,包括:
  • 确保我的 Target->Build Settings->Runpath Search Paths 包括 @executable_path/Frameworks
  • 尝试将 APIKit.framework 添加到 Target->General->Embedded Binaries(由于某种原因,当我选择它时甚至不会添加框架)
  • 由 Podfile 分解并重建它。
  • 将 APIKit.framework 添加到 Target->General->Linked Frameworks and Libraries

  • 当我在 Xcode 中查看我的 Pods 目录时,我看到每个框架的两个实例(我认为这是因为一个用于应用程序,一个用于 watch )。即使我已经成功构建并运行 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" => "me@me.com" }

    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 发出警告,但我通过设置 EMBEDDED_CONTENT_CONTAINS_SWIFT 解决了这个问题。至 NO在 WatchKit 扩展的build设置中,即使它包含 Swift。该应用程序仍在运行,并且在 App Store 中,但是 CocoaPods 仍然会警告我有关此设置的信息。

    关于cocoapods - 无法使用 cocoapods 在 watchKit 2.0 中加载动态库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31734990/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com