Skip to content

Commit

Permalink
Merge pull request #45 from yonaskolb/project_attributes
Browse files Browse the repository at this point in the history
Project attributes
  • Loading branch information
yonaskolb authored Aug 30, 2017
2 parents b6ac25d + ea41e6b commit ffd07ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/ProjectSpec/ProjectSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -30,14 +31,15 @@ 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
self.settings = settings
self.settingGroups = settingGroups
self.schemes = schemes
self.options = options
self.attributes = attributes
}

public func getTarget(_ targetName: String) -> Target? {
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class PBXProjGenerator {

let spec: ProjectSpec
let basePath: Path
let currentXcodeVersion = "0830"

var fileReferencesByPath: [Path: String] = [:]
var groupsByPath: [Path: PBXGroup] = [:]
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffd07ac

Please sign in to comment.