XcodeGen/README.md

159 lines
5.0 KiB
Markdown
Raw Permalink Normal View History

2017-07-29 15:52:30 +03:00
<p align="center">
<a href="https://github.com/yonaskolb/XcodeGen">
2017-07-29 23:36:40 +03:00
<img src="Assets/Logo_animated.gif" alt="XcodeGen" />
2017-07-29 15:52:30 +03:00
</a>
</p>
2017-07-29 16:04:19 +03:00
<p align="center">
2017-09-28 12:28:22 +03:00
<a href="https://swift.org/package-manager">
<img src="https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat" alt="Swift Package Manager" />
</a>
2017-07-29 16:04:19 +03:00
<a href="https://github.com/yonaskolb/XcodeGen/releases">
<img src="https://img.shields.io/github/release/yonaskolb/xcodegen.svg"/>
</a>
<a href="https://travis-ci.org/yonaskolb/XcodeGen">
<img src="https://img.shields.io/travis/yonaskolb/XcodeGen/master.svg?style=flat"/>
</a>
<a href="https://github.com/yonaskolb/XcodeGen/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/mashape/apistatus.svg"/>
</a>
2017-10-19 20:31:09 +03:00
<a href="http://xcodeswift.herokuapp.com/">
<img src="https://xcodeswift.herokuapp.com/badge.svg">
</a>
2017-07-29 16:04:19 +03:00
</p>
2017-07-29 15:52:30 +03:00
2017-07-22 23:01:30 +03:00
# 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.
2017-07-24 20:13:15 +03:00
2017-07-29 12:21:45 +03:00
- ✅ 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**
2017-07-29 12:24:00 +03:00
- ✅ Automatically generate Schemes for **different environments** like test and production
- ✅ Easily **create new projects** with complicated setups on demand without messing around with Xcode
2017-07-29 12:21:45 +03:00
- ✅ Generate from anywhere including **Continuous Delivery** servers
2017-08-30 14:03:05 +03:00
- ✅ Distribute your spec amongst multiple files for easy **sharing** and overriding
2017-12-27 14:09:23 +03:00
- ✅ Easily create **multi-platform** frameworks
2017-07-29 12:21:45 +03:00
Given a very simple project spec file like this:
2017-07-27 00:06:34 +03:00
2017-07-24 20:20:44 +03:00
```yaml
2017-12-27 14:09:23 +03:00
name: MyProject
options:
2017-12-26 19:24:49 +03:00
bundleIdPrefix: com.myapp
2017-07-24 20:51:33 +03:00
targets:
2017-09-14 21:53:34 +03:00
MyApp:
2017-07-24 20:13:15 +03:00
type: application
platform: iOS
2017-12-26 19:24:49 +03:00
deploymentTarget: 10.0
2017-12-27 14:20:02 +03:00
sources: [MyApp]
2017-07-27 00:06:34 +03:00
settings:
2017-12-27 14:20:02 +03:00
CUSTOM_BUILD_SETTING: my_value
2017-07-24 20:13:15 +03:00
dependencies:
- target: MyFramework
2017-09-14 21:53:34 +03:00
MyFramework:
2017-07-24 20:13:15 +03:00
type: framework
2017-08-27 17:58:36 +03:00
platform: iOS
2017-12-27 14:20:02 +03:00
sources: [MyFramework]
2017-07-24 20:13:15 +03:00
```
2017-11-13 19:31:16 +03:00
A project would be created with 2 connected targets, with all the required configurations and build settings. See the [Project Spec](Docs/ProjectSpec.md) documentation for all the options you can specify.
2017-07-24 20:13:15 +03:00
2017-07-28 14:55:36 +03:00
## Installing
Make sure Xcode 9 is installed first.
2017-07-28 14:55:36 +03:00
2017-10-02 18:05:55 +03:00
### [Mint](https://github.com/yonaskolb/mint)
2017-09-29 12:00:30 +03:00
```sh
$ mint run yonaskolb/xcodegen
```
2017-07-29 12:24:00 +03:00
### Make
2017-07-24 20:13:15 +03:00
```
2017-07-28 14:55:36 +03:00
$ git clone https://github.com/yonaskolb/XcodeGen.git
$ cd XcodeGen
$ make
2017-07-24 20:13:15 +03:00
```
2017-08-25 17:55:31 +03:00
2017-09-19 12:54:43 +03:00
### Homebrew
2017-08-25 17:55:31 +03:00
```
$ brew tap yonaskolb/XcodeGen https://github.com/yonaskolb/XcodeGen.git
$ brew install XcodeGen
2017-08-25 17:55:31 +03:00
```
2017-07-28 14:55:36 +03:00
2017-07-29 12:24:00 +03:00
### Swift Package Manager
2017-07-28 14:55:36 +03:00
2017-09-27 12:29:57 +03:00
**Use as CLI**
2017-07-24 20:13:15 +03:00
```
2017-07-29 12:21:45 +03:00
$ git clone https://github.com/yonaskolb/XcodeGen.git
$ cd XcodeGen
2017-12-27 12:50:30 +03:00
$ swift run xcodegen
2017-07-24 20:13:15 +03:00
```
2017-07-29 12:21:45 +03:00
**Use as dependency**
Add the following to your Package.swift file's dependencies:
2017-07-28 14:55:36 +03:00
2017-07-24 20:13:15 +03:00
```
2017-10-02 18:08:15 +03:00
.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "1.0.0"),
2017-07-24 20:13:15 +03:00
```
2017-07-29 12:21:45 +03:00
And then import wherever needed: `import XcodeGenKit`
2017-07-24 20:13:15 +03:00
## Usage
2017-07-29 12:21:45 +03:00
Simply run:
2017-07-28 14:55:36 +03:00
```
$ xcodegen
```
2017-07-29 12:21:45 +03:00
This will look for a project spec in the current directory called `project.yml`
2017-07-28 14:55:36 +03:00
Use `xcodegen --help` to see the list of options:
2017-07-28 14:55:36 +03:00
2017-11-22 07:48:29 +03:00
- **--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.
2017-11-22 07:48:29 +03:00
- **--quiet**: Suppress informational and success messages. By default this is disabled.
2017-07-28 14:55:36 +03:00
## 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.
2017-07-24 20:13:15 +03:00
## Project Spec
2017-11-13 19:31:16 +03:00
See Project Spec documentation [here](Docs/ProjectSpec.md)
2017-07-24 20:18:37 +03:00
## Attributions
This tool is powered by:
- [xcodeproj](https://github.com/carambalabs/xcodeproj)
- [JSONUtilities](https://github.com/yonaskolb/JSONUtilities)
- [Spectre](https://github.com/kylef/Spectre)
- [PathKit](https://github.com/kylef/PathKit)
- [Commander](https://github.com/kylef/Commander)
- [Yams](https://github.com/jpsim/Yams)
2017-07-29 12:21:45 +03:00
Inspiration for this tool came from:
2017-07-28 16:05:04 +03:00
- [struct](https://github.com/workshop/struct)
- [xcake](https://github.com/jcampbell05/xcake)
- [CocoaPods Xcodeproj](https://github.com/CocoaPods/Xcodeproj)
2017-07-28 16:05:04 +03:00
2017-07-24 20:18:37 +03:00
## Contributions
Pull requests and issues are welcome
## License
2017-07-29 12:21:45 +03:00
XcodeGen is licensed under the MIT license. See [LICENSE](LICENSE) for more info.