ios - 在 Xcode 11 中通过 FaSTLane 构建 SPM 包不起作用

标签 ios swift xcode fastlane swift-package-manager

我最近将我的包管理器从 Cocoapods 更新为 SPM,因为 Xcode 11 已经集成了它。我的所有库都已经支持 SPM,所以我尝试了一下。在 Xcode 调试构建期间一切正常,但我目前正在使用 FaSTLane 来自动化部署和测试过程,并且我的 spm 包在测试步骤期间失败,因为我的包不支持 MacO,但某些依赖项支持,所以它以某种方式试图强制我提供 MacOS 支持。不幸的是,我目前无法做到这一点。

您知道我是否错误地使用了 spm,或者这是 spm 的错误吗? RxSwift 也支持 MacO,但 spm 似乎对这个特定的包没有问题,只有 Kingfisher、RxSwiftExt 和 Willow 受到影响。

这是错误:

error: the product 'Kingfisher' requires minimum platform version 10.12 for macos platform
error: the product 'RxSwiftExt' requires minimum platform version 10.11 for macos platform
error: the product 'Willow' requires minimum platform version 10.11 for macos platform

这是我来自 faSTLane/swift 的测试语句

swift test --build-path ./build --package-path Core --configuration debug

这是我的 Package.swift

// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "Core",
    platforms: [
        .iOS(.v11)
    ],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "Core",
            type: .static,
            targets: ["Core"]),
    ],
    dependencies: [
        // Local Dependencies
        .package(path: "../RxKingfisher"),
        // Remote Dependencies
       .package(url: "https://github.com/Nike-Inc/Willow.git",   Package.Dependency.Requirement.branch("master")),
        .package(url: "https://github.com/ReactiveX/RxSwift", .branch("master")),
        .package(url: "https://github.com/Quick/Nimble", .branch("master")),
        .package(url: "https://github.com/Quick/Quick", .branch("master")),
        .package(url: "https://github.com/realm/realm-cocoa", .branch("master")),
        .package(url: "https://github.com/RxSwiftCommunity/RxRealm", .branch("master")),
        .package(url: "https://github.com/RxSwiftCommunity/Action", .branch("master")),
        .package(url: "https://github.com/RxSwiftCommunity/RxSwiftExt", .branch("master")),
        .package(url: "https://github.com/onevcat/Kingfisher", .branch("master")),
        .package(url: "https://github.com/Swinject/Swinject", .branch("master")),
        .package(url: "https://github.com/RxSwiftCommunity/RxDataSources", .branch("master")),
        // We need to change to the master branch after it was merged
        .package(url: "https://github.com/jrendel/SwiftKeychainWrapper", Package.Dependency.Requirement.revision("8b0da97503be8db3b008581a30fdec71046136a7"))
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "Core",
            dependencies: [
                // Remote
                "Realm", "RealmSwift", "RxDataSources", "RxRealm", "Kingfisher", "RxSwift", "Action", "SwiftKeychainWrapper", "RxSwiftExt", "Swinject", "Willow",
                // Locals
                "RxKingfisher"
            ]),
        .testTarget(
            name: "CoreTests",
            dependencies: ["Core", "Quick", "Nimble", "RxTest", "RxBlocking"])
    ]
)


最佳答案

不确定 swift 命令的语法,但使用 xcodebuild 设置目标对我有帮助。

xcodebuild -quiet clean test -project YourProject.xcodeproj -scheme YourScheme -destination 'platform=iOS Simulator,name=iPhone 8'

似乎在 Package.swift 中为 platforms 设置 iOS,您仍然可以将 Mac 作为可用的构建目标,它位于列表的开头,并最终在本例中使用。

关于ios - 在 Xcode 11 中通过 FaSTLane 构建 SPM 包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58233579/

相关文章:

ios - UICollectionView 初始化问题

ios - 为什么我的导航栏不会在滑动时隐藏?

ios - 如何在 React Native 应用程序中创建 "Rate this app"链接?

ios - Heroku 和 MongoDb 上的自定义解析服务器错误 3080 : JSON text did not start with array or object and option to allow fragments not set

arrays - 按对象类型拆分 Swift 数组

objective-c - 如何从 Popover 中的按钮关闭 UIPopover

iphone - RestKit 更新到 xcode 4.4.1 后出现警告

iOS Objective-C/Swift 下载时读取文件

iphone - 如何使用 coreGraphics 在两点连接处添加曲线?

ios - Swift 中是否有 API 可以确定 iOS 设备的处理器寄存器大小?