scaffold_macos_project
Generate a new macOS project with a structured Xcode workspace, SPM package for features, and proper macOS configuration using customizable templates for project setup.
Instructions
Scaffold a new macOS project from templates. Creates a modern Xcode project with workspace structure, SPM package for features, and proper macOS configuration.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bundleIdentifier | No | Bundle identifier (e.g., com.example.myapp). If not provided, will use com.example.projectname | |
| currentProjectVersion | No | Build number (e.g., 1, 42, 100). If not provided, will use 1 | |
| customizeNames | No | Whether to customize project names and identifiers. Default is true. | |
| deploymentTarget | No | macOS deployment target (e.g., 15.4, 14.0). If not provided, will use 15.4 | |
| displayName | No | App display name (shown on home screen/dock). If not provided, will use projectName | |
| marketingVersion | No | Marketing version (e.g., 1.0, 2.1.3). If not provided, will use 1.0 | |
| outputPath | Yes | Path where the project should be created | |
| projectName | Yes | Name of the new project |
Implementation Reference
- src/tools/scaffold.ts:483-530 (handler)The tool handler function: validates, calls shared scaffoldProject with macOS platform, returns success/error response with next stepsasync (params) => { try { const projectParams: ScaffoldProjectParams = { ...params, platform: 'macOS' }; const projectPath = await scaffoldProject(projectParams); const response = { success: true, projectPath, platform: 'macOS', message: `Successfully scaffolded macOS project "${params.projectName}" at ${projectPath}`, nextSteps: [ `Open the project: open ${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace`, `Build for macOS: build_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`, `Run and run on macOS: build_run_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`, ], }; return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { log( 'error', `Failed to scaffold macOS project: ${error instanceof Error ? error.message : String(error)}`, ); return { content: [ { type: 'text', text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', }, null, 2, ), }, ], }; } },
- src/tools/scaffold.ts:62-67 (schema)Zod schema for macOS project scaffolding parameters, extending base schema with deploymentTargetconst ScaffoldmacOSProjectSchema = BaseScaffoldSchema.extend({ deploymentTarget: z .string() .optional() .describe('macOS deployment target (e.g., 15.4, 14.0). If not provided, will use 15.4'), });
- src/tools/scaffold.ts:478-531 (registration)Registration of the scaffold_macos_project tool using registerTool, including name, description, schema, and handlerregisterTool<ScaffoldmacOSProjectParams>( server, 'scaffold_macos_project', 'Scaffold a new macOS project from templates. Creates a modern Xcode project with workspace structure, SPM package for features, and proper macOS configuration.', ScaffoldmacOSProjectSchema.shape, async (params) => { try { const projectParams: ScaffoldProjectParams = { ...params, platform: 'macOS' }; const projectPath = await scaffoldProject(projectParams); const response = { success: true, projectPath, platform: 'macOS', message: `Successfully scaffolded macOS project "${params.projectName}" at ${projectPath}`, nextSteps: [ `Open the project: open ${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace`, `Build for macOS: build_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`, `Run and run on macOS: build_run_mac_ws --workspace-path "${projectPath}/${params.customizeNames ? params.projectName : 'MyProject'}.xcworkspace" --scheme "${params.customizeNames ? params.projectName : 'MyProject'}"`, ], }; return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { log( 'error', `Failed to scaffold macOS project: ${error instanceof Error ? error.message : String(error)}`, ); return { content: [ { type: 'text', text: JSON.stringify( { success: false, error: error instanceof Error ? error.message : 'Unknown error occurred', }, null, 2, ), }, ], }; } }, );
- src/tools/scaffold.ts:380-418 (helper)Shared core scaffolding function called by both iOS and macOS handlers: gets template, processes directory recursively replacing placeholders and updating configsasync function scaffoldProject(params: ScaffoldProjectParams): Promise<string> { const { projectName, outputPath, platform, customizeNames = true } = params; log('info', `Scaffolding project: ${projectName} (${platform}) at ${outputPath}`); // Validate project name if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(projectName)) { throw new ValidationError( 'Project name must start with a letter and contain only letters, numbers, and underscores', ); } // Get template path from TemplateManager let templatePath: string; try { templatePath = await TemplateManager.getTemplatePath(platform); } catch (error) { throw new ValidationError( `Failed to get template for ${platform}: ${error instanceof Error ? error.message : String(error)}`, ); } // Create output directory const projectPath = join(outputPath, customizeNames ? projectName : 'MyProject'); if (existsSync(projectPath)) { throw new ValidationError(`Project directory already exists at ${projectPath}`); } try { // Process the template await processDirectory(templatePath, projectPath, params); return projectPath; } finally { // Clean up downloaded template if needed await TemplateManager.cleanup(templatePath); } }