Repository navigation
Bare app targets with an Objective-C main.m - #33
Merged
Merged
Conversation
This was referenced Nov 6, 2026
Merged
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.
Bare app targets with an Objective-C main.m
A bare React Native app whose Xcode app target is Objective-C style (
AppDelegate.h/AppDelegate.mmplusmain.min the Sources phase, as every React Native template before 0.77 had) stopped inside xtool's SwiftPM build witherror: 'ios-xtool': library product 'App' should not contain executable targets (it has 'App'). The app target's sources are copied intoSources/Appunder their own names, and SwiftPM makes any target with a compiled file namedmain.<ext>an executable target; xtool needsAppto stay a library, because its builder package links the app's entry point from theApplibrary product. Not a release: the notes stay under[Unreleased].What users get
main.mbuilds. A C-familymainfile (main.m,main.mm,main.c,main.cc,main.cpp,main.cxx, in any case) is copied asAppMain.<ext>in the same folder, so it still compiles into the App library and still definesmain;UIApplicationMain(…, NSStringFromClass([AppDelegate class]))and#import "AppDelegate.h"keep working. The build printsℹ <Target>/main.m is compiled as AppMain.m: SwiftPM takes a target with a file named main for an executable, and xtool links the app's entry point from the App library.AppMain.<ext>, in any folder, gives the existing duplicate-name error, which now says which file is compiled under that name:Two compiled sources share the name AppMain.m (<Target>/main.m, which is compiled as AppMain.m, and <Target>/AppMain.m). The copy step's own "would both be copied to Sources/App/AppMain.m" check covers the same case.main.swiftis refused early, with the remedy. Renaming it would change Swift semantics (top-level code is allowed only inmain.swift), sobuildanddoctor --projectstop withThe app target compiles <Target>/main.swift: … Mark the app delegate class @main (as the React Native template's AppDelegate.swift does), move any other top-level code of main.swift into it, and remove main.swift from the app target.docs/bare-react-native.md, a troubleshooting entry keyed by the SwiftPM message, and a CHANGELOG line under[Unreleased]→### Fixed.Verified
Sources/PackageLoading/PackageBuilder.swift(Sources.computeModuleKind()): a target not declared with an explicit type is an executable when any compiled source's basename, lowercased, starts withmain.and has exactly one dot. Headers are not compiled sources, somain.hdoes not count;main.test.mandMainView.swiftdo not count either. rn-xtool matches the same rule (/^main\.[^.]+$/i).main.m,main.mm,Main.candSupporting/main.mare copied asAppMain.*in their folder with the original name absent and theℹline printed; an app file namedAppMain.mgives the collision error at the copy and at the project read (same folder and another folder);main.swiftandMain.swiftare refused with the remedy; names that only start withmainare left alone.Sources/App; the build on a real app is checked separately.Checks
npm test(2379 passed, 6 skipped) andnpm run lintpass.npm run scan:privateis clean on both commits.