mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-11 12:56:03 +03:00
format code
This commit is contained in:
parent
554a9d2524
commit
e75b1c1e89
@ -1,10 +1,3 @@
|
||||
//
|
||||
// Version.swift
|
||||
// ProjectSpec
|
||||
//
|
||||
// Created by Yonas Kolb on 22/12/17.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import xcproj
|
||||
import JSONUtilities
|
||||
@ -78,5 +71,4 @@ extension DeploymentTarget: JSONObjectConvertible {
|
||||
watchOS = try parseVersion("watchOS")
|
||||
macOS = try parseVersion("macOS")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,15 +67,15 @@ public struct ProjectSpec {
|
||||
|
||||
public static func == (lhs: ProjectSpec.Options, rhs: ProjectSpec.Options) -> Bool {
|
||||
return lhs.carthageBuildPath == rhs.carthageBuildPath &&
|
||||
lhs.bundleIdPrefix == rhs.bundleIdPrefix &&
|
||||
lhs.settingPresets == rhs.settingPresets &&
|
||||
lhs.createIntermediateGroups == rhs.createIntermediateGroups &&
|
||||
lhs.developmentLanguage == rhs.developmentLanguage &&
|
||||
lhs.tabWidth == rhs.tabWidth &&
|
||||
lhs.indentWidth == rhs.indentWidth &&
|
||||
lhs.usesTabs == rhs.usesTabs &&
|
||||
lhs.xcodeVersion == rhs.xcodeVersion &&
|
||||
lhs.deploymentTarget == rhs.deploymentTarget
|
||||
lhs.bundleIdPrefix == rhs.bundleIdPrefix &&
|
||||
lhs.settingPresets == rhs.settingPresets &&
|
||||
lhs.createIntermediateGroups == rhs.createIntermediateGroups &&
|
||||
lhs.developmentLanguage == rhs.developmentLanguage &&
|
||||
lhs.tabWidth == rhs.tabWidth &&
|
||||
lhs.indentWidth == rhs.indentWidth &&
|
||||
lhs.usesTabs == rhs.usesTabs &&
|
||||
lhs.xcodeVersion == rhs.xcodeVersion &&
|
||||
lhs.deploymentTarget == rhs.deploymentTarget
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ public struct LegacyTarget {
|
||||
}
|
||||
|
||||
extension LegacyTarget: Equatable {
|
||||
public static func ==(lhs: LegacyTarget, rhs: LegacyTarget) -> Bool {
|
||||
public static func == (lhs: LegacyTarget, rhs: LegacyTarget) -> Bool {
|
||||
return lhs.toolPath == rhs.toolPath &&
|
||||
lhs.arguments == rhs.arguments &&
|
||||
lhs.passSettings == rhs.passSettings &&
|
||||
@ -31,7 +31,7 @@ public struct Target {
|
||||
public var scheme: TargetScheme?
|
||||
public var legacy: LegacyTarget?
|
||||
public var deploymentTarget: Version?
|
||||
|
||||
|
||||
public var isLegacy: Bool {
|
||||
return legacy != nil
|
||||
}
|
||||
@ -185,7 +185,7 @@ extension TargetScheme: JSONObjectConvertible {
|
||||
}
|
||||
|
||||
extension LegacyTarget: JSONObjectConvertible {
|
||||
|
||||
|
||||
public init(jsonDictionary: JSONDictionary) throws {
|
||||
toolPath = try jsonDictionary.json(atKeyPath: "toolPath")
|
||||
arguments = jsonDictionary.json(atKeyPath: "arguments")
|
||||
|
@ -48,7 +48,7 @@ public struct Version: CustomStringConvertible, Equatable {
|
||||
return Version(major: major, minor: minor, patch: patch + 1)
|
||||
}
|
||||
|
||||
public static func ==(lhs: Version, rhs: Version) -> Bool {
|
||||
public static func == (lhs: Version, rhs: Version) -> Bool {
|
||||
return lhs.major == rhs.major &&
|
||||
lhs.minor == rhs.minor &&
|
||||
lhs.patch == rhs.patch
|
||||
|
@ -104,7 +104,7 @@ public class PBXProjGenerator {
|
||||
topLevelGroups.insert(rootGroup)
|
||||
}
|
||||
|
||||
let mainGroup = PBXGroup(reference: referenceGenerator.generate(PBXGroup.self, "Project"), children: Array(topLevelGroups), sourceTree: .group, usesTabs: spec.options.usesTabs.map{ $0 ? 1 : 0 }, indentWidth: spec.options.indentWidth, tabWidth: spec.options.tabWidth)
|
||||
let mainGroup = PBXGroup(reference: referenceGenerator.generate(PBXGroup.self, "Project"), children: Array(topLevelGroups), sourceTree: .group, usesTabs: spec.options.usesTabs.map { $0 ? 1 : 0 }, indentWidth: spec.options.indentWidth, tabWidth: spec.options.tabWidth)
|
||||
addObject(mainGroup)
|
||||
|
||||
sortGroups(group: mainGroup)
|
||||
@ -141,7 +141,7 @@ public class PBXProjGenerator {
|
||||
let childGroups = group.children.flatMap { proj.objects.groups[$0] }
|
||||
childGroups.forEach(sortGroups)
|
||||
}
|
||||
|
||||
|
||||
func generateTarget(_ target: Target) throws -> PBXTarget {
|
||||
|
||||
sourceGenerator.targetName = target.name
|
||||
@ -149,7 +149,7 @@ public class PBXProjGenerator {
|
||||
|
||||
let sourceFiles = try sourceGenerator.getAllSourceFiles(sources: target.sources)
|
||||
|
||||
var plistPath: Path? = nil
|
||||
var plistPath: Path?
|
||||
var searchForPlist = true
|
||||
|
||||
let configs: [XCBuildConfiguration] = spec.configs.map { config in
|
||||
|
@ -41,9 +41,9 @@ public class ProjectGenerator {
|
||||
func getBuildEntry(_ buildTarget: Scheme.BuildTarget) -> XCScheme.BuildAction.Entry {
|
||||
|
||||
let predicate: (PBXTarget) -> Bool = { $0.name == buildTarget.target }
|
||||
let targetReference = pbxProject.objects.nativeTargets.referenceValues.first{ predicate($0 as PBXTarget) } ?? pbxProject.objects.legacyTargets.referenceValues.first{ predicate($0 as PBXTarget) }!
|
||||
let targetReference = pbxProject.objects.nativeTargets.referenceValues.first { predicate($0 as PBXTarget) } ?? pbxProject.objects.legacyTargets.referenceValues.first { predicate($0 as PBXTarget) }!
|
||||
|
||||
let buildableReference = XCScheme.BuildableReference(referencedContainer: "container:\(spec.name).xcodeproj", blueprintIdentifier: targetReference.reference, buildableName: buildTarget.target + (targetReference.productType?.fileExtension.map{ ".\($0)" } ?? ""), blueprintName: scheme.name)
|
||||
let buildableReference = XCScheme.BuildableReference(referencedContainer: "container:\(spec.name).xcodeproj", blueprintIdentifier: targetReference.reference, buildableName: buildTarget.target + (targetReference.productType?.fileExtension.map { ".\($0)" } ?? ""), blueprintName: scheme.name)
|
||||
|
||||
return XCScheme.BuildAction.Entry(buildableReference: buildableReference, buildFor: buildTarget.buildTypes)
|
||||
}
|
||||
@ -152,4 +152,3 @@ extension Scheme {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,15 +173,15 @@ func projectGeneratorTests() {
|
||||
guard let projectConfigListReference = pbxProject.objects.projects.values.first?.buildConfigurationList,
|
||||
let projectConfigReference = pbxProject.objects.configurationLists[projectConfigListReference]?.buildConfigurations.first,
|
||||
let projectConfig = pbxProject.objects.buildConfigurations[projectConfigReference]
|
||||
else {
|
||||
throw failure("Couldn't find Project config")
|
||||
else {
|
||||
throw failure("Couldn't find Project config")
|
||||
}
|
||||
|
||||
guard let targetConfigListReference = pbxProject.objects.nativeTargets.referenceValues.first?.buildConfigurationList,
|
||||
let targetConfigReference = pbxProject.objects.configurationLists[targetConfigListReference]?.buildConfigurations.first,
|
||||
let targetConfig = pbxProject.objects.buildConfigurations[targetConfigReference]
|
||||
else {
|
||||
throw failure("Couldn't find Target config")
|
||||
else {
|
||||
throw failure("Couldn't find Target config")
|
||||
}
|
||||
|
||||
try expect(projectConfig.buildSettings["IPHONEOS_DEPLOYMENT_TARGET"] as? String) == "10.0"
|
||||
@ -477,8 +477,7 @@ func projectGeneratorTests() {
|
||||
"ignore.file",
|
||||
"*.ignored",
|
||||
// not supported
|
||||
//"**/*.ignored",
|
||||
|
||||
// "**/*.ignored",
|
||||
]
|
||||
|
||||
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [TargetSource(path: "Sources", excludes: excludes)])
|
||||
@ -504,7 +503,6 @@ func projectGeneratorTests() {
|
||||
try project.expectFileMissing(paths: ["Sources", "partial", "file_part"])
|
||||
try project.expectFileMissing(paths: ["Sources", "a.ignored"])
|
||||
try project.expectFileMissing(paths: ["Sources", "ignore.file"])
|
||||
|
||||
}
|
||||
|
||||
$0.it("generates file sources") {
|
||||
@ -643,7 +641,7 @@ func projectGeneratorTests() {
|
||||
TargetSource(path: "A", buildPhase: .resources),
|
||||
TargetSource(path: "B", buildPhase: .none),
|
||||
TargetSource(path: "C", buildPhase: nil),
|
||||
])
|
||||
])
|
||||
let spec = ProjectSpec(basePath: directoryPath, name: "Test", targets: [target])
|
||||
|
||||
let project = try getPbxProj(spec)
|
||||
@ -734,7 +732,7 @@ extension PBXProj {
|
||||
error = "isn't in a build phase when it's expected to be in \(buildPhase.rawValue.quoted)"
|
||||
}
|
||||
}
|
||||
} else if let actualBuildPhase = actualBuildPhase {
|
||||
} else if let actualBuildPhase = actualBuildPhase {
|
||||
error = "is in the \(actualBuildPhase.rawValue.quoted) build phase when it's expected to not be in any"
|
||||
}
|
||||
if let error = error {
|
||||
|
@ -119,7 +119,7 @@ func projectSpecTests() {
|
||||
build: .init(targets: [.init(target: "invalidTarget")]),
|
||||
run: .init(config: "debugInvalid"),
|
||||
archive: .init(config: "releaseInvalid")
|
||||
)]
|
||||
)]
|
||||
|
||||
try expectValidationError(spec, .invalidSchemeTarget(scheme: "scheme1", target: "invalidTarget"))
|
||||
try expectValidationError(spec, .invalidSchemeConfig(scheme: "scheme1", config: "debugInvalid"))
|
||||
@ -132,7 +132,7 @@ func projectSpecTests() {
|
||||
type: .application,
|
||||
platform: .iOS,
|
||||
sources: [.init(path: "generated.swift", optional: true)]
|
||||
)]
|
||||
)]
|
||||
try spec.validate()
|
||||
}
|
||||
}
|
||||
|
@ -229,18 +229,18 @@ func specLoadingTests() {
|
||||
bundleIdPrefix: "com.test",
|
||||
developmentLanguage: "ja",
|
||||
deploymentTarget: DeploymentTarget(
|
||||
iOS: "11.1",
|
||||
tvOS: "10.0",
|
||||
watchOS: "3.0",
|
||||
macOS: "10.12.1"))
|
||||
iOS: "11.1",
|
||||
tvOS: "10.0",
|
||||
watchOS: "3.0",
|
||||
macOS: "10.12.1"))
|
||||
let expected = ProjectSpec(basePath: "", name: "test", options: options)
|
||||
let dictionary: [String: Any] = ["options": [
|
||||
"carthageBuildPath": "../Carthage/Build",
|
||||
"bundleIdPrefix": "com.test",
|
||||
"createIntermediateGroups": true,
|
||||
"developmentLanguage": "ja",
|
||||
"deploymentTarget": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1" ]
|
||||
]]
|
||||
"deploymentTarget": ["iOS": 11.1, "tvOS": 10.0, "watchOS": "3", "macOS": "10.12.1"],
|
||||
]]
|
||||
let parsedSpec = try getProjectSpec(dictionary)
|
||||
try expect(parsedSpec) == expected
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user