mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-09-11 12:56:03 +03:00
run swiftformat
This commit is contained in:
parent
ac3ba77d07
commit
fb3f80d6af
@ -20,35 +20,35 @@ let package = Package(
|
||||
],
|
||||
targets: [
|
||||
.target(name: "XcodeGen", dependencies: [
|
||||
"XcodeGenCLI",
|
||||
"XcodeGenCLI",
|
||||
]),
|
||||
.target(name: "XcodeGenCLI", dependencies: [
|
||||
"XcodeGenKit",
|
||||
"ProjectSpec",
|
||||
"SwiftCLI",
|
||||
"Rainbow",
|
||||
"PathKit",
|
||||
"XcodeGenKit",
|
||||
"ProjectSpec",
|
||||
"SwiftCLI",
|
||||
"Rainbow",
|
||||
"PathKit",
|
||||
]),
|
||||
.target(name: "XcodeGenKit", dependencies: [
|
||||
"ProjectSpec",
|
||||
"JSONUtilities",
|
||||
"xcodeproj",
|
||||
"PathKit",
|
||||
"ProjectSpec",
|
||||
"JSONUtilities",
|
||||
"xcodeproj",
|
||||
"PathKit",
|
||||
]),
|
||||
.target(name: "ProjectSpec", dependencies: [
|
||||
"JSONUtilities",
|
||||
"xcodeproj",
|
||||
"Yams",
|
||||
"JSONUtilities",
|
||||
"xcodeproj",
|
||||
"Yams",
|
||||
]),
|
||||
.testTarget(name: "XcodeGenKitTests", dependencies: [
|
||||
"XcodeGenKit",
|
||||
"Spectre",
|
||||
"PathKit",
|
||||
"XcodeGenKit",
|
||||
"Spectre",
|
||||
"PathKit",
|
||||
]),
|
||||
.testTarget(name: "PerformanceTests", dependencies: [
|
||||
"XcodeGenKit",
|
||||
"Spectre",
|
||||
"PathKit",
|
||||
])
|
||||
"XcodeGenKit",
|
||||
"Spectre",
|
||||
"PathKit",
|
||||
]),
|
||||
]
|
||||
)
|
||||
|
@ -49,7 +49,7 @@ extension BuildScript: JSONObjectConvertible {
|
||||
outputFiles = jsonDictionary.json(atKeyPath: "outputFiles") ?? []
|
||||
inputFileLists = jsonDictionary.json(atKeyPath: "inputFileLists") ?? []
|
||||
outputFileLists = jsonDictionary.json(atKeyPath: "outputFileLists") ?? []
|
||||
|
||||
|
||||
if let string: String = jsonDictionary.json(atKeyPath: "script") {
|
||||
script = .script(string)
|
||||
} else {
|
||||
|
@ -14,7 +14,7 @@ enum PathProperty {
|
||||
}
|
||||
|
||||
extension Array where Element == PathProperty {
|
||||
|
||||
|
||||
func resolvingPaths(in jsonDictionary: JSONDictionary, relativeTo path: Path) -> JSONDictionary {
|
||||
var result = jsonDictionary
|
||||
|
||||
|
@ -21,7 +21,7 @@ public struct SpecFile {
|
||||
} else if let dictionary = any as? JSONDictionary,
|
||||
let path = dictionary["path"] as? String {
|
||||
self.path = Path(path)
|
||||
self.relativePaths = dictionary["relativePaths"] as? Bool ?? Include.defaultRelativePaths
|
||||
relativePaths = dictionary["relativePaths"] as? Bool ?? Include.defaultRelativePaths
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
@ -91,8 +91,7 @@ public struct SpecFile {
|
||||
return jsonDictionary.merged(onto:
|
||||
subSpecs
|
||||
.map { $0.mergedDictionary() }
|
||||
.reduce([:]) { $1.merged(onto: $0) }
|
||||
)
|
||||
.reduce([:]) { $1.merged(onto: $0) })
|
||||
}
|
||||
|
||||
func resolvingPaths(relativeTo basePath: Path = Path()) -> SpecFile {
|
||||
@ -105,7 +104,7 @@ public struct SpecFile {
|
||||
return SpecFile(
|
||||
jsonDictionary: jsonDictionary,
|
||||
relativePath: self.relativePath,
|
||||
subSpecs: self.subSpecs.map { $0.resolvingPaths(relativeTo: relativePath) }
|
||||
subSpecs: subSpecs.map { $0.resolvingPaths(relativeTo: relativePath) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -117,7 +116,7 @@ extension Dictionary where Key == String, Value: Any {
|
||||
|
||||
for (key, value) in self {
|
||||
if key.hasSuffix(":REPLACE") {
|
||||
let newKey = key[key.startIndex ..< key.index(key.endIndex, offsetBy: -8)]
|
||||
let newKey = key[key.startIndex..<key.index(key.endIndex, offsetBy: -8)]
|
||||
merged[Key(newKey)] = value
|
||||
} else if let dictionary = value as? Dictionary<Key, Value>, let base = merged[key] as? Dictionary<Key, Value> {
|
||||
merged[key] = dictionary.merged(onto: base) as? Value
|
||||
|
@ -48,18 +48,18 @@ func arrayOfBytes<T>(_ value: T, length: Int? = nil) -> [UInt8] {
|
||||
|
||||
let bytes = valuePointer.withMemoryRebound(to: UInt8.self, capacity: totalBytes) { (bytesPointer) -> [UInt8] in
|
||||
var bytes = [UInt8](repeating: 0, count: totalBytes)
|
||||
for j in 0 ..< min(MemoryLayout<T>.size, totalBytes) {
|
||||
for j in 0..<min(MemoryLayout<T>.size, totalBytes) {
|
||||
bytes[totalBytes - 1 - j] = (bytesPointer + j).pointee
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
#if swift(>=4.1)
|
||||
valuePointer.deinitialize(count: 1)
|
||||
valuePointer.deallocate()
|
||||
valuePointer.deinitialize(count: 1)
|
||||
valuePointer.deallocate()
|
||||
#else
|
||||
valuePointer.deinitialize()
|
||||
valuePointer.deallocate(capacity: 1)
|
||||
valuePointer.deinitialize()
|
||||
valuePointer.deallocate(capacity: 1)
|
||||
#endif
|
||||
|
||||
return bytes
|
||||
@ -136,7 +136,7 @@ struct BytesIterator: IteratorProtocol {
|
||||
|
||||
mutating func next() -> ArraySlice<UInt8>? {
|
||||
let end = min(chunkSize, data.count - offset)
|
||||
let result = data[offset ..< offset + end]
|
||||
let result = data[offset..<offset + end]
|
||||
offset += result.count
|
||||
return result.count > 0 ? result : nil
|
||||
}
|
||||
@ -222,24 +222,24 @@ class MD5: HashProtocol {
|
||||
var dTemp: UInt32 = 0
|
||||
|
||||
// Main loop
|
||||
for j in 0 ..< sines.count {
|
||||
for j in 0..<sines.count {
|
||||
var g = 0
|
||||
var F: UInt32 = 0
|
||||
|
||||
switch j {
|
||||
case 0 ... 15:
|
||||
case 0...15:
|
||||
F = (B & C) | ((~B) & D)
|
||||
g = j
|
||||
break
|
||||
case 16 ... 31:
|
||||
case 16...31:
|
||||
F = (D & B) | (~D & C)
|
||||
g = (5 * j + 1) % 16
|
||||
break
|
||||
case 32 ... 47:
|
||||
case 32...47:
|
||||
F = B ^ C ^ D
|
||||
g = (3 * j + 5) % 16
|
||||
break
|
||||
case 48 ... 63:
|
||||
case 48...63:
|
||||
F = C ^ (B | (~D))
|
||||
g = (7 * j) % 16
|
||||
break
|
||||
|
@ -319,11 +319,11 @@ class SourceGenerator {
|
||||
.filter {
|
||||
if $0.isDirectory {
|
||||
let children = try $0.children()
|
||||
|
||||
|
||||
if children.isEmpty {
|
||||
return project.options.generateEmptyDirectories
|
||||
}
|
||||
|
||||
|
||||
return !children.filter(isIncludedPath).isEmpty
|
||||
} else if $0.isFile {
|
||||
return isIncludedPath($0)
|
||||
|
@ -2,6 +2,5 @@ import Foundation
|
||||
|
||||
public struct FrameworkStruct {
|
||||
|
||||
public init() {
|
||||
}
|
||||
public init() {}
|
||||
}
|
||||
|
@ -140,19 +140,19 @@ extension Project {
|
||||
try path.mkpath()
|
||||
paths.append(path)
|
||||
|
||||
for swiftFile in 1 ... swiftFilesPerDirectory {
|
||||
for swiftFile in 1...swiftFilesPerDirectory {
|
||||
let file = path + "file_\(swiftFile).swift"
|
||||
try file.write("")
|
||||
paths.append(file)
|
||||
}
|
||||
|
||||
for resourceFile in 1 ... resourcesPerDirectory {
|
||||
for resourceFile in 1...resourcesPerDirectory {
|
||||
let file = path + "file_\(resourceFile).png"
|
||||
try file.write("")
|
||||
paths.append(file)
|
||||
}
|
||||
|
||||
for objFile in 1 ... objFilesPerDirectory {
|
||||
for objFile in 1...objFilesPerDirectory {
|
||||
let header = path + "file_\(objFile).h"
|
||||
try header.write("")
|
||||
paths.append(header)
|
||||
@ -163,7 +163,7 @@ extension Project {
|
||||
}
|
||||
|
||||
if depth < levels - 1 {
|
||||
for directory in 1 ... directoriesPerLevel {
|
||||
for directory in 1...directoriesPerLevel {
|
||||
try createDirectory(path + "directory_\(directory)", depth: depth + 1)
|
||||
}
|
||||
}
|
||||
|
@ -184,8 +184,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
"staging": ["SETTING1": "VALUE1"],
|
||||
"debug": ["SETTING2": "VALUE2"],
|
||||
"Release": ["SETTING3": "VALUE3"],
|
||||
]
|
||||
)
|
||||
])
|
||||
)
|
||||
|
||||
var buildSettings = project.getProjectBuildSettings(config: project.configs[1])
|
||||
@ -563,12 +562,12 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
type: .stickerPack,
|
||||
platform: .iOS,
|
||||
dependencies: [
|
||||
Dependency(type: .sdk, reference: "NotificationCenter.framework")
|
||||
Dependency(type: .sdk, reference: "NotificationCenter.framework"),
|
||||
]
|
||||
)
|
||||
expectedResourceFiles[stickerPack.name] = nil
|
||||
expectedLinkedFiles[stickerPack.name] = Set([
|
||||
"NotificationCenter.framework"
|
||||
"NotificationCenter.framework",
|
||||
])
|
||||
|
||||
let targets = [app, iosFrameworkZ, staticLibrary, resourceBundle, iosFrameworkA, iosFrameworkB, appTest, appTestWithoutTransitive, stickerPack]
|
||||
|
@ -277,7 +277,7 @@ class SourceGeneratorTests: XCTestCase {
|
||||
]
|
||||
|
||||
let target = Target(name: "Test", type: .application, platform: .iOS, sources: [TargetSource(path: "Sources", excludes: excludes)])
|
||||
|
||||
|
||||
func test(generateEmptyDirectories: Bool) throws {
|
||||
let options = SpecOptions(generateEmptyDirectories: generateEmptyDirectories)
|
||||
let project = Project(basePath: directoryPath, name: "Test", targets: [target], options: options)
|
||||
@ -307,7 +307,7 @@ class SourceGeneratorTests: XCTestCase {
|
||||
// try pbxProj.expectFileMissing(paths: ["Sources", "A", "a.ignored"])
|
||||
// try pbxProj.expectFileMissing(paths: ["Sources", "A", "B", "b.ignored"])
|
||||
}
|
||||
|
||||
|
||||
try test(generateEmptyDirectories: false)
|
||||
try test(generateEmptyDirectories: true)
|
||||
}
|
||||
@ -379,7 +379,7 @@ class SourceGeneratorTests: XCTestCase {
|
||||
"Sources/A/b.swift",
|
||||
"Sources/F/G/h.swift",
|
||||
"../OtherDirectory/C/D/e.swift",
|
||||
TargetSource(path: "Sources/B", createIntermediateGroups: false)
|
||||
TargetSource(path: "Sources/B", createIntermediateGroups: false),
|
||||
])
|
||||
let options = SpecOptions(createIntermediateGroups: true)
|
||||
let project = Project(basePath: directoryPath, name: "Test", targets: [target], options: options)
|
||||
|
@ -347,7 +347,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
"type": "framework",
|
||||
"platform": "tvOS",
|
||||
"deploymentTarget": "1.1.0",
|
||||
"configFiles": ["debug": "Configs/$target_name/debug.xcconfig"]
|
||||
"configFiles": ["debug": "Configs/$target_name/debug.xcconfig"],
|
||||
],
|
||||
],
|
||||
])
|
||||
@ -559,7 +559,7 @@ class SpecLoadingTests: XCTestCase {
|
||||
["script": "shell script\ndo thing", "name": "myscript", "inputFiles": ["file", "file2"], "outputFiles": ["file", "file2"], "shell": "bin/customshell", "runOnlyWhenInstalling": true],
|
||||
["script": "shell script\ndo thing", "name": "myscript", "inputFiles": ["file", "file2"], "outputFiles": ["file", "file2"], "shell": "bin/customshell", "showEnvVars": false],
|
||||
["script": "shell script\nwith file lists", "name": "myscript", "inputFileLists": ["inputList.xcfilelist"], "outputFileLists": ["outputList.xcfilelist"], "shell": "bin/customshell", "runOnlyWhenInstalling": true],
|
||||
["script": "shell script\nwith file lists", "name": "myscript", "inputFileLists": ["inputList.xcfilelist"], "outputFileLists": ["outputList.xcfilelist"], "shell": "bin/customshell", "showEnvVars": false]
|
||||
["script": "shell script\nwith file lists", "name": "myscript", "inputFileLists": ["inputList.xcfilelist"], "outputFileLists": ["outputList.xcfilelist"], "shell": "bin/customshell", "showEnvVars": false],
|
||||
]
|
||||
target["preBuildScripts"] = scripts
|
||||
target["postCompileScripts"] = scripts
|
||||
|
@ -14,7 +14,7 @@ public func firstDifferenceBetweenStrings(_ s1: String, _ s2: String) -> FirstDi
|
||||
|
||||
let lenMin = min(len1, len2)
|
||||
|
||||
for i in 0 ..< lenMin {
|
||||
for i in 0..<lenMin {
|
||||
if (s1 as NSString).character(at: i) != (s2 as NSString).character(at: i) {
|
||||
return .DifferenceAtIndex(i)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user