Modern Apps git

← xtool.git

tests: derive CFBundleSupportedPlatforms from the build triple (#289)

Commit
8041b9286bf720611eba33b50c00d0edc67cafcd
Author
Matt Van Horn <[email protected]>
When
2026-10-04 19:33 UTC (2 months ago)
Parents
ab95680
## What does this PR do?

Application packing now sets CFBundleSupportedPlatforms from
Packer.cfBundleSupportedPlatforms(for:). The helper splits the triple on
hyphens, takes the OS token after apple with any numeric version
stripped, and returns iPhoneSimulator for an ios triple that also
contains simulator, iPhoneOS for other ios triples, MacOSX for macos or
macosx, and iPhoneOS when the triple is missing or unrecognized.
PackerTests covers those triples. Package.resolved drops the
swift-issue-reporting pin and adds xctest-dynamic-overlay 1.13.1.

Application builds aimed at the iOS simulator still ship an Info.plist
whose CFBundleSupportedPlatforms value is iPhoneOS. Hosts that read that
key treat the archive as a physical-device build and refuse to launch it
on a simulator. While packing an application, Packer assigns
CFBundleSupportedPlatforms the fixed array iPhoneOS. The build triple is
already available on buildSettings, but that assignment never reads it,
so a simulator triple is packed the same way as a device triple.

Fixes #191

## How was it tested?

The package builds successfully.

## AI tool usage

How much of this PR was AI-assisted? (check one)

- [ ] **0** - No AI was used to write code
- [ ] **1** - I was assisted by AI. I reviewed the finished result.
- [ ] **2** - I set the AI going and left it to it; nobody has read the
result - no review, or AI review only

AI was used for assistance.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Application metadata now reports the supported platform based on the
build target, including iOS devices, iOS simulators, and macOS. Unknown
targets retain the iOS device platform as a fallback.
* **Tests**
* Added coverage for platform metadata across supported and unknown
build targets.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Matt Van Horn <[email protected]>

Diff

Sources/PackLib/Packer.swift
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 {
Tests/XToolTests/PackerTests.swift
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"])+}