swift - 如何将 Alamofire pod 添加到 Apple Watch 扩展?

标签 swift cocoapods apple-watch

我有一个名为“watchTest”的 Apple Watch 扩展。我正在尝试为此扩展添加 Alamofire,但直到现在都没有成功。

我的播客文件:

source "https://github.com/CocoaPods/Specs.git"

platform :ios, '9.3'

use_frameworks!

target 'buttonExample' do
    pod 'Alamofire'
end

target 'watchTest' do
    pod 'Alamofire'

    target 'watchTest Extension' do
        inherit! :search_paths
    end

end

Pod 安装日志(警告可能是问题的根源):

Analyzing dependencies
Downloading dependencies
Using Alamofire (4.9.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.

[!] The `watchTest [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-watchTest/Pods-watchTest.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `watchTest [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-watchTest/Pods-watchTest.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

WatchTest 扩展接口(interface) Controller .swift:

import WatchKit
import Foundation
import Alamofire

class InterfaceController: WKInterfaceController {

    override func awake(withContext context: Any?) {
        super.awake(withContext: context)

        // Configure interface objects here.
    }

    override func willActivate() {
        // This method is called when watch view controller is about to be visible to user
        super.willActivate()
    }

    override func didDeactivate() {
        // This method is called when watch view controller is no longer visible
        super.didDeactivate()
    }

}

编译错误:

watchTest Extension: No such module 'Alamofire'

最佳答案

请查看this关联。它表明您必须将 platform :watchos 'version' 添加到目标。

target 'watchTest Extension' do
    platform :watchos, 'version'
    pod 'Alamofire'
end

关于swift - 如何将 Alamofire pod 添加到 Apple Watch 扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57959007/

相关文章:

ios - 如何在特定时间自动删除iOS通知中心的推送通知?

swift - 实例成员 'result' 不能用于类型 'Regex.Match'

ios - CocoaPods 构建项目时出错

ios - Xcode 未使用 XCFrameworks 找到架构 x86_64 的符号

swift - 让 Apple Watch 保持唤醒状态超过 70 秒 (watchOS 3)

ios - 从HealthKit查询中检索HKWorkoutTypeIdentifier

objective-c - 可以使用 Apple Watch Simulator 进行录音吗?

ios - Swift - 从 backBarButtonItem 中删除标题,但保留箭头

swift - 垂直 ScrollView 内的水平 ScrollView 无法使用 swift 工作

swift - 仅过滤距离数据库最近的位置