There are many benefits on using XcodeGen to create our Xcode project.
- Avoid merge conflicts on the project file
- Framework and dependencies can be added very easy
- No accidental changes on the project file
- Easy to add new targets
- Easy to add new configurations
XcodeGen is a command line tool that uses a folder structure and spec (yaml or json) to create the Xcode project.
We can install XcodeGen using brew
1 |
brew install xcodegen |
After this all we have to do is to create yml file which declares where the files are, target and configurations names.
We can also add settings and paths for Info.plist and other files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
configs: Debug: debug Release: release name: TESTAPP options: bundleIdPrefix: com.trikalabs xcodeVersion: '13.2.1' deploymentTarget: '15.2' groupSortPosition: top generateEmptyDirectories: true findCarthageFrameworks: false minimumXcodeGenVersion: '2.18.0' targets: TESTAPP: type: application platform: iOS deploymentTarget: 15.2 settings: base: MARKETING_VERSION: 1.0 sources: - path: ../TESTAPP/TESTAPP info: path: "../TESTAPP/TESTAPP/Info.plist" settings: base: IPHONEOS_DEPLOYMENT_TARGET: 15.2 ENABLE_BITCODE: NO SWIFT_VERSION: 5.2 configs: Release: ENABLE_BITCODE: YES |
Then all we have to do in order to create our project file is
1 |
xcodegen -s ./project.yml -p ./ |
Resources:
https://github.com/yonaskolb/XcodeGen
https://ricardojpsantos.medium.com/avoiding-merge-conflicts-with-xcodegen-a0e2a1647bcb