GitXplorerGitXplorer
m

SchemeGeneratorPlugin

public
6 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
aea066b78226a13c2f5fd31667d9f80abe397a44

Update README.md

mmackoj committed 2 years ago
Verified
326364ac396ca4da85a3bc7a81bb09497a2cfa05

Update README.md

mmackoj committed 2 years ago
Verified
1e619602fb3c350088ccf7d0bec156af151dc9b4

Update README.md

mmackoj committed 2 years ago
Unverified
78c5d5edee9aab0f51428dc90eaf537dea9315af

Fix name

mmackoj committed 2 years ago
Verified
f4aed4c24e83995f1aaaaf4f1b77e2bc79ff1bff

Update Package.swift

mmackoj committed 2 years ago
Verified
f0eb683adc198a0c9ba5ee08cc0a3d3fe3a057bc

Update schemeGenerator.json

mmackoj committed 2 years ago

README

The README file for this repository.

Scheme Generator

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.

⚠️ This is in beta

Installation

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.

Basic usage

The plugin will display messages and errors in Xcode Report navigator.

step description img
0 To run it right click on the package you want to run it on. Capture d’écran 2022-10-21 à 13 16 35
1 It will propose you to run it you can provide an optional argument(--confFile newName.json) that will allow you to change the name of the configuration file. Once change the new configuration file name will be stored Capture d’écran 2022-10-21 à 13 38 29
2 At first launch, it will ask for permission to write files into the schemesDirectory for it to work you have to select "Allow Command to Change Files". Capture d’écran 2022-10-21 à 01 35 07

If the schemesDirectory point to inside a workspace project.xcworkspace/xcshareddata/xcschemes you might need to restart Xcode to see all your schemes updated.

How to use in CLI

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.

Configuration

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.swift
  • overwriteAlreadyGeneratedSchemes: A bool that represents if it should force the overwrite of schemes already present scheme
  • excludedSchemes: An array of String that represents the name of the schemes files that already exist and should not be processed
  • verbose: 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.

CI

You can use it in CI to automatically generate your schemes.

swift package plugin --allow-writing-to-package-directory scheme-generator

How Does it Work?

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.