Skip to content

Commit

Permalink
Merge pull request #3293 from daltonclaybrook/dalton/xcode-14-bitcode
Browse files Browse the repository at this point in the history
Fix issue where Carthage doesn’t build for watchOS or tvOS if bitcode is disabled in Xcode 14
  • Loading branch information
giginet committed Nov 12, 2022
2 parents d89afef + cfd5426 commit a91d086
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/CarthageKit/Xcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@ public func buildScheme( // swiftlint:disable:this function_body_length cyclomat
sdkFilter: @escaping SDKFilterCallback = { sdks, _, _, _ in .success(sdks) }
) -> SignalProducer<TaskEvent<URL>, CarthageError> {
precondition(workingDirectoryURL.isFileURL)
let isXcode14OrHigher = XcodeVersion.make()?
.majorVersionNumber
.map { $0 >= 14 } ?? false

let buildArgs = BuildArguments(
project: project,
Expand All @@ -697,7 +700,10 @@ public func buildScheme( // swiftlint:disable:this function_body_length cyclomat
// Filter out SDKs that require bitcode when bitcode is disabled in
// project settings. This is necessary for testing frameworks, which
// must add a User-Defined setting of ENABLE_BITCODE=NO.
return settings.bitcodeEnabled.value == true || !["appletvos", "watchos"].contains(sdk.rawValue)
// In Xcode 14 and up, bitcode is no longer required for any SDK.
return isXcode14OrHigher
|| settings.bitcodeEnabled.value == true
|| !["appletvos", "watchos"].contains(sdk.rawValue)
}
.map { _ in sdk }
}
Expand Down
4 changes: 4 additions & 0 deletions Source/XCDBLD/XcodeVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public struct XcodeVersion {
self.buildVersion = buildVersion
}

public var majorVersionNumber: Int? {
version.components(separatedBy: ".").first.flatMap(Int.init)
}

internal init?(xcodebuildOutput: String) {
let range = NSRange(xcodebuildOutput.startIndex..., in: xcodebuildOutput)
guard let match = XcodeVersion.regex.firstMatch(in: xcodebuildOutput, range: range) else {
Expand Down
7 changes: 7 additions & 0 deletions Tests/XCDBLDTests/XcodeVersionSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class XcodeVersionSpec: QuickSpec {
expect(version2?.buildVersion) == "9M189t"
}
}

describe("major version") {
it("should return correct major version") {
let version = XcodeVersion(xcodebuildOutput: "Xcode 8.3.2\nBuild version 8E2002")
expect(version?.majorVersionNumber) == 8
}
}
}
}
}

0 comments on commit a91d086

Please sign in to comment.