Swiftpack.co - Package - yonaskolb/XcodeGen


Swift Package Manager


XcodeGen is a command line tool that generates your Xcode project using your folder structure and a simple project spec.

The project spec is a YAML or JSON file that defines your targets, configurations, schemes, custom build settings and many other options. All your source directories are automatically parsed and referenced appropriately while preserving your folder structure. Sensible defaults are used in many places, so you only need to customize what is needed. Very complex projects can also be defined as well.

  • ✅ Create projects on demand and remove your .xcodeproj file from git, which means no merge conflicts!
  • ✅ Groups in Xcode are always synced to your directories on disk
  • ✅ Easy configuration of projects which is human readable and git friendly
  • ✅ Easily copy and paste files and directories without having to edit anything in Xcode
  • ✅ Share build settings across multiple targets with build setting groups
  • ✅ Automatically generate Schemes for different environments like test and production
  • ✅ Easily create new projects with complicated setups on demand without messing around with Xcode
  • ✅ Generate from anywhere including on CI
  • ✅ Distribute your spec amongst multiple files for easy sharing and overriding
  • ✅ Easily create multi-platform frameworks
  • ✅ Integrate Carthage frameworks without any work

Given a very simple project spec file like this:

name: MyProject
  bundleIdPrefix: com.myapp
    type: application
    platform: iOS
    deploymentTarget: "10.0"
    sources: [MyApp]
      CUSTOM_BUILD_SETTING: my_value
      - target: MyFramework
    type: framework
    platform: iOS
    sources: [MyFramework]

A project would be created with 2 connected targets, with all the required configurations and build settings. See the Project Spec documentation for all the options you can specify, and Usage for more general documentation.


Make sure Xcode 9.3 is installed first.


$ mint run yonaskolb/xcodegen


$ git clone https://github.com/yonaskolb/XcodeGen.git
$ cd XcodeGen
$ make


$ brew tap yonaskolb/XcodeGen https://github.com/yonaskolb/XcodeGen.git
$ brew install XcodeGen

Swift Package Manager

Use as CLI

$ git clone https://github.com/yonaskolb/XcodeGen.git
$ cd XcodeGen
$ swift run xcodegen

Use as dependency

Add the following to your Package.swift file's dependencies:

.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "1.0.0"),

And then import wherever needed: import XcodeGenKit


Simply run:

$ xcodegen

This will look for a project spec in the current directory called project.yml

Use xcodegen --help to see the list of options:

  • --spec: An optional path to a .yml or .json project spec.
  • --project: An optional path to a directory where the project will be generated. By default this is the directory the spec lives in.
  • --quiet: Suppress informational and success messages. By default this is disabled.


$ git clone https://github.com/yonaskolb/XcodeGen.git
$ cd XcodeGen
$ swift package generate-xcodeproj

This use Swift Project Manager to create an xcodeproj file that you can open, edit and run in Xcode, which makes editing any code easier.

If you want to pass any required arguments when running in Xcode, you can edit the scheme to include launch arguments.


  • See Project Spec documentation for all the various properties and options that can be set
  • See Usage for more specific usage and use case documentation
  • See FAQ for a list of some frequently asked questions
  • See Examples for some real world XcodeGen project specs out in the wild


This tool is powered by:

Inspiration for this tool came from:


Pull requests and issues are welcome


XcodeGen is licensed under the MIT license. See LICENSE for more info.


Stars: 1142
Help us keep the lights on


1.9.0 - Apr 12, 2018


  • Scheme pre and post actions can now be added to target.scheme 280 @yonaskolb
  • Individual files can now be added to fileGroups 293 @yonaskolb


  • Updated to xcproj 4.3.0 for Xcode 9.3 updates
  • Update default Xcode version to 9.3 including new settings 284 @LinusU
  • Breaking for ProjectSpec library users Changed ProjectSpec to Project and ProjectSpec.Options to SpecOptions 281 @jerrymarino


  • Fixed manual build phase of none not being applied to folders 288 @yonaskolb
  • Quoted values now correctly get parsed as strings 282 @yonaskolb
  • Fixed adding a root source folder when createIntermediateGroups is on 291 @yonaskolb
  • Fixed Homebrew installations issues on some machines 289 @vhbit
  • Fixed files that are added as root sources from having invalid parent groups outside the project directory 293 @yonaskolb


1.8.0 - Mar 27, 2018


  • Added Project defaultConfig 269 @keith
  • Added Target attributes 276 @yonaskolb
  • Automatically set DevelopmentTeam and ProvisioningStyle within TargetAttributes if relevant build settings are defined 277 @yonaskolb


  • Fixed default LD_RUNPATH_SEARCH_PATHS for app extensions 272 @LinusU


  • Make LegacyTarget init public 264 @jerrymarino
  • Upgrade to xcproj to 4.2.0, Yams to 0.6.0 and PathKit to 0.9.1 @yonaskolb

1.7.0 - Mar 2, 2018


  • Added support for scheme environment variables 239 254 259 @turekj @toshi0383
  • Added carthageExecutablePath option 244 @akkyie
  • Added parallelizeBuild and buildImplicitDependencies to Schemes 241 @rahul-malik @yonaskolb
  • Added support for Core Data xcdatamodeld files 249 @yonaskolb
  • Projects are now generated atomically by writing to a temporary directory first 250 @yonaskolb
  • Added script for adding precompiled binary to releases 246 @toshi0383
  • Added optional headerVisibilty to target source. This still defaults to public 252 @yonaskolb
  • Releases now include a pre-compiled binary and setting presets, including an install script


  • Fixed Mint installation from reading setting presets 248 @yonaskolb
  • Fixed setting buildPhase on a folder source. This allows for a folder of header files 254 @toshi0383
  • Carthage dependencies are not automatically embedded into test targets 256 @yonaskolb
  • Carthage dependencies now respect the embed property 256 @yonaskolb
  • iMessage extensions now have proper setting presets in regards to app icon and runtime search paths 255 @yonaskolb
  • Excluded files are not added within .lproj directories 238 @toshi0383


1.6.0 - Jan 30, 2018


  • Added scheme pre-actions and post-actions 231 @kastiglione
  • Added options.disabledValidations including missingConfigs to disable project validation errors 220 @keith
  • Generate UI Test Target Attributes 221 @anreitersimon


  • Filter out duplicate source files 217 @allu22
  • Fixed how lastKnownFileType and explicitFileType were generated across platforms 115 @toshi0383
  • Removed a few cases of project diffs when opening the project in Xcode @yonaskolb
  • Fixed Swift not being embedded by default in watch apps @yonaskolb


  • Change arrays to strings in setting presets 218 @allu22
  • Updated to xcproj 4.0 227


1.5.0 - Dec 27, 2017


  • added support for gatherCoverageData flag in target schemes #170 @alexruperez
  • added support for commandLineOptions in target schemes #172 @rahul-malik
  • added Project spec as a SwiftPM library for reuse in other projects #164 @soffes
  • added implicit option for framework dependencies #166 @sbarow
  • added --quite option to CLI #167 @soffes
  • can now print version with -v in addition to --version #174 @kastiglione
  • added support for legacy targets #175 @bkase
  • added support for indentation options #190 @bkase
  • added source excludes #135 #161 #190 @peymankh @
  • added options.xcodeVersion #197 @yonaskolb @peymankh
  • add test targets to Scheme #195 @vhbit
  • add option to make a source file optional incase it will be generated later #200 @vhbit
  • finalize Scheme spec #201 @yonaskolb
  • added buildPhase setting to target source for overriding the guessed build phase of files #206 @yonaskolb
  • added deploymentTarget setting to project and target #205 @yonaskolb


  • huge performance improvements when writing the project file due to changes in xcproj
  • updated dependencies
  • minor logging changes
  • updated Project Spec documentation
  • scan for Info.plist lazely #194 @kastiglione
  • change setting presets so that icon settings only get applied to application targets #204 @yonaskolb
  • changed scheme build targets format #203 @yonaskolb
  • when specifying a --spec argument, the default for the --project path is now the directory containing the spec #211 @yonaskolb


  • fixed shell scripts escaping quotes twice #186 @allu22
  • fixed createIntermediateGroups when using a relative spec path #184 @kastiglione
  • fixed command line arguments for test and profile from being overridden #199 @vhbit
  • fixed files deep within a hierarchy having the path for a name
  • fixed source files from being duplicated if referenced with different casing #212 @yonaskolb
  • fixed target product name not being written. Fixes integration with R.swift #213 @yonaskolb