1. Template Variables
| Variable | Description |
|---|---|
__APP_NAME__ |
App display name and target name |
__BUNDLE_PREFIX__ |
Bundle ID prefix (e.g., com.username) |
__BUNDLE_ID__ |
Full bundle ID (__BUNDLE_PREFIX__.__APP_NAME__) |
__MACOS_TARGET__ |
macOS deployment target (default: 26.0) |
__IOS_TARGET__ |
iOS deployment target (default: 26.0) |
2. XcodeGen Path (Primary)
Steps when xcodegen is available:
- Create directory structure:
Sources/<AppName>/,Tests/<AppName>Tests/ - Write
project.ymlfrom template (selectmacos.project.ymlorios.project.yml) - Replace all
__TEMPLATE_VAR__placeholders with actual values - Write
AppEntry.swiftandContentView.swiftfrom templates - Write
.gitignorefrom template - Run
xcodegen generate - Open the generated project in Xcode and verify with
BuildProjectwhen the bridge is available, otherwise usexcodebuild
3. Manual Xcode Fallback
Steps when xcodegen is NOT available:
- Stop the automated scaffold path and tell the user there is no official Xcode MCP project-scaffolding tool in this toolkit.
- Ask the user to either install XcodeGen or create a new App project in Xcode manually.
- Once the project exists, write the template-based
AppEntry.swift,ContentView.swift, and.gitignorefiles into that project structure. - Verify with
BuildProjectif the project is open in Xcode, otherwise usexcodebuild.
4. App Archetypes
Standard (WindowGroup)
@main
struct __APP_NAME__App: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Document-Based
@main
struct __APP_NAME__App: App {
var body: some Scene {
DocumentGroup(newDocument: __APP_NAME__Document()) { file in
ContentView(document: file.$document)
}
}
}
Menu Bar Extra
@main
struct __APP_NAME__App: App {
var body: some Scene {
MenuBarExtra("__APP_NAME__", systemImage: "star.fill") {
ContentView()
}
.menuBarExtraStyle(.window)
}
}
Utility (Single Window)
@main
struct __APP_NAME__App: App {
var body: some Scene {
Window("__APP_NAME__", id: "main") {
ContentView()
}
.defaultSize(width: 600, height: 400)
}
}
5. Post-Scaffold Checklist
| Requirement | How to verify |
|---|---|
| Swift 6.2 strict concurrency | SWIFT_STRICT_CONCURRENCY = complete in build settings |
| Correct deployment target | Check MACOSX_DEPLOYMENT_TARGET or IPHONEOS_DEPLOYMENT_TARGET |
| Working .xcodeproj | BuildProject succeeds with clean build |
| Test target wired | RunAllTests runs (even with 0 tests) |
| RenderPreview works | ContentView has #Preview block |
| Proper app bundle (.app) | Target type is application |
| Git-friendly | .gitignore excludes .xcodeproj (if XcodeGen), includes project.yml |
Cross-References
apple-app-architect:swift-app-lifecycle— scene structure detailsapple-app-builder:xcode-mcp— BuildProject, diagnostics, previews, and targeted tests