Scheme Generator is a Swift Package Manager Plugin for quickly updating your Schemes files. It is a great tool for a project that is modularized or that uses TCA.
Add to your dependencies .package(url: "https://github.com/mackoj/SchemeGeneratorPlugin.git", from: "0.5.5"),
.
This plugin works with Xcode 14.1 / 14.0.
The plugin will display messages and errors in Xcode Report navigator.
If the schemesDirectory
point to inside a workspace project.xcworkspace/xcshareddata/xcschemes
you might need to restart Xcode to see all your schemes updated.
You can then invoke the plugin from the root of your repository like so:
swift package plugin scheme-generator
This will generate schemes for all compatible targets defined in your package and write them in schemesDirectory
.
Notice that you must also passed --allow-writing-to-directory
option to SwiftPM. Otherwise SwiftPM will throw an error as it's a sandbox violation for a plugin to write to a package directory without explicit permission.
You can pass --confFile newName.json
to scheme-generator
in order to change the default path for the configuration. It will be saved so that you will not be required to input the configuration fileName at each launch.
To use it you have to set a configuration file at the root of your project named schemeGenerator.json
.
This file contains these keys:
schemesDirectory
: A string that represents where the schemes will be saved(if you use TCA you can put it in workspace)removeNotGeneratedSchemes
: A bool that represents if it should remove schemes that are no longer in Package.swiftoverwriteAlreadyGeneratedSchemes
: A bool that represents if it should force the overwrite of schemes already present schemeexcludedSchemes
: An array of String that represents the name of the schemes files that already exist and should not be processedverbose
: A bool that represents if it should print more information in the console
{
"schemesDirectory": "Project/project.xcworkspace/xcshareddata/xcschemes",
"excludedSchemes": ["Target1Tests", "Target2Tests"],
"removeNotGeneratedSchemes": true,
"overwriteAlreadyGeneratedSchemes": false,
"verbose": true
}
If a new configuration filename is used as explained in #basic-usage step 1. It will be saved so that you will not be required to input the configuration fileName at each launch.
You can use it in CI to automatically generate your schemes.
swift package plugin --allow-writing-to-package-directory scheme-generator
It loads its configuration to figure out what
it can do and where
to apply it. Then it loads all the products from the Package.swift
. Apply a filter to do just what is required then wrote the files in the schemesDirectory
.
The scheme is based on a template.