Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
tests: derive CFBundleSupportedPlatforms from the build triple (#289)
Matt Van Horn8041b9286bf7
diff --git a/Sources/PackLib/Packer.swift b/Sources/PackLib/Packer.swiftindex d41cb7f..bd2057b 100644--- a/Sources/PackLib/Packer.swift+++ b/Sources/PackLib/Packer.swift@@ -193,7 +193,7 @@ public struct Packer: Sendable {if product.type == .application {info["UIRequiredDeviceCapabilities"] = ["arm64"]info["LSRequiresIPhoneOS"] = true- info["CFBundleSupportedPlatforms"] = ["iPhoneOS"]+ info["CFBundleSupportedPlatforms"] = Packer.cfBundleSupportedPlatforms(for: buildSettings.triple)}if let iconPath = product.iconPath {@@ -210,6 +210,26 @@ public struct Packer: Sendable {try encodedPlist.write(to: infoPath)}}++ static func cfBundleSupportedPlatforms(for triple: String) -> [String] {+ let components = triple.split(separator: "-").map(String.init)+ guard let appleIndex = components.firstIndex(of: "apple"),+ components.indices.contains(appleIndex + 1) else {+ return ["iPhoneOS"]+ }++ let os = components[appleIndex + 1].prefix { !$0.isNumber }+ switch os {+ case "ios" where components.contains("simulator"):+ return ["iPhoneSimulator"]+ case "ios":+ return ["iPhoneOS"]+ case "macos", "macosx":+ return ["MacOSX"]+ default:+ return ["iPhoneOS"]+ }+ }}extension Plan.Product {diff --git a/Tests/XToolTests/PackerTests.swift b/Tests/XToolTests/PackerTests.swiftnew file mode 100644index 0000000..5aabda8--- /dev/null+++ b/Tests/XToolTests/PackerTests.swift@@ -0,0 +1,15 @@+import Testing+@testable import PackLib++@Test func cfBundleSupportedPlatformsFollowsBuildTriple() {+ #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios") == ["iPhoneOS"])+ #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios-simulator") == ["iPhoneSimulator"])++ #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios17.0") == ["iPhoneOS"])+ #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-ios17.0-simulator") == ["iPhoneSimulator"])+ #expect(Packer.cfBundleSupportedPlatforms(for: "x86_64-apple-ios-simulator") == ["iPhoneSimulator"])+ #expect(Packer.cfBundleSupportedPlatforms(for: "arm64-apple-macosx") == ["MacOSX"])+ #expect(Packer.cfBundleSupportedPlatforms(for: "x86_64-apple-macosx") == ["MacOSX"])++ #expect(Packer.cfBundleSupportedPlatforms(for: "unknown-triple") == ["iPhoneOS"])+}