mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
rename setting presets to setting groups
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
name: EnvironmentTest
|
||||
settingPresets:
|
||||
settingGroups:
|
||||
app:
|
||||
PRODUCT_BUNDLE_IDENTIFIER: com.app$(BUNDLE_ID_SUFFIX)$(BUNDLE_ID_EXTENSION_SUFFIX)
|
||||
test:
|
||||
|
||||
@@ -8,11 +8,11 @@ settings:
|
||||
configs:
|
||||
my_config:
|
||||
BUILD_SETTING_2: value 2
|
||||
presets:
|
||||
groups:
|
||||
- my_settings
|
||||
|
||||
name: SettingsTest
|
||||
settingPresets:
|
||||
settingGroups:
|
||||
preset1:
|
||||
SETTING: value
|
||||
preset2:
|
||||
@@ -29,12 +29,12 @@ settingPresets:
|
||||
base:
|
||||
SETTING: value
|
||||
preset5:
|
||||
presets:
|
||||
groups:
|
||||
- preset1
|
||||
base:
|
||||
SETTING: value
|
||||
preset6:
|
||||
presets:
|
||||
groups:
|
||||
- preset1
|
||||
base:
|
||||
SETTING: value
|
||||
@@ -46,7 +46,7 @@ settingPresets:
|
||||
SETTING: value
|
||||
configs:
|
||||
config1:
|
||||
presets:
|
||||
groups:
|
||||
- preset1
|
||||
base:
|
||||
SETTING: value
|
||||
@@ -59,7 +59,7 @@ settingPresets:
|
||||
settings:
|
||||
base:
|
||||
SETTING 5: value 5
|
||||
presets:
|
||||
groups:
|
||||
- preset7
|
||||
configs:
|
||||
config1:
|
||||
@@ -72,13 +72,13 @@ targets:
|
||||
type: application
|
||||
platform: iOS
|
||||
settings:
|
||||
presets:
|
||||
groups:
|
||||
- preset7
|
||||
base:
|
||||
SETTING 2: value 2
|
||||
configs:
|
||||
config1:
|
||||
presets:
|
||||
groups:
|
||||
- preset1
|
||||
base:
|
||||
SETTING 3: value 3
|
||||
|
||||
@@ -26,7 +26,7 @@ The project spec is a YAML or JSON file that defines your targets, configuration
|
||||
- ✅ 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 presets**
|
||||
- ✅ Share build settings across multiple targets with **build setting groups**
|
||||
- ✅ Automatically generate Schemes for **different environments** like test and production
|
||||
- ✅ Easily **create new projects** with complicated setups on demand without messing around with Xcode
|
||||
- ✅ Generate from anywhere including **Continuous Delivery** servers
|
||||
|
||||
@@ -17,7 +17,7 @@ public struct ProjectSpec {
|
||||
public var name: String
|
||||
public var targets: [Target]
|
||||
public var settings: Settings
|
||||
public var settingPresets: [String: Settings]
|
||||
public var settingGroups: [String: Settings]
|
||||
public var configs: [Config]
|
||||
public var schemes: [Scheme]
|
||||
public var options: Options
|
||||
@@ -30,12 +30,12 @@ public struct ProjectSpec {
|
||||
}
|
||||
}
|
||||
|
||||
public init(name: String, configs: [Config] = [], targets: [Target] = [], settings: Settings = .empty, settingPresets: [String: Settings] = [:], schemes: [Scheme] = [], options: Options = Options()) {
|
||||
public init(name: String, configs: [Config] = [], targets: [Target] = [], settings: Settings = .empty, settingGroups: [String: Settings] = [:], schemes: [Scheme] = [], options: Options = Options()) {
|
||||
self.name = name
|
||||
self.targets = targets
|
||||
self.configs = configs
|
||||
self.settings = settings
|
||||
self.settingPresets = settingPresets
|
||||
self.settingGroups = settingGroups
|
||||
self.schemes = schemes
|
||||
self.options = options
|
||||
}
|
||||
@@ -55,7 +55,7 @@ extension ProjectSpec: Equatable {
|
||||
return lhs.name == rhs.name &&
|
||||
lhs.targets == rhs.targets &&
|
||||
lhs.settings == rhs.settings &&
|
||||
lhs.settingPresets == rhs.settingPresets &&
|
||||
lhs.settingGroups == rhs.settingGroups &&
|
||||
lhs.configs == rhs.configs &&
|
||||
lhs.schemes == rhs.schemes &&
|
||||
lhs.options == rhs.options
|
||||
@@ -86,7 +86,7 @@ extension ProjectSpec {
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
name = try jsonDictionary.json(atKeyPath: "name")
|
||||
settings = jsonDictionary.json(atKeyPath: "settings") ?? .empty
|
||||
settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? [:]
|
||||
settingGroups = jsonDictionary.json(atKeyPath: "settingGroups") ?? jsonDictionary.json(atKeyPath: "settingPresets") ?? [:]
|
||||
let configs: [String: String] = jsonDictionary.json(atKeyPath: "configs") ?? [:]
|
||||
self.configs = configs.map { Config(name: $0, type: ConfigType(rawValue: $1)) }
|
||||
self.targets = try Target.decodeTargets(jsonDictionary: jsonDictionary)
|
||||
|
||||
@@ -15,46 +15,46 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl
|
||||
|
||||
public let buildSettings: BuildSettings
|
||||
public let configSettings: [String: Settings]
|
||||
public let presets: [String]
|
||||
public let groups: [String]
|
||||
|
||||
public init(buildSettings: BuildSettings = [:], configSettings: [String: Settings] = [:], presets: [String] = []) {
|
||||
public init(buildSettings: BuildSettings = [:], configSettings: [String: Settings] = [:], groups: [String] = []) {
|
||||
self.buildSettings = buildSettings
|
||||
self.configSettings = configSettings
|
||||
self.presets = presets
|
||||
self.groups = groups
|
||||
}
|
||||
|
||||
public init(dictionary: [String: Any]) {
|
||||
buildSettings = dictionary
|
||||
configSettings = [:]
|
||||
presets = []
|
||||
groups = []
|
||||
}
|
||||
|
||||
static let empty: Settings = Settings(dictionary: [:])
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
if jsonDictionary["configs"] != nil || jsonDictionary["presets"] != nil || jsonDictionary["base"] != nil {
|
||||
presets = jsonDictionary.json(atKeyPath: "presets") ?? []
|
||||
if jsonDictionary["configs"] != nil || jsonDictionary["groups"] != nil || jsonDictionary["base"] != nil {
|
||||
groups = jsonDictionary.json(atKeyPath: "groups") ?? jsonDictionary.json(atKeyPath: "presets") ?? []
|
||||
let buildSettingsDictionary: JSONDictionary = jsonDictionary.json(atKeyPath: "base") ?? [:]
|
||||
buildSettings = buildSettingsDictionary
|
||||
configSettings = jsonDictionary.json(atKeyPath: "configs") ?? [:]
|
||||
} else {
|
||||
buildSettings = jsonDictionary
|
||||
configSettings = [:]
|
||||
presets = []
|
||||
groups = []
|
||||
}
|
||||
}
|
||||
|
||||
public static func ==(lhs: Settings, rhs: Settings) -> Bool {
|
||||
return NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) &&
|
||||
lhs.configSettings == rhs.configSettings &&
|
||||
lhs.presets == rhs.presets
|
||||
lhs.groups == rhs.groups
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
var string: String = ""
|
||||
if !buildSettings.isEmpty {
|
||||
let buildSettingDescription = buildSettings.map { "\($0) = \($1)" }.joined(separator: "\n")
|
||||
if !configSettings.isEmpty || !presets.isEmpty {
|
||||
if !configSettings.isEmpty || !groups.isEmpty {
|
||||
string += "base:\n " + buildSettingDescription.replacingOccurrences(of: "(.)\n", with: "$1\n ", options: .regularExpression, range: nil)
|
||||
} else {
|
||||
string += buildSettingDescription
|
||||
@@ -71,11 +71,11 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl
|
||||
}
|
||||
}
|
||||
}
|
||||
if !presets.isEmpty {
|
||||
if !groups.isEmpty {
|
||||
if !string.isEmpty {
|
||||
string += "\n"
|
||||
}
|
||||
string += "presets:\n \(presets.joined(separator: "\n "))"
|
||||
string += "groups:\n \(groups.joined(separator: "\n "))"
|
||||
}
|
||||
return string
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ extension Target {
|
||||
platformTarget["name"] = platformPrefix + name + platformSuffix
|
||||
|
||||
var settings = platformTarget["settings"] as? JSONDictionary ?? [:]
|
||||
if settings["configs"] != nil || settings["presets"] != nil || settings["base"] != nil {
|
||||
if settings["configs"] != nil || settings["groups"] != nil || settings["base"] != nil {
|
||||
var base = settings["base"] as? JSONDictionary ?? [:]
|
||||
if base["PRODUCT_NAME"] == nil {
|
||||
base["PRODUCT_NAME"] = name
|
||||
|
||||
@@ -42,8 +42,8 @@ public class ProjectGenerator {
|
||||
|
||||
func validateSettings(_ settings: Settings) -> [SpecValidationError.Error] {
|
||||
var errors: [SpecValidationError.Error] = []
|
||||
for preset in settings.presets {
|
||||
if let settings = spec.settingPresets[preset] {
|
||||
for preset in settings.groups {
|
||||
if let settings = spec.settingGroups[preset] {
|
||||
errors += validateSettings(settings)
|
||||
} else {
|
||||
errors.append(.invalidSettingsPreset(preset))
|
||||
@@ -52,7 +52,7 @@ public class ProjectGenerator {
|
||||
return errors
|
||||
}
|
||||
|
||||
for settings in spec.settingPresets.values {
|
||||
for settings in spec.settingGroups.values {
|
||||
errors += validateSettings(settings)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ extension ProjectSpec {
|
||||
public func getBuildSettings(settings: Settings, config: Config) -> BuildSettings {
|
||||
var buildSettings: BuildSettings = [:]
|
||||
|
||||
for preset in settings.presets {
|
||||
let presetSettings = settingPresets[preset]!
|
||||
for preset in settings.groups {
|
||||
let presetSettings = settingGroups[preset]!
|
||||
buildSettings += getBuildSettings(settings: presetSettings, config: config)
|
||||
}
|
||||
|
||||
|
||||
@@ -114,26 +114,26 @@ func specLoadingTests() {
|
||||
let spec = try ProjectSpec(path: fixturePath + "settings_test.yml")
|
||||
let buildSettings: BuildSettings = ["SETTING": "value"]
|
||||
let configSettings: [String: Settings] = ["config1": Settings(buildSettings: ["SETTING1": "value"])]
|
||||
let presets = ["preset1"]
|
||||
let groups = ["preset1"]
|
||||
|
||||
let preset1 = Settings(buildSettings: buildSettings, configSettings: [:], presets: [])
|
||||
let preset2 = Settings(buildSettings: [:], configSettings: configSettings, presets: [])
|
||||
let preset3 = Settings(buildSettings: buildSettings, configSettings: configSettings, presets: [])
|
||||
let preset4 = Settings(buildSettings: buildSettings, configSettings: [:], presets: [])
|
||||
let preset5 = Settings(buildSettings: buildSettings, configSettings: [:], presets: presets)
|
||||
let preset6 = Settings(buildSettings: buildSettings, configSettings: configSettings, presets: presets)
|
||||
let preset7 = Settings(buildSettings: buildSettings, configSettings: ["config1": Settings(buildSettings: buildSettings, presets: presets)])
|
||||
let preset1 = Settings(buildSettings: buildSettings, configSettings: [:], groups: [])
|
||||
let preset2 = Settings(buildSettings: [:], configSettings: configSettings, groups: [])
|
||||
let preset3 = Settings(buildSettings: buildSettings, configSettings: configSettings, groups: [])
|
||||
let preset4 = Settings(buildSettings: buildSettings, configSettings: [:], groups: [])
|
||||
let preset5 = Settings(buildSettings: buildSettings, configSettings: [:], groups: groups)
|
||||
let preset6 = Settings(buildSettings: buildSettings, configSettings: configSettings, groups: groups)
|
||||
let preset7 = Settings(buildSettings: buildSettings, configSettings: ["config1": Settings(buildSettings: buildSettings, groups: groups)])
|
||||
let preset8 = Settings(buildSettings: [:], configSettings: ["config1": Settings(configSettings: configSettings)])
|
||||
|
||||
try expect(spec.settingPresets.count) == 8
|
||||
try expect(spec.settingPresets["preset1"]) == preset1
|
||||
try expect(spec.settingPresets["preset2"]) == preset2
|
||||
try expect(spec.settingPresets["preset3"]) == preset3
|
||||
try expect(spec.settingPresets["preset4"]) == preset4
|
||||
try expect(spec.settingPresets["preset5"]) == preset5
|
||||
try expect(spec.settingPresets["preset6"]) == preset6
|
||||
try expect(spec.settingPresets["preset7"]) == preset7
|
||||
try expect(spec.settingPresets["preset8"]) == preset8
|
||||
try expect(spec.settingGroups.count) == 8
|
||||
try expect(spec.settingGroups["preset1"]) == preset1
|
||||
try expect(spec.settingGroups["preset2"]) == preset2
|
||||
try expect(spec.settingGroups["preset3"]) == preset3
|
||||
try expect(spec.settingGroups["preset4"]) == preset4
|
||||
try expect(spec.settingGroups["preset5"]) == preset5
|
||||
try expect(spec.settingGroups["preset6"]) == preset6
|
||||
try expect(spec.settingGroups["preset7"]) == preset7
|
||||
try expect(spec.settingGroups["preset8"]) == preset8
|
||||
}
|
||||
|
||||
$0.it("parses run scripts") {
|
||||
|
||||
+12
-12
@@ -10,9 +10,9 @@ Required properties are marked 🔵 and optional properties with ⚪️.
|
||||
- [Project](#project)
|
||||
- [Options](#options)
|
||||
- [Configs](#configs)
|
||||
- [Setting Presets](#setting-presets)
|
||||
- [Setting Groups](#setting-groups)
|
||||
- [Settings](#settings)
|
||||
- [Target](#target)
|
||||
- [Target](#target)
|
||||
- [Product Type](#product-type)
|
||||
- [Platform](#platform)
|
||||
- [Sources](#sources)
|
||||
@@ -28,7 +28,7 @@ Required properties are marked 🔵 and optional properties with ⚪️.
|
||||
- ⚪️ **options**: [Options](#options) - Various options to override default behaviour
|
||||
- ⚪️ **configs**: [Configs](#configs) - Project build configurations. Defaults to `Debug` and `Release` configs
|
||||
- ⚪️ **settings**: [Settings](#settings) - Project specific settings. Default base and config type settings will be applied first before any settings defined here
|
||||
- ⚪️ **settingPresets**: [Setting Presets](#setting-presets) - Setting presets mapped by name
|
||||
- ⚪️ **settingGroups**: [Setting Groups](#setting-groups) - Setting groups mapped by name
|
||||
- ⚪️ **targets**: [[Target](#target)] - The list of targets in the project
|
||||
|
||||
### Options
|
||||
@@ -45,29 +45,29 @@ configs:
|
||||
If no configs are specified, default `Debug` and `Release` configs will be created automatically.
|
||||
|
||||
|
||||
### Setting Presets
|
||||
Setting presets are named groups of build settings that can be reused elsewhere. Each preset is a [Settings](#settings) schema, so can include other presets
|
||||
### Setting Groups
|
||||
Setting groups are named groups of build settings that can be reused elsewhere. Each preset is a [Settings](#settings) schema, so can include other groups
|
||||
|
||||
```yaml
|
||||
settingPresets:
|
||||
settingGroups:
|
||||
preset1:
|
||||
BUILD_SETTING: value
|
||||
preset2:
|
||||
base:
|
||||
BUILD_SETTING: value
|
||||
presets:
|
||||
groups:
|
||||
- preset
|
||||
preset3:
|
||||
configs:
|
||||
debug:
|
||||
presets:
|
||||
groups:
|
||||
- preset
|
||||
```
|
||||
|
||||
## Settings
|
||||
Settings can either be a simple map of build settings `[String: String]`, or can be more advanced with the following properties:
|
||||
|
||||
- ⚪️ **presets**: `[String]` - List of presets to include and merge
|
||||
- ⚪️ **groups**: `[String]` - List of setting groups to include and merge
|
||||
- ⚪️ **configs**: [String: [Settings](#settings)] - Mapping of config name to a settings spec. These settings will only be applied for that config
|
||||
- ⚪️ **base**: `[String: String]` - Used to specify default settings that apply to any config
|
||||
|
||||
@@ -84,11 +84,11 @@ settings:
|
||||
configs:
|
||||
my_config:
|
||||
BUILD_SETTING_2: value 2
|
||||
presets:
|
||||
groups:
|
||||
- my_settings
|
||||
```
|
||||
|
||||
Settings are merged in the following order: presets, configs, base.
|
||||
Settings are merged in the following order: groups, configs, base.
|
||||
|
||||
## Target
|
||||
|
||||
@@ -152,7 +152,7 @@ settings:
|
||||
INFOPLIST_FILE: MyApp/Info.plist
|
||||
PRODUCT_BUNDLE_IDENTIFIER: com.myapp
|
||||
MY_SETTING: platform $platform
|
||||
presets:
|
||||
groups:
|
||||
- $platform
|
||||
```
|
||||
The above will generate 2 targets named `MyFramework_iOS` and `MyFramework_tvOS`, with all the relevant platform build settings. They will both have a `PRODUCT_NAME` of `MyFramework`
|
||||
|
||||
Reference in New Issue
Block a user