set project attributes

This commit is contained in:
Yonas Kolb
2017-08-30 17:06:41 +02:00
parent 183630159e
commit ea41e6bbc6
3 changed files with 15 additions and 2 deletions
+4 -1
View File
@@ -21,6 +21,7 @@ public struct ProjectSpec {
public var configs: [Config]
public var schemes: [Scheme]
public var options: Options
public var attributes: [String: Any]
public struct Options {
public var carthageBuildPath: String?
@@ -30,7 +31,7 @@ public struct ProjectSpec {
}
}
public init(name: String, configs: [Config] = [], targets: [Target] = [], settings: Settings = .empty, settingGroups: [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(), attributes: [String: Any] = [:]) {
self.name = name
self.targets = targets
self.configs = configs
@@ -38,6 +39,7 @@ public struct ProjectSpec {
self.settingGroups = settingGroups
self.schemes = schemes
self.options = options
self.attributes = attributes
}
public func getTarget(_ targetName: String) -> Target? {
@@ -79,6 +81,7 @@ extension ProjectSpec: JSONObjectConvertible {
self.configs = configs.map { Config(name: $0, type: ConfigType(rawValue: $1)) }
targets = try Target.decodeTargets(jsonDictionary: jsonDictionary)
schemes = try jsonDictionary.json(atKeyPath: "schemes")
attributes = jsonDictionary.json(atKeyPath: "attributes") ?? [:]
if jsonDictionary["options"] != nil {
options = try jsonDictionary.json(atKeyPath: "options")
} else {
+10 -1
View File
@@ -18,6 +18,7 @@ public class PBXProjGenerator {
let spec: ProjectSpec
let basePath: Path
let currentXcodeVersion = "0830"
var fileReferencesByPath: [Path: String] = [:]
var groupsByPath: [Path: PBXGroup] = [:]
@@ -133,7 +134,15 @@ public class PBXProjGenerator {
addObject(mainGroup)
let knownRegions: [String] = ["en", "Base"]
let root = PBXProject(reference: project.rootObject, buildConfigurationList: buildConfigList.reference, compatibilityVersion: "Xcode 3.2", mainGroup: mainGroup.reference, developmentRegion: "English", knownRegions: knownRegions, targets: targets.referenceList)
let projectAttributes: [String: Any] = spec.attributes.isEmpty ? ["LastUpgradeCheck": currentXcodeVersion] : spec.attributes
let root = PBXProject(reference: project.rootObject,
buildConfigurationList: buildConfigList.reference,
compatibilityVersion: "Xcode 3.2",
mainGroup: mainGroup.reference,
developmentRegion: "English",
knownRegions: knownRegions,
targets: targets.referenceList,
attributes: projectAttributes)
project.projects.append(root)
return project
+1
View File
@@ -27,6 +27,7 @@ Required properties are marked 🔵 and optional properties with ⚪️.
- 🔵 **name**: `String` - Name of the generated project
- ⚪️ **include**: `[String]` - The paths to other specs. They will be merged in order and then the current spec will be merged on top
- ⚪️ **options**: [Options](#options) - Various options to override default behaviour
- ⚪️ **attributes**: `map` - The PBXProject attributes. This is for advanced use. Defaults to ``{"LastUpgradeCheck": "0830"}``
- ⚪️ **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
- ⚪️ **settingGroups**: [Setting Groups](#setting-groups) - Setting groups mapped by name