feat(ios): add --catalyst to build Mac Catalyst apps - #5
Merged
Conversation
`ns build ios --catalyst` rebuilds the existing iOS target against the macOS SDK with the Mac Catalyst variant, producing a native macOS .app in `platforms/ios/build/<Configuration>-maccatalyst`. Mac Catalyst is a variant of the iOS platform rather than a platform of its own, so this reuses the iOS target instead of introducing a new one: - destination `platform=macOS,variant=Mac Catalyst`, and no `-sdk` — passing one on top of the destination makes xcodebuild fall back to iphoneos - `SUPPORTS_MACCATALYST=YES` is forced, since the runtime template only sets the legacy `SUPPORTS_UIKITFORMAC` alias - signing goes through `-allowProvisioningUpdates`: Catalyst needs a macOS provisioning profile, which the iOS signing service cannot select - Catalyst starts at iOS 13.1, so the deployment target is clamped for this build only (with a warning) rather than failing a project that still targets iOS 12 `MACCATALYST_DEPLOYMENT_TARGET` is passed explicitly because the runtime's metadata generator reads it and older runtimes crash when it is unset. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ns build ios --catalystrebuilds the existing iOS target against the macOS SDK with the Mac Catalyst variant, producing a native macOS.appinplatforms/ios/build/<Configuration>-maccatalyst.Mac Catalyst is a variant of the iOS platform rather than a platform of its own, so this reuses the iOS target instead of introducing a new one. Four things it has to get right:
-sdk.platform=macOS,variant=Mac Catalystselects the variant; passing an SDK on top of it makes xcodebuild fall back toiphoneos, so the Catalyst path suppliesBUILD_DIR/SHARED_PRECOMPS_DIRdirectly instead of going throughgetBuildCommonArgs. Without that the.applands in DerivedData and the CLI reports "No .app found".SUPPORTS_MACCATALYST=YESis forced, since the runtime template only sets the legacySUPPORTS_UIKITFORMACalias.-allowProvisioningUpdates. Catalyst needs a macOS provisioning profile, which$iOSSigningServicecannot select; Xcode creates it automatically.MACCATALYST_DEPLOYMENT_TARGETis passed alongside because the runtime's metadata generator reads it and older runtimes crash when it is unset.Not included: running the result.
ns run <platform>goes through the LiveSync pipeline, which is built aroundMobile.IDevice— a Catalyst app is a local.appyouopen, not a device. Wiring that up means a Mac pseudo-device implementingIDeviceApplicationManager(24 members) andIDeviceFileSystem(34 members) plus device discovery, which belongs in its own PR. For now:open platforms/ios/build/Debug-maccatalyst/<name>.app.Testing
Built a real app (OSS Weather, iOS deployment target 12.0) from a clean
platforms/ios:The
.applaunches on Apple Silicon as a native macOS app — menu bar, resizable window, weather data loading. All 13 CocoaPods dependencies compiled forarm64-apple-ios-macabiwithout changes.tsc --noEmitandnpm run buildare clean.Note this also needs the runtime-side fixes in Akylas/nativescript-ios-runtime#4 — without them the metadata generator crashes or emits metadata with no UIKit.