Swiftpack.co - Package - yonaskolb/XcodeGen

XcodeGen

Swift Package Manager

XcodeGen

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 and custom build settings. All you 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.

  • ✅ Easy configuration of projects which is human readable and git friendly
  • ✅ Groups in Xcode are always synced to your directories on disk
  • ✅ Create projects on demand and remove your .xcodeproj file from git, which means no merge conflicts!
  • ✅ 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 Continuous Delivery servers
  • ✅ Distribute your spec amongst multiple files for easy sharing and overriding
  • ✅ Easily create multi-platform frameworks

Given a very simple project spec file like this:

name: MyProject
options:
  bundleIdPrefix: com.myapp
targets:
  MyApp:
    type: application
    platform: iOS
    deploymentTarget: 10.0
    sources: [MyApp]
    settings:
      CUSTOM_BUILD_SETTING: my_value
    dependencies:
      - target: MyFramework
  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.

Installing

Make sure Xcode 9 is installed first.

Mint

$ mint run yonaskolb/xcodegen

Make

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

Homebrew

$ 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

Usage

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.

Editing

$ 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.

Project Spec

See Project Spec documentation here

Attributions

This tool is powered by:

Inspiration for this tool came from:

Contributions

Pull requests and issues are welcome

License

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

Github

link
Stars: 750
Help us keep the lights on

Releases

1.5.0 - Dec 27, 2017

Added

  • 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

Changed

  • 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

  • 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

Commits

1.4.0 - Nov 16, 2017

Added

  • added --version flag #112 @mironal
  • added support for adding individual file sources #106 #133 #142 #139 @bkase
  • added source compiler flag support #121 @bkase
  • added ProjectSpec.options.createIntermediateGroups #108 @bkase
  • added better json loading support #127 @rahul-malik
  • added source name for customizing names of source directories and file #146 @yonaskolb
  • added folder reference source support via a new type property #151 @yonaskolb
  • added ProjectSpec.options.developmentLanguage #155 @yonaskolb

Changed

  • updated to xcproj 1.2.0 #113 @yonaskolb
  • build settings from presets will be removed if they are provided in xcconfig files #77 @toshi0383
  • all files and groups are sorted by type and then alphabetically #144 @yonaskolb
  • target sources can now have an expanded form #119 @yonaskolb
  • empty build phases are now not generated #149 @yonaskolb
  • make UUIDs more deterministic #154 @yonaskolb

Fixed

  • only add headers to frameworks and libraries #118 @ryohey
  • fixed localized files with the same name #126 @ryohey
  • fix intermediate sources #144 @yonaskolb
  • fix cyclical target dependencies not working #147 @yonaskolb
  • fix directory bundles not being added properly when referenced directly #148 @yonaskolb
  • made mm, c and S file be parsed as source files #120 #125 #138 @bkase @enmiller
  • fix the generation of localized variant groups if there is no Base.lproj #157 @ryohey
  • all localizations found are added to a projects known regions #157 @ryohey

Internal

  • refactoring
  • more tests
  • added release scripts

Commits

1.3.0 - Oct 26, 2017

Added

  • generate output files for Carthage copy-frameworks script #84 @mironal
  • added options.settingPreset to choose which setting presets get applied #100 @yonaskolb
  • added link option for target dependencies #109 @keith

Changed

  • updated to xcproj 0.4.1 #85 @enmiller
  • don't copy base settings if config type has been left out #100 @yonaskolb
  • generate localised files under a single variant group #70 @ryohey
  • don't apply common project settings to configs with no type #100 @yonaskolb
  • config references in settings can now be partially matched and are case insensitive #111 @yonaskolb
  • other small internal changes @yonaskolb

Fixed

  • embed Carthage frameworks for macOS #82 @toshi0383
  • fixed copying of watchOS app resources #96 @keith
  • automatically ignore more file types for a target's sources (entitlements, gpx, apns) #94 @keith
  • change make build to a PHONY task #98 @keith
  • allow copying of resource files from dependant targets #95 @keith
  • fixed library linking #93 @keith
  • fixed duplicate carthage file references #107 @yonaskolb
  • an error is now shown if you try and generate a target scheme and don't have debug and release builds @yonaskolb

Commits

1.2.4 - Oct 1, 2017

Fixed

  • setting presets only apply ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES: YES to applications
  • don't add carthage dependency to copy-frameworks script if embed: false
  • sort group children on APFS

Changed

  • update to xcproj 0.3.0

Commits

1.2.3 - Sep 29, 2017

Fixed

  • Fixed wrong carthage directory name reference for macOS #74 @toshi0383
  • Removed unnecessary carthage copy-frameworks for macOS app target #76 @toshi0383
  • Added some missing default settings for framework targets. SKIP_INSTALL: YES fixes archiving
  • Filter out nulls from setting presets if specifying an empty string

Commits