mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2026-03-18 20:02:25 +00:00
Define default property values
This commit is contained in:
@@ -2,6 +2,8 @@ import Foundation
|
||||
import JSONUtilities
|
||||
|
||||
public struct BuildScript: Equatable {
|
||||
public static let runOnlyWhenInstallingDefault = false
|
||||
public static let showEnvVarsDefault = true
|
||||
|
||||
public var script: ScriptType
|
||||
public var name: String?
|
||||
@@ -26,8 +28,8 @@ public struct BuildScript: Equatable {
|
||||
inputFileLists: [String] = [],
|
||||
outputFileLists: [String] = [],
|
||||
shell: String? = nil,
|
||||
runOnlyWhenInstalling: Bool = false,
|
||||
showEnvVars: Bool = true
|
||||
runOnlyWhenInstalling: Bool = runOnlyWhenInstallingDefault,
|
||||
showEnvVars: Bool = showEnvVarsDefault
|
||||
) {
|
||||
self.script = script
|
||||
self.name = name
|
||||
@@ -57,8 +59,8 @@ extension BuildScript: JSONObjectConvertible {
|
||||
script = .path(path)
|
||||
}
|
||||
shell = jsonDictionary.json(atKeyPath: "shell")
|
||||
runOnlyWhenInstalling = jsonDictionary.json(atKeyPath: "runOnlyWhenInstalling") ?? false
|
||||
showEnvVars = jsonDictionary.json(atKeyPath: "showEnvVars") ?? true
|
||||
runOnlyWhenInstalling = jsonDictionary.json(atKeyPath: "runOnlyWhenInstalling") ?? BuildScript.runOnlyWhenInstallingDefault
|
||||
showEnvVars = jsonDictionary.json(atKeyPath: "showEnvVars") ?? BuildScript.showEnvVarsDefault
|
||||
}
|
||||
}
|
||||
extension BuildScript: JSONEncodable {
|
||||
@@ -73,7 +75,7 @@ extension BuildScript: JSONEncodable {
|
||||
"shell": shell
|
||||
]
|
||||
|
||||
if !showEnvVars {
|
||||
if showEnvVars != BuildScript.showEnvVarsDefault {
|
||||
dict["showEnvVars"] = showEnvVars
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,18 @@ import Foundation
|
||||
import JSONUtilities
|
||||
|
||||
public struct Dependency: Equatable {
|
||||
public static let removeHeadersDefault = true
|
||||
public static let implicitDefault = false
|
||||
public static let weakLinkDefault = false
|
||||
|
||||
public var type: DependencyType
|
||||
public var reference: String
|
||||
public var embed: Bool?
|
||||
public var codeSign: Bool?
|
||||
public var removeHeaders: Bool = true
|
||||
public var removeHeaders: Bool = removeHeadersDefault
|
||||
public var link: Bool?
|
||||
public var implicit: Bool = false
|
||||
public var weakLink: Bool = false
|
||||
public var implicit: Bool = implicitDefault
|
||||
public var weakLink: Bool = weakLinkDefault
|
||||
|
||||
public init(
|
||||
type: DependencyType,
|
||||
@@ -18,8 +21,8 @@ public struct Dependency: Equatable {
|
||||
embed: Bool? = nil,
|
||||
codeSign: Bool? = nil,
|
||||
link: Bool? = nil,
|
||||
implicit: Bool = false,
|
||||
weakLink: Bool = false
|
||||
implicit: Bool = implicitDefault,
|
||||
weakLink: Bool = weakLinkDefault
|
||||
) {
|
||||
self.type = type
|
||||
self.reference = reference
|
||||
@@ -89,13 +92,13 @@ extension Dependency: JSONEncodable {
|
||||
"link": link
|
||||
]
|
||||
|
||||
if !removeHeaders {
|
||||
if removeHeaders != Dependency.removeHeadersDefault {
|
||||
dict["removeHeaders"] = removeHeaders
|
||||
}
|
||||
if implicit {
|
||||
if implicit != Dependency.implicitDefault {
|
||||
dict["implicit"] = implicit
|
||||
}
|
||||
if weakLink {
|
||||
if weakLink != Dependency.weakLinkDefault {
|
||||
dict["weak"] = weakLink
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public struct Build: Equatable {
|
||||
public static let parallelizeBuildDefault = true
|
||||
public static let buildImplicitDependenciesDefault = true
|
||||
|
||||
public var targets: [BuildTarget]
|
||||
public var parallelizeBuild: Bool
|
||||
public var buildImplicitDependencies: Bool
|
||||
@@ -51,8 +54,8 @@ public struct Scheme: Equatable {
|
||||
public var postActions: [ExecutionAction]
|
||||
public init(
|
||||
targets: [BuildTarget],
|
||||
parallelizeBuild: Bool = true,
|
||||
buildImplicitDependencies: Bool = true,
|
||||
parallelizeBuild: Bool = parallelizeBuildDefault,
|
||||
buildImplicitDependencies: Bool = buildImplicitDependenciesDefault,
|
||||
preActions: [ExecutionAction] = [],
|
||||
postActions: [ExecutionAction] = []
|
||||
) {
|
||||
@@ -86,6 +89,8 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public struct Test: BuildAction {
|
||||
public static let gatherCoverageDataDefault = false
|
||||
|
||||
public var config: String?
|
||||
public var gatherCoverageData: Bool
|
||||
public var commandLineArguments: [String: Bool]
|
||||
@@ -95,14 +100,17 @@ public struct Scheme: Equatable {
|
||||
public var environmentVariables: [XCScheme.EnvironmentVariable]
|
||||
|
||||
public struct TestTarget: Equatable, ExpressibleByStringLiteral {
|
||||
public static let randomExecutionOrderDefault = false
|
||||
public static let parallelizableDefault = false
|
||||
|
||||
public let name: String
|
||||
public var randomExecutionOrder: Bool
|
||||
public var parallelizable: Bool
|
||||
|
||||
public init(
|
||||
name: String,
|
||||
randomExecutionOrder: Bool = false,
|
||||
parallelizable: Bool = false
|
||||
randomExecutionOrder: Bool = randomExecutionOrderDefault,
|
||||
parallelizable: Bool = parallelizableDefault
|
||||
) {
|
||||
self.name = name
|
||||
self.randomExecutionOrder = randomExecutionOrder
|
||||
@@ -118,7 +126,7 @@ public struct Scheme: Equatable {
|
||||
|
||||
public init(
|
||||
config: String,
|
||||
gatherCoverageData: Bool = false,
|
||||
gatherCoverageData: Bool = gatherCoverageDataDefault,
|
||||
randomExecutionOrder: Bool = false,
|
||||
parallelizable: Bool = false,
|
||||
commandLineArguments: [String: Bool] = [:],
|
||||
@@ -174,6 +182,8 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public struct Archive: BuildAction {
|
||||
public static let revealArchiveInOrganizerDefault = true
|
||||
|
||||
public var config: String?
|
||||
public var customArchiveName: String?
|
||||
public var revealArchiveInOrganizer: Bool
|
||||
@@ -182,7 +192,7 @@ public struct Scheme: Equatable {
|
||||
public init(
|
||||
config: String,
|
||||
customArchiveName: String? = nil,
|
||||
revealArchiveInOrganizer: Bool = true,
|
||||
revealArchiveInOrganizer: Bool = revealArchiveInOrganizerDefault,
|
||||
preActions: [ExecutionAction] = [],
|
||||
postActions: [ExecutionAction] = []
|
||||
) {
|
||||
@@ -255,7 +265,7 @@ extension Scheme.Test: JSONObjectConvertible {
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
config = jsonDictionary.json(atKeyPath: "config")
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? false
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? Scheme.Test.gatherCoverageDataDefault
|
||||
commandLineArguments = jsonDictionary.json(atKeyPath: "commandLineArguments") ?? [:]
|
||||
if let targets = jsonDictionary["targets"] as? [Any] {
|
||||
self.targets = try targets.compactMap { target in
|
||||
@@ -294,8 +304,8 @@ extension Scheme.Test.TestTarget: JSONObjectConvertible {
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
name = try jsonDictionary.json(atKeyPath: "name")
|
||||
randomExecutionOrder = jsonDictionary.json(atKeyPath: "randomExecutionOrder") ?? false
|
||||
parallelizable = jsonDictionary.json(atKeyPath: "parallelizable") ?? false
|
||||
randomExecutionOrder = jsonDictionary.json(atKeyPath: "randomExecutionOrder") ?? Scheme.Test.TestTarget.randomExecutionOrderDefault
|
||||
parallelizable = jsonDictionary.json(atKeyPath: "parallelizable") ?? Scheme.Test.TestTarget.parallelizableDefault
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,11 +319,11 @@ extension Scheme.Test.TestTarget: JSONEncodable {
|
||||
"name": name
|
||||
]
|
||||
|
||||
if randomExecutionOrder {
|
||||
dict["randomExecutionOrder"] = true
|
||||
if randomExecutionOrder != Scheme.Test.TestTarget.randomExecutionOrderDefault {
|
||||
dict["randomExecutionOrder"] = randomExecutionOrder
|
||||
}
|
||||
if parallelizable {
|
||||
dict["parallelizable"] = true
|
||||
if parallelizable != Scheme.Test.TestTarget.parallelizableDefault {
|
||||
dict["parallelizable"] = parallelizable
|
||||
}
|
||||
|
||||
return dict
|
||||
@@ -363,7 +373,7 @@ extension Scheme.Archive: JSONObjectConvertible {
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
config = jsonDictionary.json(atKeyPath: "config")
|
||||
customArchiveName = jsonDictionary.json(atKeyPath: "customArchiveName")
|
||||
revealArchiveInOrganizer = jsonDictionary.json(atKeyPath: "revealArchiveInOrganizer") ?? true
|
||||
revealArchiveInOrganizer = jsonDictionary.json(atKeyPath: "revealArchiveInOrganizer") ?? Scheme.Archive.revealArchiveInOrganizerDefault
|
||||
preActions = jsonDictionary.json(atKeyPath: "preActions") ?? []
|
||||
postActions = jsonDictionary.json(atKeyPath: "postActions") ?? []
|
||||
}
|
||||
@@ -378,7 +388,7 @@ extension Scheme.Archive: JSONEncodable {
|
||||
"customArchiveName": customArchiveName,
|
||||
]
|
||||
|
||||
if !revealArchiveInOrganizer {
|
||||
if revealArchiveInOrganizer != Scheme.Archive.revealArchiveInOrganizerDefault {
|
||||
dict["revealArchiveInOrganizer"] = revealArchiveInOrganizer
|
||||
}
|
||||
|
||||
@@ -439,8 +449,8 @@ extension Scheme.Build: JSONObjectConvertible {
|
||||
self.targets = targets.sorted { $0.target < $1.target }
|
||||
preActions = try jsonDictionary.json(atKeyPath: "preActions")?.map(Scheme.ExecutionAction.init) ?? []
|
||||
postActions = try jsonDictionary.json(atKeyPath: "postActions")?.map(Scheme.ExecutionAction.init) ?? []
|
||||
parallelizeBuild = jsonDictionary.json(atKeyPath: "parallelizeBuild") ?? true
|
||||
buildImplicitDependencies = jsonDictionary.json(atKeyPath: "buildImplicitDependencies") ?? true
|
||||
parallelizeBuild = jsonDictionary.json(atKeyPath: "parallelizeBuild") ?? Scheme.Build.parallelizeBuildDefault
|
||||
buildImplicitDependencies = jsonDictionary.json(atKeyPath: "buildImplicitDependencies") ?? Scheme.Build.buildImplicitDependenciesDefault
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,10 +464,10 @@ extension Scheme.Build: JSONEncodable {
|
||||
"postActions": postActions.map { $0.toJSONValue() },
|
||||
]
|
||||
|
||||
if !parallelizeBuild {
|
||||
if parallelizeBuild != Scheme.Build.parallelizeBuildDefault {
|
||||
dict["parallelizeBuild"] = parallelizeBuild
|
||||
}
|
||||
if !buildImplicitDependencies {
|
||||
if buildImplicitDependencies != Scheme.Build.buildImplicitDependenciesDefault {
|
||||
dict["buildImplicitDependencies"] = buildImplicitDependencies
|
||||
}
|
||||
|
||||
@@ -498,6 +508,7 @@ extension BuildType: JSONEncodable {
|
||||
}
|
||||
|
||||
extension XCScheme.EnvironmentVariable: JSONObjectConvertible {
|
||||
public static let enabledDefault = true
|
||||
|
||||
private static func parseValue(_ value: Any) -> String {
|
||||
if let bool = value as? Bool {
|
||||
@@ -517,7 +528,7 @@ extension XCScheme.EnvironmentVariable: JSONObjectConvertible {
|
||||
value = try jsonDictionary.json(atKeyPath: "value")
|
||||
}
|
||||
let variable: String = try jsonDictionary.json(atKeyPath: "variable")
|
||||
let enabled: Bool = jsonDictionary.json(atKeyPath: "isEnabled") ?? true
|
||||
let enabled: Bool = jsonDictionary.json(atKeyPath: "isEnabled") ?? XCScheme.EnvironmentVariable.enabledDefault
|
||||
self.init(variable: variable, value: value, enabled: enabled)
|
||||
}
|
||||
|
||||
@@ -536,10 +547,15 @@ extension XCScheme.EnvironmentVariable: JSONObjectConvertible {
|
||||
|
||||
extension XCScheme.EnvironmentVariable: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
var dict: [String: Any] = [
|
||||
"variable": variable,
|
||||
"value": value,
|
||||
"isEnabled": enabled
|
||||
"value": value
|
||||
]
|
||||
|
||||
if enabled != XCScheme.EnvironmentVariable.enabledDefault {
|
||||
dict["isEnabled"] = enabled
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ import Foundation
|
||||
import JSONUtilities
|
||||
|
||||
public struct SpecOptions: Equatable {
|
||||
public static let settingPresetsDefault = SettingPresets.all
|
||||
public static let createIntermediateGroupsDefault = false
|
||||
public static let transitivelyLinkDependenciesDefault = false
|
||||
public static let groupSortPositionDefault = GroupSortPosition.bottom
|
||||
public static let generateEmptyDirectoriesDefault = false
|
||||
public static let findCarthageFrameworksDefault = false
|
||||
|
||||
public var minimumXcodeGenVersion: Version?
|
||||
public var carthageBuildPath: String?
|
||||
@@ -62,9 +68,9 @@ public struct SpecOptions: Equatable {
|
||||
minimumXcodeGenVersion: Version? = nil,
|
||||
carthageBuildPath: String? = nil,
|
||||
carthageExecutablePath: String? = nil,
|
||||
createIntermediateGroups: Bool = false,
|
||||
createIntermediateGroups: Bool = createIntermediateGroupsDefault,
|
||||
bundleIdPrefix: String? = nil,
|
||||
settingPresets: SettingPresets = .all,
|
||||
settingPresets: SettingPresets = settingPresetsDefault,
|
||||
developmentLanguage: String? = nil,
|
||||
indentWidth: UInt? = nil,
|
||||
tabWidth: UInt? = nil,
|
||||
@@ -73,10 +79,10 @@ public struct SpecOptions: Equatable {
|
||||
deploymentTarget: DeploymentTarget = .init(),
|
||||
disabledValidations: [ValidationType] = [],
|
||||
defaultConfig: String? = nil,
|
||||
transitivelyLinkDependencies: Bool = false,
|
||||
groupSortPosition: GroupSortPosition = .bottom,
|
||||
generateEmptyDirectories: Bool = false,
|
||||
findCarthageFrameworks: Bool = false
|
||||
transitivelyLinkDependencies: Bool = transitivelyLinkDependenciesDefault,
|
||||
groupSortPosition: GroupSortPosition = groupSortPositionDefault,
|
||||
generateEmptyDirectories: Bool = generateEmptyDirectoriesDefault,
|
||||
findCarthageFrameworks: Bool = findCarthageFrameworksDefault
|
||||
) {
|
||||
self.minimumXcodeGenVersion = minimumXcodeGenVersion
|
||||
self.carthageBuildPath = carthageBuildPath
|
||||
@@ -109,8 +115,8 @@ extension SpecOptions: JSONObjectConvertible {
|
||||
carthageBuildPath = jsonDictionary.json(atKeyPath: "carthageBuildPath")
|
||||
carthageExecutablePath = jsonDictionary.json(atKeyPath: "carthageExecutablePath")
|
||||
bundleIdPrefix = jsonDictionary.json(atKeyPath: "bundleIdPrefix")
|
||||
settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? .all
|
||||
createIntermediateGroups = jsonDictionary.json(atKeyPath: "createIntermediateGroups") ?? false
|
||||
settingPresets = jsonDictionary.json(atKeyPath: "settingPresets") ?? SpecOptions.settingPresetsDefault
|
||||
createIntermediateGroups = jsonDictionary.json(atKeyPath: "createIntermediateGroups") ?? SpecOptions.createIntermediateGroupsDefault
|
||||
developmentLanguage = jsonDictionary.json(atKeyPath: "developmentLanguage")
|
||||
usesTabs = jsonDictionary.json(atKeyPath: "usesTabs")
|
||||
xcodeVersion = jsonDictionary.json(atKeyPath: "xcodeVersion")
|
||||
@@ -119,10 +125,10 @@ extension SpecOptions: JSONObjectConvertible {
|
||||
deploymentTarget = jsonDictionary.json(atKeyPath: "deploymentTarget") ?? DeploymentTarget()
|
||||
disabledValidations = jsonDictionary.json(atKeyPath: "disabledValidations") ?? []
|
||||
defaultConfig = jsonDictionary.json(atKeyPath: "defaultConfig")
|
||||
transitivelyLinkDependencies = jsonDictionary.json(atKeyPath: "transitivelyLinkDependencies") ?? false
|
||||
groupSortPosition = jsonDictionary.json(atKeyPath: "groupSortPosition") ?? .bottom
|
||||
generateEmptyDirectories = jsonDictionary.json(atKeyPath: "generateEmptyDirectories") ?? false
|
||||
findCarthageFrameworks = jsonDictionary.json(atKeyPath: "findCarthageFrameworks") ?? false
|
||||
transitivelyLinkDependencies = jsonDictionary.json(atKeyPath: "transitivelyLinkDependencies") ?? SpecOptions.transitivelyLinkDependenciesDefault
|
||||
groupSortPosition = jsonDictionary.json(atKeyPath: "groupSortPosition") ?? SpecOptions.groupSortPositionDefault
|
||||
generateEmptyDirectories = jsonDictionary.json(atKeyPath: "generateEmptyDirectories") ?? SpecOptions.generateEmptyDirectoriesDefault
|
||||
findCarthageFrameworks = jsonDictionary.json(atKeyPath: "findCarthageFrameworks") ?? SpecOptions.findCarthageFrameworksDefault
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,16 +151,16 @@ extension SpecOptions: JSONEncodable {
|
||||
"defaultConfig": defaultConfig,
|
||||
]
|
||||
|
||||
if settingPresets != .all {
|
||||
if settingPresets != SpecOptions.settingPresetsDefault {
|
||||
dict["settingPresets"] = settingPresets.rawValue
|
||||
}
|
||||
if createIntermediateGroups {
|
||||
if createIntermediateGroups != SpecOptions.createIntermediateGroupsDefault {
|
||||
dict["createIntermediateGroups"] = createIntermediateGroups
|
||||
}
|
||||
if generateEmptyDirectories {
|
||||
if generateEmptyDirectories != SpecOptions.generateEmptyDirectoriesDefault {
|
||||
dict["generateEmptyDirectories"] = generateEmptyDirectories
|
||||
}
|
||||
if findCarthageFrameworks {
|
||||
if findCarthageFrameworks != SpecOptions.findCarthageFrameworksDefault {
|
||||
dict["findCarthageFrameworks"] = findCarthageFrameworks
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import JSONUtilities
|
||||
import xcodeproj
|
||||
|
||||
public struct LegacyTarget: Equatable {
|
||||
public static let passSettingsDefault = false
|
||||
|
||||
public var toolPath: String
|
||||
public var arguments: String?
|
||||
public var passSettings: Bool
|
||||
@@ -10,7 +12,7 @@ public struct LegacyTarget: Equatable {
|
||||
|
||||
public init(
|
||||
toolPath: String,
|
||||
passSettings: Bool = false,
|
||||
passSettings: Bool = passSettingsDefault,
|
||||
arguments: String? = nil,
|
||||
workingDirectory: String? = nil
|
||||
) {
|
||||
@@ -267,19 +269,24 @@ extension LegacyTarget: JSONObjectConvertible {
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
toolPath = try jsonDictionary.json(atKeyPath: "toolPath")
|
||||
arguments = jsonDictionary.json(atKeyPath: "arguments")
|
||||
passSettings = jsonDictionary.json(atKeyPath: "passSettings") ?? false
|
||||
passSettings = jsonDictionary.json(atKeyPath: "passSettings") ?? LegacyTarget.passSettingsDefault
|
||||
workingDirectory = jsonDictionary.json(atKeyPath: "workingDirectory")
|
||||
}
|
||||
}
|
||||
|
||||
extension LegacyTarget: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
var dict: [String: Any?] = [
|
||||
"toolPath": toolPath,
|
||||
"passSettings": passSettings,
|
||||
"arguments": arguments,
|
||||
"workingDirectory": workingDirectory,
|
||||
] as [String: Any?]
|
||||
]
|
||||
|
||||
if passSettings != LegacyTarget.passSettingsDefault {
|
||||
dict["passSettings"] = passSettings
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ import JSONUtilities
|
||||
import xcodeproj
|
||||
|
||||
public struct TargetScheme: Equatable {
|
||||
public static let gatherCoverageDataDefault = false
|
||||
|
||||
public var testTargets: [Scheme.Test.TestTarget]
|
||||
public var configVariants: [String]
|
||||
public var gatherCoverageData: Bool
|
||||
@@ -14,7 +16,7 @@ public struct TargetScheme: Equatable {
|
||||
public init(
|
||||
testTargets: [Scheme.Test.TestTarget] = [],
|
||||
configVariants: [String] = [],
|
||||
gatherCoverageData: Bool = false,
|
||||
gatherCoverageData: Bool = gatherCoverageDataDefault,
|
||||
commandLineArguments: [String: Bool] = [:],
|
||||
environmentVariables: [XCScheme.EnvironmentVariable] = [],
|
||||
preActions: [Scheme.ExecutionAction] = [],
|
||||
@@ -47,7 +49,7 @@ extension TargetScheme: JSONObjectConvertible {
|
||||
testTargets = []
|
||||
}
|
||||
configVariants = jsonDictionary.json(atKeyPath: "configVariants") ?? []
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? false
|
||||
gatherCoverageData = jsonDictionary.json(atKeyPath: "gatherCoverageData") ?? TargetScheme.gatherCoverageDataDefault
|
||||
commandLineArguments = jsonDictionary.json(atKeyPath: "commandLineArguments") ?? [:]
|
||||
environmentVariables = try XCScheme.EnvironmentVariable.parseAll(jsonDictionary: jsonDictionary)
|
||||
preActions = jsonDictionary.json(atKeyPath: "preActions") ?? []
|
||||
@@ -57,8 +59,7 @@ extension TargetScheme: JSONObjectConvertible {
|
||||
|
||||
extension TargetScheme: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
"gatherCoverageData": gatherCoverageData,
|
||||
var dict: [String: Any] = [
|
||||
"configVariants": configVariants,
|
||||
"commandLineArguments": commandLineArguments,
|
||||
"testTargets": testTargets.map { $0.toJSONValue() },
|
||||
@@ -66,5 +67,11 @@ extension TargetScheme: JSONEncodable {
|
||||
"preActions": preActions.map { $0.toJSONValue() },
|
||||
"postActions": postActions.map { $0.toJSONValue() },
|
||||
]
|
||||
|
||||
if gatherCoverageData != TargetScheme.gatherCoverageDataDefault {
|
||||
dict["gatherCoverageData"] = gatherCoverageData
|
||||
}
|
||||
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import PathKit
|
||||
import xcodeproj
|
||||
|
||||
public struct TargetSource: Equatable {
|
||||
public static let optionalDefault = false
|
||||
|
||||
public var path: String
|
||||
public var name: String?
|
||||
@@ -123,7 +124,7 @@ public struct TargetSource: Equatable {
|
||||
compilerFlags: [String] = [],
|
||||
excludes: [String] = [],
|
||||
type: SourceType? = nil,
|
||||
optional: Bool = false,
|
||||
optional: Bool = optionalDefault,
|
||||
buildPhase: BuildPhase? = nil,
|
||||
headerVisibility: HeaderVisibility? = nil,
|
||||
createIntermediateGroups: Bool? = nil
|
||||
@@ -169,7 +170,7 @@ extension TargetSource: JSONObjectConvertible {
|
||||
headerVisibility = jsonDictionary.json(atKeyPath: "headerVisibility")
|
||||
excludes = jsonDictionary.json(atKeyPath: "excludes") ?? []
|
||||
type = jsonDictionary.json(atKeyPath: "type")
|
||||
optional = jsonDictionary.json(atKeyPath: "optional") ?? false
|
||||
optional = jsonDictionary.json(atKeyPath: "optional") ?? TargetSource.optionalDefault
|
||||
|
||||
if let string: String = jsonDictionary.json(atKeyPath: "buildPhase") {
|
||||
buildPhase = try BuildPhase(string: string)
|
||||
@@ -193,8 +194,8 @@ extension TargetSource: JSONEncodable {
|
||||
"createIntermediateGroups": createIntermediateGroups,
|
||||
]
|
||||
|
||||
if optional {
|
||||
dict["optional"] = true
|
||||
if optional != TargetSource.optionalDefault {
|
||||
dict["optional"] = optional
|
||||
}
|
||||
|
||||
if dict.count == 0 {
|
||||
|
||||
Reference in New Issue
Block a user