Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to xcodeproj 0.1.1 #33

Merged
merged 4 commits into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Fixtures/TestProject/GeneratedProject.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
BF3862341101 /* MyFramework.framework in CopyFiles */,
BF3862341101 /* MyFramework.framework */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -71,15 +71,15 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BF5986511201,
BF5986511201 /* TestProject.app */,
);
runOnlyForDeploymentPostprocessing = 0;
};
FBP652326301 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BF2753556301,
BF2753556301 /* MyFramework.framework */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -155,7 +155,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
BF3515549501,
BF3515549501 /* MyFramework.h */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -266,7 +266,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF3154421201,
BF3154421201 /* Assets.xcassets */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -308,24 +308,24 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF9001417701 /* TestProjectTests.swift in Sources */,
BF9001417701 /* TestProjectTests.swift */,
);
runOnlyForDeploymentPostprocessing = 0;
};
SBP299349701 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF9155249601 /* FrameworkFile.swift in Sources */,
BF9155249601 /* FrameworkFile.swift */,
);
runOnlyForDeploymentPostprocessing = 0;
};
SBP652326301 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BF1073850101 /* AppDelegate.swift in Sources */,
BF1744565901 /* ViewController.swift in Sources */,
BF1073850101 /* AppDelegate.swift */,
BF1744565901 /* ViewController.swift */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions Package.pins
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
"package": "Yams",
"reason": null,
"repositoryURL": "https://github.com/jpsim/Yams.git",
"version": "0.3.4"
"version": "0.3.5"
},
{
"package": "xcodeproj",
"reason": null,
"repositoryURL": "https://github.com/carambalabs/xcodeproj.git",
"version": "0.0.9"
"version": "0.1.1"
}
],
"version": 1
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ let package = Package(
.Package(url: "https://github.com/yonaskolb/JSONUtilities.git", majorVersion: 3, minor: 3),
.Package(url: "https://github.com/kylef/Spectre.git", majorVersion: 0, minor: 7),
.Package(url: "https://github.com/onevcat/Rainbow", majorVersion: 2),
.Package(url: "https://github.com/carambalabs/xcodeproj.git", majorVersion: 0, minor: 0),
.Package(url: "https://github.com/carambalabs/xcodeproj.git", majorVersion: 0, minor: 1),
]
)
28 changes: 11 additions & 17 deletions Sources/ProjectSpec/ProjectExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import xcodeproj
import PathKit

extension Array where Element: ProjectElement {
extension Array where Element: Referenceable {

public var referenceList: [String] {
return map { $0.reference }
Expand All @@ -21,28 +21,22 @@ extension Array where Element: ProjectElement {
}
}

extension BuildSettings: CustomStringConvertible {
extension Dictionary where Key == String, Value: Any {

public init() {
dictionary = [:]
public func merged(_ dictionary: [Key: Value]) -> [Key: Value] {
var mergedDictionary = self
mergedDictionary.merge(dictionary)
return mergedDictionary
}

public static let empty = BuildSettings()

public func merged(_ buildSettings: BuildSettings) -> BuildSettings {
var mergedSettings = self
mergedSettings.merge(buildSettings)
return mergedSettings
}

public mutating func merge(_ buildSettings: BuildSettings) {
for (key, value) in buildSettings.dictionary {
dictionary[key] = value
public mutating func merge(_ dictionary: [Key: Value]) {
for (key, value) in dictionary {
self[key] = value
}
}

public var description: String {
return dictionary.map { "\($0) = \($1)" }.joined(separator: "\n")
public func equals(_ dictionary: BuildSettings) -> Bool {
return NSDictionary(dictionary: self).isEqual(to: dictionary)
}
}

Expand Down
25 changes: 10 additions & 15 deletions Sources/ProjectSpec/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
import Foundation
import JSONUtilities
import xcodeproj

import PathKit
import Yams
public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertible {

public let buildSettings: BuildSettings
public let configSettings: [String: Settings]
public let presets: [String]

public init(buildSettings: BuildSettings = .empty, configSettings: [String: Settings] = [:], presets: [String] = []) {
public init(buildSettings: BuildSettings = [:], configSettings: [String: Settings] = [:], presets: [String] = []) {
self.buildSettings = buildSettings
self.configSettings = configSettings
self.presets = presets
}

public init(dictionary: [String: Any]) {
buildSettings = BuildSettings(dictionary: dictionary)
buildSettings = dictionary
configSettings = [:]
presets = []
}
Expand All @@ -33,25 +34,26 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl
public init(jsonDictionary: JSONDictionary) throws {
if jsonDictionary["configs"] != nil || jsonDictionary["presets"] != nil || jsonDictionary["base"] != nil {
presets = jsonDictionary.json(atKeyPath: "presets") ?? []
buildSettings = jsonDictionary.json(atKeyPath: "base") ?? [:]
let buildSettingsDictionary: JSONDictionary = jsonDictionary.json(atKeyPath: "base") ?? [:]
buildSettings = buildSettingsDictionary
configSettings = jsonDictionary.json(atKeyPath: "configs") ?? [:]
} else {
buildSettings = BuildSettings(dictionary: jsonDictionary)
buildSettings = jsonDictionary
configSettings = [:]
presets = []
}
}

public static func ==(lhs: Settings, rhs: Settings) -> Bool {
return lhs.buildSettings == rhs.buildSettings &&
return NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) &&
lhs.configSettings == rhs.configSettings &&
lhs.presets == rhs.presets
}

public var description: String {
var string: String = ""
if !buildSettings.dictionary.isEmpty {
let buildSettingDescription = buildSettings.description
if !buildSettings.isEmpty {
let buildSettingDescription = buildSettings.map { "\($0) = \($1)" }.joined(separator: "\n")
if !configSettings.isEmpty || !presets.isEmpty {
string += "base:\n " + buildSettingDescription.replacingOccurrences(of: "(.)\n", with: "$1\n ", options: .regularExpression, range: nil)
} else {
Expand Down Expand Up @@ -87,10 +89,3 @@ extension Settings: ExpressibleByDictionaryLiteral {
self.init(dictionary: dictionary)
}
}

extension BuildSettings: JSONObjectConvertible {

public init(jsonDictionary: JSONDictionary) throws {
self.init(dictionary: jsonDictionary)
}
}
Loading