Learning is like rowing upstream; not to advance is to drop back. The original | address

XcodeGen is a command line tool written in Swift that uses folder structures and project specifications to generate your Xcode projects. XcodeGen is currently available on Github with 5K Star at github.com/yonaskolb/X… Github.com/uzi-yyds-co…

XcodeGen has a YAML or JSON file that defines your goals, configurations, schemas, custom build Settings, and many other options. All of your source directories are automatically resolved and referenced appropriately, while preserving your folder structure. Reasonable defaults are used in many places, so you only need to customize what you need. You can also use more advanced capabilities to define very complex projects.

advantages

As an Xcode helper, it has the following advantages:

  • Build projects on demand and remove your.xcodeProj from Git, which means no more merge conflicts!

  • Groups and files in Xcode are always synchronized to directories on your disk

  • Easy to configure project, readable and Git friendly

  • Easily copy and paste files and directories without editing anything in Xcode

  • Use build Settings groups to share build Settings across multiple targets

  • Generate solutions automatically for different environments such as test and production

  • Easily create new projects with complex Settings as needed, without using Xcode

  • Generate from anywhere, including CI

  • Distribute your specification across multiple files for easy sharing and overwriting

  • Easily create multi-platform frameworks

  • Integrate the Carthage framework without any effort

  • Export the dependency graph to view in Graphviz

The project specification

Here is a project specification file:

name: MyProject include: - base_spec.yml options: bundleIdPrefix: com.myapp packages: Yams: url: https://github.com/jpsim/Yams from: 2.0.0 targets: MyApp: type: application platform: iOS deploymentTarget: "10.0" Sources: [MyApp] Settings: configs: debug: CUSTOM_BUILD_SETTING: my_debug_value Release: CUSTOM_BUILD_SETTING: my_release_value dependencies: - target: MyFramework - carthage: Alamofire - framework: Vendor/MyFramework.framework - sdk: Contacts.framework - sdk: libc++.tbd - package: Yams MyFramework: type: Framework Platform: iOS Sources: [MyFramework] will create a project with two connected targets that contains all the necessary configuration and build Settings.Copy the code

The installation

To install XcodeGen, first make sure you have Xcode 11+ installed, and then there are several ways to install it

Mint

mint install yonaskolb/xcodegen
Copy the code

Make

git clone https://github.com/yonaskolb/XcodeGen.gitcd XcodeGenmake install
Copy the code

Homebrew

brew install xcodegen
Copy the code

Swift package manager

Used for CLI

git clone https://github.com/yonaskolb/XcodeGen.gitcd XcodeGenswift run xcodegen
Copy the code

Used to rely on

Add the following to the dependencies of the package. swift file:

Package (url: "https://github.com/yonaskolb/XcodeGen.git", from: "2.25.0"),Copy the code

Then import XcodeGenKit where necessary

use

XcodeGen is also very simple to use, just run the following command:

xcodegen generate
Copy the code

This will look for the project specification named project.yml in the current directory and generate an Xcode project with the name defined in the specification.

This command has the following options

  • Optional path to spec:.yml or.json project specifications. The default for the project. Yml

  • Project: Optional path to the directory to build the project. By default, this is the directory where the specification resides.

  • Quiet: Suppression messages and success messages.

  • Use-cache: Used to prevent projects from being generated unnecessarily. If this is set, the project is written to the cache file when it is built. If you run XCodeGen later but the specification and all the files it contains are the same, the project will not be generated.

  • Cache-path: user-defined path for cache files. The default is ~ /. Xcodegen/cache / {PROJECT_SPEC_PATH_HASH}

There are other combined commands, such as XcodeGen Dump, which can output parsed specifications in a number of different formats or write them to a file. More detailed usage information can be viewed using XcodeGen Help.

Download iOS resources/source files at github.com/uzi-yyds-co…