简体   繁体   English

通过 Xcode 11 中的 Fastlane 构建 SPM Package 不起作用

[英]Build SPM Package via Fastlane in Xcode 11 does not work

I recently updated my package manager from Cocoapods to SPM because Xcode 11 already has it integrated.我最近将我的 package 管理器从 Cocoapods 更新为 SPM,因为 Xcode 11 已经集成了它。 All my libraries already supported SPM, so I gave it a try.我所有的库都已经支持 SPM,所以我试了一下。 It all works fine during Xcode debug building, but I'm currently using Fastlane to automate the deployment and testing process, and my spm package fails during the testing step because my package doesn't support MacOs, but some dependencies do, so it somehow tries to force me to provide MacOS support. It all works fine during Xcode debug building, but I'm currently using Fastlane to automate the deployment and testing process, and my spm package fails during the testing step because my package doesn't support MacOs, but some dependencies do, so it somehow试图强迫我提供 MacOS 支持。 Unfortunately, I can't do that at the moment.不幸的是,我目前不能这样做。

Do you have any idea if I'm using spm incorrectly, or if this is a bug of spm?您是否知道我是否错误地使用了 spm,或者这是 spm 的错误? RxSwift also supports MacOs, but spm seems to have no problem with this particular package, only Kingfisher, RxSwiftExt and Willow are affected. RxSwift 也支持 MacOs,但 spm 似乎对这个特定的 package 没有问题,只有 Kingfisher、RxSwiftExt 和 Willow 受到影响。

This is the error:这是错误:

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

This is my test statement from fastlane/swift这是我来自 fastlane/swift 的测试语句

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

And this is my Package.swift这是我的 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"])
    ]
)


Not sure about the syntax for swift command, but with xcodebuild setting the destination helped me.不确定swift命令的语法,但是通过xcodebuild设置目标对我有帮助。

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

It seems that setting iOS for the platforms in Package.swift you will still have the Mac as available build target, which is at the beginning of the list and ends up being used in this case.似乎为 Package.swift 中的platforms设置 iOS 您仍然可以将 Mac 作为可用的构建目标,它位于列表的开头并最终在这种情况下使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM