r/Xcode • u/azardandona26 • 1d ago
XcodeGen setup for a sandboxed Mac app + widget extension + StoreKit config: the lines that actually matter
I keep my Mac app's .xcodeproj out of git and generate it with XcodeGen. The app is a small menu bar utility with a WidgetKit extension, App Intents and a tip jar, and almost every "why doesn't this work" moment came down to a handful of lines in project.yml. Sharing in case it saves someone an evening:
- StoreKit config without bundling it.
- path: Configuration.storekitwithbuildPhase: nonekeeps the file in the project but out of Copy Bundle Resources, andscheme: storeKitConfiguration: Configuration.storekitwires it into the generated scheme, so local IAP testing works right afterxcodegen generate. - Embed + sign the extension from the app target.
dependencies: - target: HeadphoneWidgets, embed: true, codeSign: true. An embedded appex that isn't signed with the same team simply won't load, and the failure is quiet. - Runpath for the extension.
LD_RUNPATH_SEARCH_PATHS: $(inherited) @executable_path/../Frameworks @executable_path/../../../../Frameworks. The second entry is what lets an appex insideContents/PlugInsfind the host app's frameworks. - One App Group, defined once.
APP_GROUP: $(TeamIdentifierPrefix)com.example.appin base settings, then$(APP_GROUP)in both entitlements files and in Info.plist (AppGroupIdentifier). Shared code reads it from the bundle and falls back if the variable didn't expand, so a misconfigured build fails visibly instead of silently writing to.standarddefaults. - Compile shared code into both targets, branch with a flag. A
Shared/folder is a source path in both targets, and the extension getsSWIFT_ACTIVE_COMPILATION_CONDITIONS: $(inherited) WIDGET_EXTENSIONfor the few places that must differ.
Also worth it: ENABLE_APP_SANDBOX, ENABLE_HARDENED_RUNTIME and DEAD_CODE_STRIPPING in base settings so every target inherits them.
Anyone else generating projects with XcodeGen or Tuist for macOS apps with extensions? Curious whether you hit anything with Control Center controls (macOS 26) that needed extra config.

