From 9019b387d8f9581462f125f29f420119e8d0a1fd Mon Sep 17 00:00:00 2001 From: yonaskolb Date: Sun, 1 Sep 2019 21:51:50 +1000 Subject: [PATCH 1/3] update changelog --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e11b34f44..5f6b04af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,12 @@ ## Next Version +## 2.7.0 + #### Added -- Added Bash 4 style recursive globbing (`**/*`) when excluding files from target sources. [#636](https://github.com/yonaskolb/XcodeGen/pull/636) @bclymer -- Added ability to disable main thread checker on Run and Test schemes and TargetSchemes [#601](https://github.com/yonaskolb/XcodeGen/pull/601) @wag-miles +- Added Bash 4 style recursive globbing (`**/*`) in target sources `excludes` [#636](https://github.com/yonaskolb/XcodeGen/pull/636) @bclymer +- Added ability to disable main thread checker in Schemes [#601](https://github.com/yonaskolb/XcodeGen/pull/601) @wag-miles #### Fixed - Fixed included specs that were referenced multiple times from duplicating content [#599](https://github.com/yonaskolb/XcodeGen/pull/599) @haritowa @@ -14,6 +16,8 @@ #### Changed - Allow linking of dependencies into static libraries when `link` is set to true [#635](https://github.com/yonaskolb/XcodeGen/pull/635) @kateinoigakukun +[Commits](https://github.com/yonaskolb/XcodeGen/compare/2.6.0...2.7.0) + ## 2.6.0 #### Added From 777b15fe21fa5d7518f4cb4db4bd2fb659692bda Mon Sep 17 00:00:00 2001 From: yonaskolb Date: Sun, 1 Sep 2019 21:57:39 +1000 Subject: [PATCH 2/3] Update to 2.7.0 --- Makefile | 2 +- README.md | 2 +- Sources/XcodeGen/main.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 290799249..f14716d25 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TOOL_NAME = XcodeGen export EXECUTABLE_NAME = xcodegen -VERSION = 2.6.0 +VERSION = 2.7.0 PREFIX = /usr/local INSTALL_PATH = $(PREFIX)/bin/$(EXECUTABLE_NAME) diff --git a/README.md b/README.md index af43ea7b4..5f1c1a9c1 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ swift run xcodegen Add the following to your Package.swift file's dependencies: ```swift -.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "2.6.0"), +.package(url: "https://github.com/yonaskolb/XcodeGen.git", from: "2.7.0"), ``` And then import wherever needed: `import XcodeGenKit` diff --git a/Sources/XcodeGen/main.swift b/Sources/XcodeGen/main.swift index c3c66e28d..45bf241b5 100644 --- a/Sources/XcodeGen/main.swift +++ b/Sources/XcodeGen/main.swift @@ -2,6 +2,6 @@ import Foundation import ProjectSpec import XcodeGenCLI -let version = Version("2.6.0") +let version = Version("2.7.0") let cli = XcodeGenCLI(version: version) cli.execute() From d921d14259d12d7ae201e4237de58be756cf8028 Mon Sep 17 00:00:00 2001 From: yonaskolb Date: Sun, 1 Sep 2019 22:02:53 +1000 Subject: [PATCH 3/3] make format_code --- Sources/ProjectSpec/AggregateTarget.swift | 2 +- Sources/ProjectSpec/BuildRule.swift | 2 +- Sources/ProjectSpec/BuildScript.swift | 3 ++- Sources/ProjectSpec/Dependency.swift | 2 +- Sources/ProjectSpec/Plist.swift | 2 +- Sources/ProjectSpec/Project.swift | 2 +- Sources/ProjectSpec/Scheme.swift | 16 ++++++------- Sources/ProjectSpec/Settings.swift | 2 +- Sources/ProjectSpec/SpecFile.swift | 20 ++++++++-------- Sources/ProjectSpec/Target.swift | 9 ++++--- Sources/ProjectSpec/TargetScheme.swift | 2 +- Sources/ProjectSpec/TargetSource.swift | 2 +- Sources/XcodeGenKit/Glob.swift | 8 ++----- Sources/XcodeGenKit/MD5.swift | 20 +++++++--------- Sources/XcodeGenKit/PBXProjGenerator.swift | 2 +- Sources/XcodeGenKit/SchemeGenerator.swift | 2 +- Sources/XcodeGenKit/XCProjExtensions.swift | 2 +- Tests/XcodeGenKitTests/GlobTests.swift | 10 ++++---- .../ProjectFixtureTests.swift | 2 +- .../ProjectGeneratorTests.swift | 20 ++++++++-------- Tests/XcodeGenKitTests/ProjectSpecTests.swift | 22 ++++++++--------- .../SchemeGeneratorTests.swift | 8 +++---- .../SourceGeneratorTests.swift | 16 ++++++------- Tests/XcodeGenKitTests/SpecLoadingTests.swift | 24 +++++++++---------- Tests/XcodeGenKitTests/TestHelpers.swift | 2 +- 25 files changed, 97 insertions(+), 105 deletions(-) diff --git a/Sources/ProjectSpec/AggregateTarget.swift b/Sources/ProjectSpec/AggregateTarget.swift index d861958ff..20f67dc78 100644 --- a/Sources/ProjectSpec/AggregateTarget.swift +++ b/Sources/ProjectSpec/AggregateTarget.swift @@ -70,7 +70,7 @@ extension AggregateTarget: JSONEncodable { "configFiles": configFiles, "attributes": attributes, "buildScripts": buildScripts.map { $0.toJSONValue() }, - "scheme": scheme?.toJSONValue() + "scheme": scheme?.toJSONValue(), ] as [String: Any?] } } diff --git a/Sources/ProjectSpec/BuildRule.swift b/Sources/ProjectSpec/BuildRule.swift index 3f75e75fd..760b57c7a 100644 --- a/Sources/ProjectSpec/BuildRule.swift +++ b/Sources/ProjectSpec/BuildRule.swift @@ -86,7 +86,7 @@ extension BuildRule: JSONEncodable { var dict: [String: Any?] = [ "outputFiles": outputFiles, "outputFilesCompilerFlags": outputFilesCompilerFlags, - "name": name + "name": name, ] switch fileType { diff --git a/Sources/ProjectSpec/BuildScript.swift b/Sources/ProjectSpec/BuildScript.swift index f1eaf33a5..7494ed52b 100644 --- a/Sources/ProjectSpec/BuildScript.swift +++ b/Sources/ProjectSpec/BuildScript.swift @@ -63,6 +63,7 @@ extension BuildScript: JSONObjectConvertible { showEnvVars = jsonDictionary.json(atKeyPath: "showEnvVars") ?? BuildScript.showEnvVarsDefault } } + extension BuildScript: JSONEncodable { public func toJSONValue() -> Any { var dict: [String: Any?] = [ @@ -72,7 +73,7 @@ extension BuildScript: JSONEncodable { "outputFileLists": outputFileLists, "runOnlyWhenInstalling": runOnlyWhenInstalling, "name": name, - "shell": shell + "shell": shell, ] if showEnvVars != BuildScript.showEnvVarsDefault { diff --git a/Sources/ProjectSpec/Dependency.swift b/Sources/ProjectSpec/Dependency.swift index 8da36e6d6..022bcbcde 100644 --- a/Sources/ProjectSpec/Dependency.swift +++ b/Sources/ProjectSpec/Dependency.swift @@ -89,7 +89,7 @@ extension Dependency: JSONEncodable { var dict: [String: Any?] = [ "embed": embed, "codeSign": codeSign, - "link": link + "link": link, ] if removeHeaders != Dependency.removeHeadersDefault { diff --git a/Sources/ProjectSpec/Plist.swift b/Sources/ProjectSpec/Plist.swift index e174a9ab0..8014c7bc3 100644 --- a/Sources/ProjectSpec/Plist.swift +++ b/Sources/ProjectSpec/Plist.swift @@ -29,7 +29,7 @@ extension Plist: JSONEncodable { public func toJSONValue() -> Any { return [ "path": path, - "properties": properties + "properties": properties, ] } } diff --git a/Sources/ProjectSpec/Project.swift b/Sources/ProjectSpec/Project.swift index 2790d0085..adfdf0291 100644 --- a/Sources/ProjectSpec/Project.swift +++ b/Sources/ProjectSpec/Project.swift @@ -254,7 +254,7 @@ extension Project: JSONEncodable { "configs": Dictionary(uniqueKeysWithValues: configsPairs), "aggregateTargets": Dictionary(uniqueKeysWithValues: aggregateTargetsPairs), "schemes": Dictionary(uniqueKeysWithValues: schemesPairs), - "settingGroups": settingGroups.mapValues { $0.toJSONValue() } + "settingGroups": settingGroups.mapValues { $0.toJSONValue() }, ] } } diff --git a/Sources/ProjectSpec/Scheme.swift b/Sources/ProjectSpec/Scheme.swift index 6ab9c3c69..6e58be0ca 100644 --- a/Sources/ProjectSpec/Scheme.swift +++ b/Sources/ProjectSpec/Scheme.swift @@ -197,7 +197,7 @@ 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 @@ -247,7 +247,7 @@ extension Scheme.ExecutionAction: JSONEncodable { return [ "script": script, "name": name, - "settingsTarget": settingsTarget + "settingsTarget": settingsTarget, ] } } @@ -271,7 +271,7 @@ extension Scheme.Run: JSONEncodable { "preActions": preActions.map { $0.toJSONValue() }, "postActions": postActions.map { $0.toJSONValue() }, "environmentVariables": environmentVariables.map { $0.toJSONValue() }, - "config": config + "config": config, ] if disableMainThreadChecker != Scheme.Run.disableMainThreadCheckerDefault { @@ -316,7 +316,7 @@ extension Scheme.Test: JSONEncodable { "preActions": preActions.map { $0.toJSONValue() }, "postActions": postActions.map { $0.toJSONValue() }, "environmentVariables": environmentVariables.map { $0.toJSONValue() }, - "config": config + "config": config, ] if gatherCoverageData != Scheme.Test.gatherCoverageDataDefault { @@ -348,7 +348,7 @@ extension Scheme.Test.TestTarget: JSONEncodable { } var dict: JSONDictionary = [ - "name": name + "name": name, ] if randomExecutionOrder != Scheme.Test.TestTarget.randomExecutionOrderDefault { @@ -380,7 +380,7 @@ extension Scheme.Profile: JSONEncodable { "preActions": preActions.map { $0.toJSONValue() }, "postActions": postActions.map { $0.toJSONValue() }, "environmentVariables": environmentVariables.map { $0.toJSONValue() }, - "config": config + "config": config, ] as [String: Any?] } } @@ -395,7 +395,7 @@ extension Scheme.Analyze: JSONObjectConvertible { extension Scheme.Analyze: JSONEncodable { public func toJSONValue() -> Any { return [ - "config": config + "config": config, ] } } @@ -581,7 +581,7 @@ extension XCScheme.EnvironmentVariable: JSONEncodable { public func toJSONValue() -> Any { var dict: [String: Any] = [ "variable": variable, - "value": value + "value": value, ] if enabled != XCScheme.EnvironmentVariable.enabledDefault { diff --git a/Sources/ProjectSpec/Settings.swift b/Sources/ProjectSpec/Settings.swift index 6350c4375..52e0bed50 100644 --- a/Sources/ProjectSpec/Settings.swift +++ b/Sources/ProjectSpec/Settings.swift @@ -112,7 +112,7 @@ extension Settings: JSONEncodable { return [ "base": buildSettings, "groups": groups, - "configs": configSettings.mapValues { $0.toJSONValue() } + "configs": configSettings.mapValues { $0.toJSONValue() }, ] } return buildSettings diff --git a/Sources/ProjectSpec/SpecFile.swift b/Sources/ProjectSpec/SpecFile.swift index 98a39542a..2261ce315 100644 --- a/Sources/ProjectSpec/SpecFile.swift +++ b/Sources/ProjectSpec/SpecFile.swift @@ -9,7 +9,7 @@ public struct SpecFile { public let subSpecs: [SpecFile] private let filename: String - + fileprivate struct Include { let path: Path let relativePaths: Bool @@ -92,27 +92,27 @@ public struct SpecFile { private func resolvedDictionaryWithUniqueTargets() -> JSONDictionary { let resolvedSpec = resolvingPaths() - + var value = Set() return resolvedSpec.mergedDictionary(set: &value) } - + private func substitute(variables: [String: String], in mergedDictionary: JSONDictionary) -> JSONDictionary { var resolvedSpec = mergedDictionary - + for (key, value) in variables { resolvedSpec = resolvedSpec.replaceString("${\(key)}", with: value) } - + return resolvedSpec } - + func mergedDictionary(set mergedTargets: inout Set) -> JSONDictionary { let name = (basePath + relativePath + Path(filename)).description - + guard !mergedTargets.contains(name) else { return [:] } mergedTargets.insert(name) - + return jsonDictionary.merged(onto: subSpecs .map { $0.mergedDictionary(set: &mergedTargets) } @@ -137,14 +137,14 @@ public struct SpecFile { extension Dictionary where Key == String, Value: Any { - func merged(onto other: Dictionary) -> Dictionary { + func merged(onto other: [Key: Value]) -> [Key: Value] { var merged = other for (key, value) in self { if key.hasSuffix(":REPLACE") { let newKey = key[key.startIndex.., let base = merged[key] as? Dictionary { + } else if let dictionary = value as? [Key: Value], let base = merged[key] as? [Key: Value] { merged[key] = dictionary.merged(onto: base) as? Value } else if let array = value as? [Any], let base = merged[key] as? [Any] { merged[key] = (base + array) as? Value diff --git a/Sources/ProjectSpec/Target.swift b/Sources/ProjectSpec/Target.swift index 4dd6583af..e305cf401 100644 --- a/Sources/ProjectSpec/Target.swift +++ b/Sources/ProjectSpec/Target.swift @@ -361,7 +361,6 @@ extension Target: NamedJSONDictionaryConvertible { } } - extension Target: JSONEncodable { public func toJSONValue() -> Any { var dict: [String: Any?] = [ @@ -372,10 +371,10 @@ extension Target: JSONEncodable { "attributes": attributes, "sources": sources.map { $0.toJSONValue() }, "dependencies": dependencies.map { $0.toJSONValue() }, - "postCompileScripts": postCompileScripts.map{ $0.toJSONValue() }, - "prebuildScripts": preBuildScripts.map{ $0.toJSONValue() }, - "postbuildScripts": postBuildScripts.map{ $0.toJSONValue() }, - "buildRules": buildRules.map{ $0.toJSONValue() }, + "postCompileScripts": postCompileScripts.map { $0.toJSONValue() }, + "prebuildScripts": preBuildScripts.map { $0.toJSONValue() }, + "postbuildScripts": postBuildScripts.map { $0.toJSONValue() }, + "buildRules": buildRules.map { $0.toJSONValue() }, "deploymentTarget": deploymentTarget?.deploymentTarget, "info": info?.toJSONValue(), "entitlements": entitlements?.toJSONValue(), diff --git a/Sources/ProjectSpec/TargetScheme.swift b/Sources/ProjectSpec/TargetScheme.swift index 4682e3a79..c4c4673ec 100644 --- a/Sources/ProjectSpec/TargetScheme.swift +++ b/Sources/ProjectSpec/TargetScheme.swift @@ -72,7 +72,7 @@ extension TargetScheme: JSONEncodable { "preActions": preActions.map { $0.toJSONValue() }, "postActions": postActions.map { $0.toJSONValue() }, ] - + if gatherCoverageData != TargetScheme.gatherCoverageDataDefault { dict["gatherCoverageData"] = gatherCoverageData } diff --git a/Sources/ProjectSpec/TargetSource.swift b/Sources/ProjectSpec/TargetSource.swift index 6ad090617..9df057dad 100644 --- a/Sources/ProjectSpec/TargetSource.swift +++ b/Sources/ProjectSpec/TargetSource.swift @@ -264,7 +264,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable { public func toJSONValue() -> Any { return [ "destination": destination.rawValue, - "subpath": subpath + "subpath": subpath, ] } } diff --git a/Sources/XcodeGenKit/Glob.swift b/Sources/XcodeGenKit/Glob.swift index f74a063ff..45453b43f 100644 --- a/Sources/XcodeGenKit/Glob.swift +++ b/Sources/XcodeGenKit/Glob.swift @@ -6,10 +6,8 @@ // Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167 // Adapted from https://gist.github.com/efirestone/ce01ae109e08772647eb061b3bb387c3 - import Foundation - public let GlobBehaviorBashV3 = Glob.Behavior( supportsGlobstar: false, includesFilesFromRootOfGlobstar: false, @@ -29,7 +27,6 @@ public let GlobBehaviorGradle = Glob.Behavior( includesFilesInResultsIfTrailingSlash: true ) - /** Finds files on the file system using pattern matching. */ @@ -66,7 +63,7 @@ public class Glob: Collection { public let blacklistedDirectories: [String] var paths = [String]() public var startIndex: Int { return paths.startIndex } - public var endIndex: Int { return paths.endIndex } + public var endIndex: Int { return paths.endIndex } /// Initialize a glob /// @@ -126,7 +123,7 @@ public class Glob: Collection { private var globalFlags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK private func executeGlob(pattern: UnsafePointer, gt: UnsafeMutablePointer) -> Bool { - return 0 == glob(pattern, globalFlags, nil, gt) + return glob(pattern, globalFlags, nil, gt) == 0 } private func expandGlobstar(pattern: String) -> [String] { @@ -234,4 +231,3 @@ private extension Sequence { return Array(self) } } - diff --git a/Sources/XcodeGenKit/MD5.swift b/Sources/XcodeGenKit/MD5.swift index 37cd98694..49ad10a16 100644 --- a/Sources/XcodeGenKit/MD5.swift +++ b/Sources/XcodeGenKit/MD5.swift @@ -21,7 +21,7 @@ extension String { public var md5: String { if let data = data(using: .utf8, allowLossyConversion: true) { let message = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) -> [UInt8] in - return Array(bytes) + Array(bytes) } let MD5Calculator = MD5(message) @@ -80,14 +80,14 @@ extension NSMutableData { } protocol HashProtocol { - var message: Array { get } + var message: [UInt8] { get } /** Common part for hash calculation. Prepare header data. */ - func prepare(_ len: Int) -> Array + func prepare(_ len: Int) -> [UInt8] } extension HashProtocol { - func prepare(_ len: Int) -> Array { + func prepare(_ len: Int) -> [UInt8] { var tmpMessage = message // Step 1. Append Padding Bits @@ -102,13 +102,13 @@ extension HashProtocol { msgLength += 1 } - tmpMessage += Array(repeating: 0, count: counter) + tmpMessage += [UInt8](repeating: 0, count: counter) return tmpMessage } } -func toUInt32Array(_ slice: ArraySlice) -> Array { - var result = Array() +func toUInt32Array(_ slice: ArraySlice) -> [UInt32] { + var result = [UInt32]() result.reserveCapacity(16) for idx in stride(from: slice.startIndex, to: slice.endIndex, by: MemoryLayout.size) { @@ -230,26 +230,22 @@ class MD5: HashProtocol { case 0...15: F = (B & C) | ((~B) & D) g = j - break case 16...31: F = (D & B) | (~D & C) g = (5 * j + 1) % 16 - break case 32...47: F = B ^ C ^ D g = (3 * j + 5) % 16 - break case 48...63: F = C ^ (B | (~D)) g = (7 * j) % 16 - break default: break } dTemp = D D = C C = B - B = B &+ rotateLeft((A &+ F &+ sines[j] &+ M[g]), bits: shifts[j]) + B = B &+ rotateLeft(A &+ F &+ sines[j] &+ M[g], bits: shifts[j]) A = dTemp } diff --git a/Sources/XcodeGenKit/PBXProjGenerator.swift b/Sources/XcodeGenKit/PBXProjGenerator.swift index 6b580e08d..685bb312c 100644 --- a/Sources/XcodeGenKit/PBXProjGenerator.swift +++ b/Sources/XcodeGenKit/PBXProjGenerator.swift @@ -999,7 +999,7 @@ extension Target { var shouldEmbedDependencies: Bool { return type.isApp || type.isTest } - + var shouldEmbedCarthageDependencies: Bool { return (type.isApp && platform != .watchOS) || type == .watch2Extension diff --git a/Sources/XcodeGenKit/SchemeGenerator.swift b/Sources/XcodeGenKit/SchemeGenerator.swift index 1da86a81b..df9c9d533 100644 --- a/Sources/XcodeGenKit/SchemeGenerator.swift +++ b/Sources/XcodeGenKit/SchemeGenerator.swift @@ -107,7 +107,7 @@ public class SchemeGenerator { func getExecutionAction(_ action: Scheme.ExecutionAction) -> XCScheme.ExecutionAction { // ExecutionActions can require the use of build settings. Xcode allows the settings to come from a build or test target. let environmentBuildable = action.settingsTarget.flatMap { settingsTarget in - return (buildActionEntries + testBuildTargetEntries) + (buildActionEntries + testBuildTargetEntries) .first { settingsTarget == $0.buildableReference.blueprintName }? .buildableReference } diff --git a/Sources/XcodeGenKit/XCProjExtensions.swift b/Sources/XcodeGenKit/XCProjExtensions.swift index 5b38e96f9..1daeb1dbf 100644 --- a/Sources/XcodeGenKit/XCProjExtensions.swift +++ b/Sources/XcodeGenKit/XCProjExtensions.swift @@ -38,7 +38,7 @@ extension PBXProj { extension Dictionary { - public var valueArray: Array { + public var valueArray: [Value] { return Array(values) } } diff --git a/Tests/XcodeGenKitTests/GlobTests.swift b/Tests/XcodeGenKitTests/GlobTests.swift index 4fb6a70de..9ae8df7ec 100644 --- a/Tests/XcodeGenKitTests/GlobTests.swift +++ b/Tests/XcodeGenKitTests/GlobTests.swift @@ -9,7 +9,7 @@ import XCTest @testable import XcodeGenKit -class GlobTests : XCTestCase { +class GlobTests: XCTestCase { let tmpFiles = ["foo", "bar", "baz", "dir1/file1.ext", "dir1/dir2/dir3/file2.ext", "dir1/file1.extfoo"] var tmpDir = "" @@ -17,7 +17,7 @@ class GlobTests : XCTestCase { override func setUp() { super.setUp() - self.tmpDir = newTmpDir() + tmpDir = newTmpDir() let flags = S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH mkdir("\(tmpDir)/dir1/", flags) @@ -36,7 +36,7 @@ class GlobTests : XCTestCase { rmdir("\(tmpDir)/dir1/dir2/dir3") rmdir("\(tmpDir)/dir1/dir2") rmdir("\(tmpDir)/dir1") - rmdir(self.tmpDir) + rmdir(tmpDir) super.tearDown() } @@ -139,7 +139,7 @@ class GlobTests : XCTestCase { "\(tmpDir)/dir1/dir2/dir3/file2.ext", "\(tmpDir)/dir1/file1.ext", "\(tmpDir)/dir1/file1.extfoo", - "\(tmpDir)/foo" + "\(tmpDir)/foo", ]) } @@ -188,7 +188,7 @@ class GlobTests : XCTestCase { let glob = Glob(pattern: pattern, behavior: GlobBehaviorBashV4) XCTAssertEqual(glob.paths, [ "\(tmpDir)/dir1/dir2/dir3/file2.ext", - "\(tmpDir)/dir1/file1.ext" + "\(tmpDir)/dir1/file1.ext", ]) } diff --git a/Tests/XcodeGenKitTests/ProjectFixtureTests.swift b/Tests/XcodeGenKitTests/ProjectFixtureTests.swift index 83b72339c..585b11e44 100644 --- a/Tests/XcodeGenKitTests/ProjectFixtureTests.swift +++ b/Tests/XcodeGenKitTests/ProjectFixtureTests.swift @@ -16,7 +16,7 @@ class ProjectFixtureTests: XCTestCase { } } -fileprivate func generateXcodeProject(specPath: Path, file: String = #file, line: Int = #line) throws { +private func generateXcodeProject(specPath: Path, file: String = #file, line: Int = #line) throws { let project = try Project(path: specPath) let generator = ProjectGenerator(project: project) let writer = FileWriter(project: project) diff --git a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift index 3e3be70b6..a8fce0721 100644 --- a/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/ProjectGeneratorTests.swift @@ -6,7 +6,7 @@ import XcodeProj import XCTest import Yams -fileprivate let app = Target( +private let app = Target( name: "MyApp", type: .application, platform: .iOS, @@ -14,20 +14,20 @@ fileprivate let app = Target( dependencies: [Dependency(type: .target, reference: "MyFramework")] ) -fileprivate let framework = Target( +private let framework = Target( name: "MyFramework", type: .framework, platform: .iOS, settings: Settings(buildSettings: ["SETTING_2": "VALUE"]) ) -fileprivate let optionalFramework = Target( +private let optionalFramework = Target( name: "MyOptionalFramework", type: .framework, platform: .iOS ) -fileprivate let uiTest = Target( +private let uiTest = Target( name: "MyAppUITests", type: .uiTestBundle, platform: .iOS, @@ -35,7 +35,7 @@ fileprivate let uiTest = Target( dependencies: [Dependency(type: .target, reference: "MyApp")] ) -fileprivate let targets = [app, framework, optionalFramework, uiTest] +private let targets = [app, framework, optionalFramework, uiTest] class ProjectGeneratorTests: XCTestCase { @@ -449,8 +449,8 @@ class ProjectGeneratorTests: XCTestCase { dependencies: [ Dependency(type: .target, reference: iosFrameworkZ.name, link: true), Dependency(type: .framework, reference: "FrameworkZ.framework", link: true), - Dependency(type: .target, reference: iosFrameworkX.name/*, link: false */), - Dependency(type: .framework, reference: "FrameworkX.framework"/*, link: false */), + Dependency(type: .target, reference: iosFrameworkX.name /* , link: false */ ), + Dependency(type: .framework, reference: "FrameworkX.framework" /* , link: false */ ), Dependency(type: .carthage(findFrameworks: false), reference: "CarthageZ"), ] ) @@ -902,9 +902,9 @@ class ProjectGeneratorTests: XCTestCase { let buildFileSettings = frameworkBuildFiles.map { $0.settings } try expect(frameworkBuildFiles.count) == 2 - try expect(buildFileSettings.compactMap({ $0 }).count) == 1 - try expect(buildFileSettings.compactMap({ $0?["ATTRIBUTES"] }).count) == 1 - try expect(buildFileSettings.compactMap({ $0?["ATTRIBUTES"] as? [String] }).first) == ["Weak"] + try expect(buildFileSettings.compactMap { $0 }.count) == 1 + try expect(buildFileSettings.compactMap { $0?["ATTRIBUTES"] }.count) == 1 + try expect(buildFileSettings.compactMap { $0?["ATTRIBUTES"] as? [String] }.first) == ["Weak"] } $0.it("generates info.plist") { diff --git a/Tests/XcodeGenKitTests/ProjectSpecTests.swift b/Tests/XcodeGenKitTests/ProjectSpecTests.swift index 34f10cc73..362a657ec 100644 --- a/Tests/XcodeGenKitTests/ProjectSpecTests.swift +++ b/Tests/XcodeGenKitTests/ProjectSpecTests.swift @@ -269,9 +269,9 @@ class ProjectSpecTests: XCTestCase { productName: "App", deploymentTarget: Version(major: 0, minor: 1, patch: 2), settings: Settings(buildSettings: ["foo": "bar"], - configSettings: ["foo" : Settings(buildSettings: ["nested": "config"], - configSettings: [:], - groups: ["config-setting-group"])], + configSettings: ["foo": Settings(buildSettings: ["nested": "config"], + configSettings: [:], + groups: ["config-setting-group"])], groups: ["setting-group"]), configFiles: ["foo": "bar"], sources: [TargetSource(path: "Source", @@ -331,7 +331,7 @@ class ProjectSpecTests: XCTestCase { action: .compilerSpec("com.apple.xcode.tools.swift.compiler"), name: nil, outputFiles: ["bar"], - outputFilesCompilerFlags: ["foo"]),], + outputFilesCompilerFlags: ["foo"])], scheme: TargetScheme(testTargets: [Scheme.Test.TestTarget(name: "test target", randomExecutionOrder: false, parallelizable: false)], @@ -388,14 +388,14 @@ class ProjectSpecTests: XCTestCase { settingsTarget: "foo")]), attributes: ["foo": "bar"])], settings: Settings(buildSettings: ["foo": "bar"], - configSettings: ["foo" : Settings(buildSettings: ["nested": "config"], - configSettings: [:], - groups: ["config-setting-group"])], + configSettings: ["foo": Settings(buildSettings: ["nested": "config"], + configSettings: [:], + groups: ["config-setting-group"])], groups: ["setting-group"]), settingGroups: ["foo": Settings(buildSettings: ["foo": "bar"], - configSettings: ["foo" : Settings(buildSettings: ["nested": "config"], - configSettings: [:], - groups: ["config-setting-group"])], + configSettings: ["foo": Settings(buildSettings: ["nested": "config"], + configSettings: [:], + groups: ["config-setting-group"])], groups: ["setting-group"])], schemes: [Scheme(name: "scheme", build: Scheme.Build(targets: [Scheme.BuildTarget(target: "foo", @@ -503,7 +503,7 @@ class ProjectSpecTests: XCTestCase { } } -fileprivate func expectValidationError(_ project: Project, _ expectedError: SpecValidationError.ValidationError, file: String = #file, line: Int = #line) throws { +private func expectValidationError(_ project: Project, _ expectedError: SpecValidationError.ValidationError, file: String = #file, line: Int = #line) throws { do { try project.validate() } catch let error as SpecValidationError { diff --git a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift index 13f12e6d3..ac84c0c10 100644 --- a/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SchemeGeneratorTests.swift @@ -6,26 +6,26 @@ import XcodeProj import XCTest import Yams -fileprivate let app = Target( +private let app = Target( name: "MyApp", type: .application, platform: .iOS, dependencies: [Dependency(type: .target, reference: "MyFramework")] ) -fileprivate let framework = Target( +private let framework = Target( name: "MyFramework", type: .framework, platform: .iOS ) -fileprivate let optionalFramework = Target( +private let optionalFramework = Target( name: "MyOptionalFramework", type: .framework, platform: .iOS ) -fileprivate let uiTest = Target( +private let uiTest = Target( name: "MyAppUITests", type: .uiTestBundle, platform: .iOS, diff --git a/Tests/XcodeGenKitTests/SourceGeneratorTests.swift b/Tests/XcodeGenKitTests/SourceGeneratorTests.swift index 5faf83056..006ee2305 100644 --- a/Tests/XcodeGenKitTests/SourceGeneratorTests.swift +++ b/Tests/XcodeGenKitTests/SourceGeneratorTests.swift @@ -617,7 +617,7 @@ class SourceGeneratorTests: XCTestCase { TargetSource(path: "File1.swift", optional: true), TargetSource(path: "File2.swift", type: .file, optional: true), TargetSource(path: "Group", type: .folder, optional: true), - ]) + ]) let project = Project(basePath: directoryPath, name: "Test", targets: [target]) let pbxProj = try project.generatePbxProj() try pbxProj.expectFile(paths: ["File1.swift"]) @@ -630,11 +630,11 @@ class SourceGeneratorTests: XCTestCase { TargetSource(path: "Group1", optional: true), TargetSource(path: "Group2", type: .group, optional: true), TargetSource(path: "Group3", type: .group, optional: true), - ]) + ]) let project = Project(basePath: directoryPath, name: "Test", targets: [target]) _ = try project.generatePbxProj() } - + $0.it("relative path items outside base path are grouped together") { let directories = """ Sources: @@ -644,21 +644,21 @@ class SourceGeneratorTests: XCTestCase { - b.swift """ try createDirectories(directories) - + let outOfSourceFile1 = outOfRootPath + "Outside/a.swift" try outOfSourceFile1.parent().mkpath() try outOfSourceFile1.write("") - + let outOfSourceFile2 = outOfRootPath + "Outside/Outside2/b.swift" try outOfSourceFile2.parent().mkpath() try outOfSourceFile2.write("") - + let target = Target(name: "Test", type: .application, platform: .iOS, sources: [ "Sources", "../OtherDirectory", ]) let project = Project(basePath: directoryPath, name: "Test", targets: [target]) - + let pbxProj = try project.generatePbxProj() try pbxProj.expectFile(paths: ["Sources", "Inside", "a.swift"], buildPhase: .sources) try pbxProj.expectFile(paths: ["Sources", "Inside", "Inside2", "b.swift"], buildPhase: .sources) @@ -676,7 +676,7 @@ class SourceGeneratorTests: XCTestCase { let definition: String = "Intent.intentdefinition" let target = Target(name: "Test", type: .framework, platform: .iOS, sources: [ - TargetSource(path: "A/\(definition)", buildPhase: .sources, attributes: ["no_codegen"]) + TargetSource(path: "A/\(definition)", buildPhase: .sources, attributes: ["no_codegen"]), ]) let project = Project(basePath: directoryPath, name: "Test", targets: [target]) diff --git a/Tests/XcodeGenKitTests/SpecLoadingTests.swift b/Tests/XcodeGenKitTests/SpecLoadingTests.swift index 9a745e973..dfa177c1c 100644 --- a/Tests/XcodeGenKitTests/SpecLoadingTests.swift +++ b/Tests/XcodeGenKitTests/SpecLoadingTests.swift @@ -14,16 +14,16 @@ class SpecLoadingTests: XCTestCase { $0.it("merges each file only once") { let path = fixturePath + "duplicated_include/duplicated_import_sut.yml" let project = try loadSpec(path: path) - + try expect(project.fileGroups) == ["First", "Second"] - + let sutTarget = project.targets.first try expect(sutTarget?.sources) == [TargetSource(path: "template")] try expect(sutTarget?.preBuildScripts) == [BuildScript(script: .script("swiftlint"), name: "Swiftlint")] } } } - + func testSpecLoader() { describe { $0.it("merges includes") { @@ -207,12 +207,12 @@ class SpecLoadingTests: XCTestCase { let project = try loadSpec(path: path, variables: [ "SETTING1": "ENV VALUE1", "SETTING4": "ENV VALUE4", - "variable": "doesWin" + "variable": "doesWin", ]) try expect(project.name) == "NewName" try expect(project.settingGroups) == [ - "test": Settings(dictionary: ["MY_SETTING1": "ENV VALUE1", "MY_SETTING2": "VALUE2", "MY_SETTING4": "ENV VALUE4"]), + "test": Settings(dictionary: ["MY_SETTING1": "ENV VALUE1", "MY_SETTING2": "VALUE2", "MY_SETTING4": "ENV VALUE4"]), "toReplace": Settings(dictionary: ["MY_SETTING1": "VALUE1"]), ] try expect(project.targets.last?.sources) == ["SomeTarget", "doesWin", "templateVariable"] @@ -277,7 +277,7 @@ class SpecLoadingTests: XCTestCase { try expectError(SpecValidationError(errors: [ .deprecatedUsageOfPlaceholder(placeholderName: "target_name"), .deprecatedUsageOfPlaceholder(placeholderName: "platform"), - ]), { try specLoader.validateProjectDictionaryWarnings() }) + ])) { try specLoader.validateProjectDictionaryWarnings() } } $0.it("successfully validates warnings for new placeholder usage") { @@ -762,11 +762,11 @@ class SpecLoadingTests: XCTestCase { "name": "Target2", "parallelizable": true, "randomExecutionOrder": true, - "skippedTests": ["Test/testExample()"] + "skippedTests": ["Test/testExample()"], ], ], "gatherCoverageData": true, - "disableMainThreadChecker": true + "disableMainThreadChecker": true, ], ] let scheme = try Scheme(name: "Scheme", jsonDictionary: schemeDictionary) @@ -977,7 +977,7 @@ class SpecLoadingTests: XCTestCase { } @discardableResult -fileprivate func getProjectSpec(_ project: [String: Any], file: String = #file, line: Int = #line) throws -> Project { +private func getProjectSpec(_ project: [String: Any], file: String = #file, line: Int = #line) throws -> Project { var projectDictionary: [String: Any] = ["name": "test"] for (key, value) in project { projectDictionary[key] = value @@ -989,7 +989,7 @@ fileprivate func getProjectSpec(_ project: [String: Any], file: String = #file, } } -fileprivate func loadSpec(path: Path, variables: [String: String] = [:], file: String = #file, line: Int = #line) throws -> Project { +private func loadSpec(path: Path, variables: [String: String] = [:], file: String = #file, line: Int = #line) throws -> Project { do { let specLoader = SpecLoader(version: "1.1.0") return try specLoader.loadProject(path: path, variables: variables) @@ -998,13 +998,13 @@ fileprivate func loadSpec(path: Path, variables: [String: String] = [:], file: S } } -fileprivate func expectSpecError(_ project: [String: Any], _ expectedError: SpecParsingError, file: String = #file, line: Int = #line) throws { +private func expectSpecError(_ project: [String: Any], _ expectedError: SpecParsingError, file: String = #file, line: Int = #line) throws { try expectError(expectedError, file: file, line: line) { try getProjectSpec(project) } } -fileprivate func expectTargetError(_ target: [String: Any], _ expectedError: SpecParsingError, file: String = #file, line: Int = #line) throws { +private func expectTargetError(_ target: [String: Any], _ expectedError: SpecParsingError, file: String = #file, line: Int = #line) throws { try expectError(expectedError, file: file, line: line) { _ = try Target(name: "test", jsonDictionary: target) } diff --git a/Tests/XcodeGenKitTests/TestHelpers.swift b/Tests/XcodeGenKitTests/TestHelpers.swift index 95e001462..1802dca6d 100644 --- a/Tests/XcodeGenKitTests/TestHelpers.swift +++ b/Tests/XcodeGenKitTests/TestHelpers.swift @@ -43,7 +43,7 @@ struct ExpectationFailure: FailureType { } open class ArrayExpectation: ExpectationType { - public typealias ValueType = Array + public typealias ValueType = [T] public let expression: () throws -> ValueType? let file: String