关于ios:在Xcode 11中通过Fastlane构建SPM软件包不起作用

Build SPM Package via Fastlane in Xcode 11 does not work

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

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

这是错误:

1
2
3
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的测试声明

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

这是我的Package.swift

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// 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中将iOS设置为platforms时,您仍将Mac作为可用的构建目标,该目标位于列表的开头,最终在这种情况下被使用。