mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-11-24 09:52:48 +03:00
run swift format for Swift 5.1
This commit is contained in:
parent
7ce43f2657
commit
0e4e08bfc4
@ -1,6 +1,6 @@
|
||||
--exclude .build
|
||||
--exclude .swiftpm
|
||||
--swiftversion 5.0
|
||||
--swiftversion 5.1
|
||||
--disable redundantSelf
|
||||
--disable sortedImports
|
||||
--disable blankLinesAtStartOfScope
|
||||
|
@ -62,8 +62,8 @@ public class Glob: Collection {
|
||||
public let behavior: Behavior
|
||||
public let blacklistedDirectories: [String]
|
||||
var paths = [String]()
|
||||
public var startIndex: Int { return paths.startIndex }
|
||||
public var endIndex: Int { return paths.endIndex }
|
||||
public var startIndex: Int { paths.startIndex }
|
||||
public var endIndex: Int { paths.endIndex }
|
||||
|
||||
/// Initialize a glob
|
||||
///
|
||||
@ -109,13 +109,13 @@ public class Glob: Collection {
|
||||
// MARK: Subscript Support
|
||||
|
||||
public subscript(i: Int) -> String {
|
||||
return paths[i]
|
||||
paths[i]
|
||||
}
|
||||
|
||||
// MARK: Protocol of IndexableBase
|
||||
|
||||
public func index(after i: Int) -> Int {
|
||||
return i + 1
|
||||
i + 1
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
@ -123,7 +123,7 @@ public class Glob: Collection {
|
||||
private var globalFlags = GLOB_TILDE | GLOB_BRACE | GLOB_MARK
|
||||
|
||||
private func executeGlob(pattern: UnsafePointer<CChar>, gt: UnsafeMutablePointer<glob_t>) -> Bool {
|
||||
return glob(pattern, globalFlags, nil, gt) == 0
|
||||
glob(pattern, globalFlags, nil, gt) == 0
|
||||
}
|
||||
|
||||
private func expandGlobstar(pattern: String) -> [String] {
|
||||
@ -171,7 +171,7 @@ public class Glob: Collection {
|
||||
}
|
||||
|
||||
private func exploreDirectories(path: String) throws -> [String] {
|
||||
return try FileManager.default.contentsOfDirectory(atPath: path)
|
||||
try FileManager.default.contentsOfDirectory(atPath: path)
|
||||
.compactMap { subpath -> [String]? in
|
||||
if blacklistedDirectories.contains(subpath) {
|
||||
return nil
|
||||
@ -228,6 +228,6 @@ public class Glob: Collection {
|
||||
|
||||
private extension Sequence {
|
||||
func array() -> [Element] {
|
||||
return Array(self)
|
||||
Array(self)
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func arrayOfBytes<T>(_ value: T, length: Int? = nil) -> [UInt8] {
|
||||
extension Int {
|
||||
/** Array of bytes with optional padding (little-endian) */
|
||||
func bytes(_ totalBytes: Int = MemoryLayout<Int>.size) -> [UInt8] {
|
||||
return arrayOfBytes(self, length: totalBytes)
|
||||
arrayOfBytes(self, length: totalBytes)
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,12 +147,12 @@ struct BytesSequence: Sequence {
|
||||
let data: [UInt8]
|
||||
|
||||
func makeIterator() -> BytesIterator {
|
||||
return BytesIterator(chunkSize: chunkSize, data: data)
|
||||
BytesIterator(chunkSize: chunkSize, data: data)
|
||||
}
|
||||
}
|
||||
|
||||
func rotateLeft(_ value: UInt32, bits: UInt32) -> UInt32 {
|
||||
return ((value << bits) & 0xFFFF_FFFF) | (value >> (32 - bits))
|
||||
((value << bits) & 0xFFFF_FFFF) | (value >> (32 - bits))
|
||||
}
|
||||
|
||||
class MD5: HashProtocol {
|
||||
|
@ -11,7 +11,7 @@ extension Path {
|
||||
/// - `../a/b` simplifies to `../a/b`
|
||||
/// - `a/../../c` simplifies to `../c`
|
||||
public func simplifyingParentDirectoryReferences() -> Path {
|
||||
return normalize().components.reduce(Path(), +)
|
||||
normalize().components.reduce(Path(), +)
|
||||
}
|
||||
|
||||
/// Returns the relative path necessary to go from `base` to `self`.
|
||||
|
@ -32,14 +32,14 @@ public struct AggregateTarget: ProjectTarget {
|
||||
extension AggregateTarget: CustomStringConvertible {
|
||||
|
||||
public var description: String {
|
||||
return "\(name)\(targets.isEmpty ? "" : ": \(targets.joined(separator: ", "))")"
|
||||
"\(name)\(targets.isEmpty ? "" : ": \(targets.joined(separator: ", "))")"
|
||||
}
|
||||
}
|
||||
|
||||
extension AggregateTarget: Equatable {
|
||||
|
||||
public static func == (lhs: AggregateTarget, rhs: AggregateTarget) -> Bool {
|
||||
return lhs.name == rhs.name &&
|
||||
lhs.name == rhs.name &&
|
||||
lhs.targets == rhs.targets &&
|
||||
lhs.settings == rhs.settings &&
|
||||
lhs.configFiles == rhs.configFiles &&
|
||||
@ -64,7 +64,7 @@ extension AggregateTarget: NamedJSONDictionaryConvertible {
|
||||
|
||||
extension AggregateTarget: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"settings": settings.toJSONValue(),
|
||||
"targets": targets,
|
||||
"configFiles": configFiles,
|
||||
@ -78,7 +78,7 @@ extension AggregateTarget: JSONEncodable {
|
||||
extension AggregateTarget: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.dictionary([
|
||||
.string("configFiles"),
|
||||
.object("buildScripts", BuildScript.pathProperties),
|
||||
|
@ -94,7 +94,7 @@ extension BuildScript: JSONEncodable {
|
||||
extension BuildScript: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("path"),
|
||||
]
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ public struct Dependency: Equatable {
|
||||
self.implicit = implicit
|
||||
self.weakLink = weakLink
|
||||
}
|
||||
|
||||
|
||||
public enum CarthageLinkType: String {
|
||||
case dynamic
|
||||
case `static`
|
||||
|
||||
|
||||
public static let `default` = dynamic
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ extension Dependency: JSONEncodable {
|
||||
extension Dependency: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("framework"),
|
||||
]
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ extension Version {
|
||||
|
||||
/// doesn't print patch if 0
|
||||
public var deploymentTarget: String {
|
||||
return "\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")"
|
||||
"\(major).\(minor)\(patch > 0 ? ".\(patch)" : "")"
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ extension DeploymentTarget: JSONObjectConvertible {
|
||||
|
||||
extension DeploymentTarget: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"iOS": iOS?.string,
|
||||
"tvOS": tvOS?.string,
|
||||
"watchOS": watchOS?.string,
|
||||
|
@ -12,7 +12,7 @@ public struct Plist: Equatable {
|
||||
}
|
||||
|
||||
public static func == (lhs: Plist, rhs: Plist) -> Bool {
|
||||
return lhs.path == rhs.path &&
|
||||
lhs.path == rhs.path &&
|
||||
NSDictionary(dictionary: lhs.properties).isEqual(to: rhs.properties)
|
||||
}
|
||||
}
|
||||
@ -27,7 +27,7 @@ extension Plist: JSONObjectConvertible {
|
||||
|
||||
extension Plist: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"path": path,
|
||||
"properties": properties,
|
||||
]
|
||||
@ -37,7 +37,7 @@ extension Plist: JSONEncodable {
|
||||
extension Plist: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("path"),
|
||||
]
|
||||
}
|
||||
|
@ -79,27 +79,27 @@ public struct Project: BuildSettingsContainer {
|
||||
}
|
||||
|
||||
public func getProjectReference(_ projectName: String) -> ProjectReference? {
|
||||
return projectReferencesMap[projectName]
|
||||
projectReferencesMap[projectName]
|
||||
}
|
||||
|
||||
public func getTarget(_ targetName: String) -> Target? {
|
||||
return targetsMap[targetName]
|
||||
targetsMap[targetName]
|
||||
}
|
||||
|
||||
public func getAggregateTarget(_ targetName: String) -> AggregateTarget? {
|
||||
return aggregateTargetsMap[targetName]
|
||||
aggregateTargetsMap[targetName]
|
||||
}
|
||||
|
||||
public func getProjectTarget(_ targetName: String) -> ProjectTarget? {
|
||||
return targetsMap[targetName] ?? aggregateTargetsMap[targetName]
|
||||
targetsMap[targetName] ?? aggregateTargetsMap[targetName]
|
||||
}
|
||||
|
||||
public func getConfig(_ configName: String) -> Config? {
|
||||
return configs.first { $0.name == configName }
|
||||
configs.first { $0.name == configName }
|
||||
}
|
||||
|
||||
public var defaultProjectPath: Path {
|
||||
return basePath + "\(name).xcodeproj"
|
||||
basePath + "\(name).xcodeproj"
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ extension Project: CustomDebugStringConvertible {
|
||||
extension Project: Equatable {
|
||||
|
||||
public static func == (lhs: Project, rhs: Project) -> Bool {
|
||||
return lhs.name == rhs.name &&
|
||||
lhs.name == rhs.name &&
|
||||
lhs.targets == rhs.targets &&
|
||||
lhs.aggregateTargets == rhs.aggregateTargets &&
|
||||
lhs.settings == rhs.settings &&
|
||||
@ -216,7 +216,7 @@ extension Project {
|
||||
extension Project: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("configFiles"),
|
||||
.string("localPackages"),
|
||||
.object("options", SpecOptions.pathProperties),
|
||||
@ -259,13 +259,13 @@ extension Project {
|
||||
extension BuildSettingsContainer {
|
||||
|
||||
fileprivate var configFilePaths: [Path] {
|
||||
return configFiles.values.map { Path($0) }
|
||||
configFiles.values.map { Path($0) }
|
||||
}
|
||||
}
|
||||
|
||||
extension Project: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return toJSONDictionary()
|
||||
toJSONDictionary()
|
||||
}
|
||||
|
||||
public func toJSONDictionary() -> JSONDictionary {
|
||||
|
@ -20,7 +20,7 @@ extension ProjectReference: NamedJSONDictionaryConvertible {
|
||||
|
||||
extension ProjectReference: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"path": path,
|
||||
]
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ public protocol ProjectTarget: BuildSettingsContainer {
|
||||
extension Target {
|
||||
|
||||
public var buildScripts: [BuildScript] {
|
||||
return preBuildScripts + postCompileScripts + postBuildScripts
|
||||
preBuildScripts + postCompileScripts + postBuildScripts
|
||||
}
|
||||
}
|
||||
|
||||
extension Project {
|
||||
|
||||
public var projectTargets: [ProjectTarget] {
|
||||
return targets.map { $0 as ProjectTarget } + aggregateTargets.map { $0 as ProjectTarget }
|
||||
targets.map { $0 as ProjectTarget } + aggregateTargets.map { $0 as ProjectTarget }
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ public struct Scheme: Equatable {
|
||||
public static let randomExecutionOrderDefault = false
|
||||
public static let parallelizableDefault = false
|
||||
|
||||
public var name: String { return targetReference.name }
|
||||
public var name: String { targetReference.name }
|
||||
public let targetReference: TargetReference
|
||||
public var randomExecutionOrder: Bool
|
||||
public var parallelizable: Bool
|
||||
@ -187,7 +187,7 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public var shouldUseLaunchSchemeArgsEnv: Bool {
|
||||
return commandLineArguments.isEmpty && environmentVariables.isEmpty
|
||||
commandLineArguments.isEmpty && environmentVariables.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ public struct Scheme: Equatable {
|
||||
}
|
||||
|
||||
public var shouldUseLaunchSchemeArgsEnv: Bool {
|
||||
return commandLineArguments.isEmpty && environmentVariables.isEmpty
|
||||
commandLineArguments.isEmpty && environmentVariables.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ extension Scheme.ExecutionAction: JSONObjectConvertible {
|
||||
|
||||
extension Scheme.ExecutionAction: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"script": script,
|
||||
"name": name,
|
||||
"settingsTarget": settingsTarget,
|
||||
@ -423,7 +423,7 @@ extension Scheme.Profile: JSONObjectConvertible {
|
||||
|
||||
extension Scheme.Profile: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"commandLineArguments": commandLineArguments,
|
||||
"preActions": preActions.map { $0.toJSONValue() },
|
||||
"postActions": postActions.map { $0.toJSONValue() },
|
||||
@ -442,7 +442,7 @@ extension Scheme.Analyze: JSONObjectConvertible {
|
||||
|
||||
extension Scheme.Analyze: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"config": config,
|
||||
]
|
||||
}
|
||||
@ -491,7 +491,7 @@ extension Scheme: NamedJSONDictionaryConvertible {
|
||||
|
||||
extension Scheme: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"build": build.toJSONValue(),
|
||||
"run": run?.toJSONValue(),
|
||||
"test": test?.toJSONValue(),
|
||||
@ -572,7 +572,7 @@ extension BuildType: JSONPrimitiveConvertible {
|
||||
}
|
||||
|
||||
public static var all: [BuildType] {
|
||||
return [.running, .testing, .profiling, .analyzing, .archiving]
|
||||
[.running, .testing, .profiling, .analyzing, .archiving]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public struct Settings: Equatable, JSONObjectConvertible, CustomStringConvertibl
|
||||
}
|
||||
|
||||
public static func == (lhs: Settings, rhs: Settings) -> Bool {
|
||||
return NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) &&
|
||||
NSDictionary(dictionary: lhs.buildSettings).isEqual(to: rhs.buildSettings) &&
|
||||
lhs.configSettings == rhs.configSettings &&
|
||||
lhs.groups == rhs.groups
|
||||
}
|
||||
@ -97,7 +97,7 @@ extension Dictionary where Key == String, Value: Any {
|
||||
}
|
||||
|
||||
public func equals(_ dictionary: BuildSettings) -> Bool {
|
||||
return NSDictionary(dictionary: self).isEqual(to: dictionary)
|
||||
NSDictionary(dictionary: self).isEqual(to: dictionary)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public struct SpecFile {
|
||||
}
|
||||
|
||||
public func resolvedDictionary(variables: [String: String] = [:]) -> JSONDictionary {
|
||||
return resolvedDictionaryWithUniqueTargets().expand(variables: variables)
|
||||
resolvedDictionaryWithUniqueTargets().expand(variables: variables)
|
||||
}
|
||||
|
||||
private func resolvedDictionaryWithUniqueTargets() -> JSONDictionary {
|
||||
|
@ -53,7 +53,7 @@ private extension Dictionary where Key == String, Value: Any {
|
||||
}
|
||||
|
||||
func hasValueContaining(_ needle: String) -> Bool {
|
||||
return values.contains { value in
|
||||
values.contains { value in
|
||||
switch value {
|
||||
case let dictionary as JSONDictionary:
|
||||
return dictionary.hasValueContaining(needle)
|
||||
|
@ -176,7 +176,7 @@ extension SpecOptions: JSONEncodable {
|
||||
extension SpecOptions: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("carthageBuildPath"),
|
||||
]
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public struct Target: ProjectTarget {
|
||||
public var productName: String
|
||||
|
||||
public var isLegacy: Bool {
|
||||
return legacy != nil
|
||||
legacy != nil
|
||||
}
|
||||
|
||||
public var filename: String {
|
||||
@ -108,14 +108,14 @@ public struct Target: ProjectTarget {
|
||||
extension Target: CustomStringConvertible {
|
||||
|
||||
public var description: String {
|
||||
return "\(name): \(platform.rawValue) \(type)"
|
||||
"\(name): \(platform.rawValue) \(type)"
|
||||
}
|
||||
}
|
||||
|
||||
extension Target: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.dictionary([
|
||||
.string("sources"),
|
||||
.object("sources", TargetSource.pathProperties),
|
||||
@ -188,7 +188,7 @@ extension Target {
|
||||
extension Target: Equatable {
|
||||
|
||||
public static func == (lhs: Target, rhs: Target) -> Bool {
|
||||
return lhs.name == rhs.name &&
|
||||
lhs.name == rhs.name &&
|
||||
lhs.type == rhs.type &&
|
||||
lhs.platform == rhs.platform &&
|
||||
lhs.deploymentTarget == rhs.deploymentTarget &&
|
||||
|
@ -32,7 +32,7 @@ extension TargetReference {
|
||||
}
|
||||
|
||||
public static func local(_ name: String) -> TargetReference {
|
||||
return TargetReference(name: name, location: .local)
|
||||
TargetReference(name: name, location: .local)
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,6 @@ extension TargetReference: CustomStringConvertible {
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return reference
|
||||
reference
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONObjectConvertible {
|
||||
|
||||
extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable {
|
||||
public func toJSONValue() -> Any {
|
||||
return [
|
||||
[
|
||||
"destination": destination.rawValue,
|
||||
"subpath": subpath,
|
||||
]
|
||||
@ -277,7 +277,7 @@ extension TargetSource.BuildPhase.CopyFilesSettings: JSONEncodable {
|
||||
extension TargetSource: PathContainer {
|
||||
|
||||
static var pathProperties: [PathProperty] {
|
||||
return [
|
||||
[
|
||||
.string("path"),
|
||||
]
|
||||
}
|
||||
|
@ -9,19 +9,19 @@ struct TemplateStructure {
|
||||
|
||||
extension Target {
|
||||
static func resolveTargetTemplates(jsonDictionary: JSONDictionary) -> JSONDictionary {
|
||||
return resolveTemplates(jsonDictionary: jsonDictionary,
|
||||
templateStructure: TemplateStructure(baseKey: "targets",
|
||||
templatesKey: "targetTemplates",
|
||||
nameToReplace: "target_name"))
|
||||
resolveTemplates(jsonDictionary: jsonDictionary,
|
||||
templateStructure: TemplateStructure(baseKey: "targets",
|
||||
templatesKey: "targetTemplates",
|
||||
nameToReplace: "target_name"))
|
||||
}
|
||||
}
|
||||
|
||||
extension Scheme {
|
||||
static func resolveSchemeTemplates(jsonDictionary: JSONDictionary) -> JSONDictionary {
|
||||
return resolveTemplates(jsonDictionary: jsonDictionary,
|
||||
templateStructure: TemplateStructure(baseKey: "schemes",
|
||||
templatesKey: "schemeTemplates",
|
||||
nameToReplace: "scheme_name"))
|
||||
resolveTemplates(jsonDictionary: jsonDictionary,
|
||||
templateStructure: TemplateStructure(baseKey: "schemes",
|
||||
templatesKey: "schemeTemplates",
|
||||
nameToReplace: "scheme_name"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,23 +38,23 @@ public struct Version: CustomStringConvertible, Equatable, Comparable, Expressib
|
||||
}
|
||||
|
||||
public var string: String {
|
||||
return "\(major).\(minor).\(patch)"
|
||||
"\(major).\(minor).\(patch)"
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
return string
|
||||
string
|
||||
}
|
||||
|
||||
public func bumpingMajor() -> Version {
|
||||
return Version(major: major + 1, minor: 0, patch: 0)
|
||||
Version(major: major + 1, minor: 0, patch: 0)
|
||||
}
|
||||
|
||||
public func bumpingMinor() -> Version {
|
||||
return Version(major: major, minor: minor + 1, patch: 0)
|
||||
Version(major: major, minor: minor + 1, patch: 0)
|
||||
}
|
||||
|
||||
public func bumpingPatch() -> Version {
|
||||
return Version(major: major, minor: minor, patch: patch + 1)
|
||||
Version(major: major, minor: minor, patch: patch + 1)
|
||||
}
|
||||
|
||||
public static func < (lhs: Version, rhs: Version) -> Bool {
|
||||
|
@ -15,31 +15,31 @@ extension PBXProductType {
|
||||
}
|
||||
|
||||
public var isFramework: Bool {
|
||||
return self == .framework || self == .staticFramework
|
||||
self == .framework || self == .staticFramework
|
||||
}
|
||||
|
||||
public var isLibrary: Bool {
|
||||
return self == .staticLibrary || self == .dynamicLibrary
|
||||
self == .staticLibrary || self == .dynamicLibrary
|
||||
}
|
||||
|
||||
public var isExtension: Bool {
|
||||
return fileExtension == "appex"
|
||||
fileExtension == "appex"
|
||||
}
|
||||
|
||||
public var isApp: Bool {
|
||||
return fileExtension == "app"
|
||||
fileExtension == "app"
|
||||
}
|
||||
|
||||
public var isTest: Bool {
|
||||
return fileExtension == "xctest"
|
||||
fileExtension == "xctest"
|
||||
}
|
||||
|
||||
public var isExecutable: Bool {
|
||||
return isApp || isExtension || isTest || self == .commandLineTool
|
||||
isApp || isExtension || isTest || self == .commandLineTool
|
||||
}
|
||||
|
||||
public var name: String {
|
||||
return rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "")
|
||||
rawValue.replacingOccurrences(of: "com.apple.product-type.", with: "")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ open class ArrayExpectation<T>: ExpectationType {
|
||||
let function: String
|
||||
|
||||
open var to: ArrayExpectation<T> {
|
||||
return self
|
||||
self
|
||||
}
|
||||
|
||||
init(file: String, line: Int, function: String, expression: @escaping () throws -> ValueType?) {
|
||||
@ -61,12 +61,12 @@ open class ArrayExpectation<T>: ExpectationType {
|
||||
}
|
||||
|
||||
open func failure(_ reason: String) -> FailureType {
|
||||
return ExpectationFailure(reason: reason, file: file, line: line, function: function)
|
||||
ExpectationFailure(reason: reason, file: file, line: line, function: function)
|
||||
}
|
||||
}
|
||||
|
||||
public func expect<T>(_ expression: @autoclosure @escaping () throws -> [T]?, file: String = #file, line: Int = #line, function: String = #function) -> ArrayExpectation<T> {
|
||||
return ArrayExpectation(file: file, line: line, function: function, expression: expression)
|
||||
ArrayExpectation(file: file, line: line, function: function, expression: expression)
|
||||
}
|
||||
|
||||
extension ArrayExpectation {
|
||||
|
@ -5,6 +5,6 @@ import SwiftCLI
|
||||
extension Path: ConvertibleFromString {
|
||||
|
||||
public static func convert(from: String) -> Path? {
|
||||
return Path(from)
|
||||
Path(from)
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,7 @@ class DumpCommand: ProjectCommand {
|
||||
init(version: Version) {
|
||||
super.init(version: version,
|
||||
name: "dump",
|
||||
shortDescription: "Dumps the resolved project spec to stdout or a file"
|
||||
)
|
||||
shortDescription: "Dumps the resolved project spec to stdout or a file")
|
||||
}
|
||||
|
||||
override func execute(specLoader: SpecLoader, projectSpecPath: Path, project: Project) throws {
|
||||
|
@ -35,8 +35,7 @@ class GenerateCommand: ProjectCommand {
|
||||
init(version: Version) {
|
||||
super.init(version: version,
|
||||
name: "generate",
|
||||
shortDescription: "Generate an Xcode project from a spec"
|
||||
)
|
||||
shortDescription: "Generate an Xcode project from a spec")
|
||||
}
|
||||
|
||||
override func execute(specLoader: SpecLoader, projectSpecPath: Path, project: Project) throws {
|
||||
|
@ -30,10 +30,10 @@ enum GenerationError: Error, CustomStringConvertible, ProcessError {
|
||||
}
|
||||
|
||||
var message: String? {
|
||||
return description.red
|
||||
description.red
|
||||
}
|
||||
|
||||
var exitStatus: Int32 {
|
||||
return 1
|
||||
1
|
||||
}
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ public class CarthageDependencyResolver {
|
||||
/// Carthage's base build path as specified by the
|
||||
/// project's `SpecOptions`, or `Carthage/Build` by default
|
||||
var buildPath: String {
|
||||
return project.options.carthageBuildPath ?? "Carthage/Build"
|
||||
project.options.carthageBuildPath ?? "Carthage/Build"
|
||||
}
|
||||
|
||||
/// Carthage's executable path as specified by the
|
||||
/// project's `SpecOptions`, or `carthage` by default
|
||||
var executable: String {
|
||||
return project.options.carthageExecutablePath ?? "carthage"
|
||||
project.options.carthageExecutablePath ?? "carthage"
|
||||
}
|
||||
|
||||
private let project: Project
|
||||
|
@ -52,12 +52,12 @@ struct CarthageVersionFile: Decodable {
|
||||
extension Platform: CodingKey {
|
||||
|
||||
public var stringValue: String {
|
||||
return carthageName
|
||||
carthageName
|
||||
}
|
||||
}
|
||||
|
||||
extension CarthageVersionFile {
|
||||
func frameworks(for platform: Platform) -> [String] {
|
||||
return data[platform] ?? []
|
||||
data[platform] ?? []
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ public class PBXProjGenerator {
|
||||
let fileReference = self.sourceGenerator.getFileReference(path: frameworkPath, inPath: platformPath)
|
||||
|
||||
self.carthageFrameworksByPlatform[target.platform.carthageName, default: []].insert(fileReference)
|
||||
|
||||
|
||||
if dependency.link ?? (target.type != .staticLibrary) {
|
||||
let buildFile = self.addObject(
|
||||
PBXBuildFile(file: fileReference, settings: getDependencyFrameworkSettings(dependency: dependency))
|
||||
@ -651,7 +651,7 @@ public class PBXProjGenerator {
|
||||
}
|
||||
|
||||
for dependency in carthageDependencies {
|
||||
|
||||
|
||||
let embed = dependency.embed ?? target.shouldEmbedCarthageDependencies
|
||||
|
||||
var platformPath = Path(carthageResolver.buildPath(for: target.platform, linkType: dependency.carthageLinkType ?? .default))
|
||||
@ -681,7 +681,7 @@ public class PBXProjGenerator {
|
||||
var buildPhases: [PBXBuildPhase] = []
|
||||
|
||||
func getBuildFilesForSourceFiles(_ sourceFiles: [SourceFile]) -> [PBXBuildFile] {
|
||||
return sourceFiles
|
||||
sourceFiles
|
||||
.reduce(into: [SourceFile]()) { output, sourceFile in
|
||||
if !output.contains(where: { $0.fileReference === sourceFile.fileReference }) {
|
||||
output.append(sourceFile)
|
||||
@ -993,7 +993,7 @@ public class PBXProjGenerator {
|
||||
}
|
||||
|
||||
func getInfoPlist(_ sources: [TargetSource]) -> Path? {
|
||||
return sources
|
||||
sources
|
||||
.lazy
|
||||
.map { self.project.basePath + $0.path }
|
||||
.compactMap { (path) -> Path? in
|
||||
@ -1060,11 +1060,11 @@ public class PBXProjGenerator {
|
||||
extension Target {
|
||||
|
||||
var shouldEmbedDependencies: Bool {
|
||||
return type.isApp || type.isTest
|
||||
type.isApp || type.isTest
|
||||
}
|
||||
|
||||
var shouldEmbedCarthageDependencies: Bool {
|
||||
return (type.isApp && platform != .watchOS)
|
||||
(type.isApp && platform != .watchOS)
|
||||
|| type == .watch2Extension
|
||||
|| type.isTest
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ public class SchemeGenerator {
|
||||
let pbxProj: PBXProj
|
||||
|
||||
var defaultDebugConfig: Config {
|
||||
return project.configs.first { $0.type == .debug }!
|
||||
project.configs.first { $0.type == .debug }!
|
||||
}
|
||||
|
||||
var defaultReleaseConfig: Config {
|
||||
return project.configs.first { $0.type == .release }!
|
||||
project.configs.first { $0.type == .release }!
|
||||
}
|
||||
|
||||
public init(project: Project, pbxProj: PBXProj) {
|
||||
|
@ -115,7 +115,7 @@ extension Project {
|
||||
}
|
||||
|
||||
public func targetHasBuildSetting(_ setting: String, target: Target, config: Config) -> Bool {
|
||||
return getCombinedBuildSetting(setting, target: target, config: config) != nil
|
||||
getCombinedBuildSetting(setting, target: target, config: config) != nil
|
||||
}
|
||||
|
||||
/// Removes values from build settings if they are defined in an xcconfig file
|
||||
|
@ -72,7 +72,7 @@ class SourceGenerator {
|
||||
}
|
||||
|
||||
func getAllSourceFiles(targetType: PBXProductType, sources: [TargetSource]) throws -> [SourceFile] {
|
||||
return try sources.flatMap { try getSourceFiles(targetType: targetType, targetSource: $0, path: project.basePath + $0.path) }
|
||||
try sources.flatMap { try getSourceFiles(targetType: targetType, targetSource: $0, path: project.basePath + $0.path) }
|
||||
}
|
||||
|
||||
// get groups without build files. Use for Project.fileGroups
|
||||
@ -354,7 +354,7 @@ class SourceGenerator {
|
||||
|
||||
/// Checks whether the path is not in any default or TargetSource excludes
|
||||
func isIncludedPath(_ path: Path, excludePaths: Set<Path>, includePaths: Set<Path>) -> Bool {
|
||||
return !defaultExcludedFiles.contains(where: { path.lastComponent.contains($0) })
|
||||
!defaultExcludedFiles.contains(where: { path.lastComponent.contains($0) })
|
||||
&& !(path.extension.map(defaultExcludedExtensions.contains) ?? false)
|
||||
&& !excludePaths.contains(path)
|
||||
// If includes is empty, it's included. If it's not empty, the path either needs to match exactly, or it needs to be a direct parent of an included path.
|
||||
@ -366,7 +366,7 @@ class SourceGenerator {
|
||||
|
||||
/// Gets all the children paths that aren't excluded
|
||||
private func getSourceChildren(targetSource: TargetSource, dirPath: Path, excludePaths: Set<Path>, includePaths: Set<Path>) throws -> [Path] {
|
||||
return try dirPath.children()
|
||||
try dirPath.children()
|
||||
.filter {
|
||||
if $0.isDirectory {
|
||||
let children = try $0.children()
|
||||
@ -432,7 +432,7 @@ class SourceGenerator {
|
||||
// find the base localised directory
|
||||
let baseLocalisedDirectory: Path? = {
|
||||
func findLocalisedDirectory(by languageId: String) -> Path? {
|
||||
return localisedDirectories.first { $0.lastComponent == "\(languageId).lproj" }
|
||||
localisedDirectories.first { $0.lastComponent == "\(languageId).lproj" }
|
||||
}
|
||||
return findLocalisedDirectory(by: "Base") ??
|
||||
findLocalisedDirectory(by: NSLocale.canonicalLanguageIdentifier(from: project.options.developmentLanguage ?? "en"))
|
||||
|
@ -4,19 +4,19 @@ import ProjectSpec
|
||||
extension Project {
|
||||
|
||||
var xcodeVersion: String {
|
||||
return XCodeVersion.parse(options.xcodeVersion ?? "10.2")
|
||||
XCodeVersion.parse(options.xcodeVersion ?? "10.2")
|
||||
}
|
||||
|
||||
var schemeVersion: String {
|
||||
return "1.3"
|
||||
"1.3"
|
||||
}
|
||||
|
||||
var compatibilityVersion: String {
|
||||
return "Xcode 10.0"
|
||||
"Xcode 10.0"
|
||||
}
|
||||
|
||||
var objectVersion: UInt {
|
||||
return 51
|
||||
51
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import XcodeProj
|
||||
extension PBXFileElement {
|
||||
|
||||
public var nameOrPath: String {
|
||||
return name ?? path ?? ""
|
||||
name ?? path ?? ""
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ extension PBXProj {
|
||||
extension Dictionary {
|
||||
|
||||
public var valueArray: [Value] {
|
||||
return Array(values)
|
||||
Array(values)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ class PathExtensionsTests: XCTestCase {
|
||||
|
||||
func testPathRelativeToPath() {
|
||||
func relativePath(to path: String, from base: String) throws -> String {
|
||||
return try Path(path).relativePath(from: Path(base)).string
|
||||
try Path(path).relativePath(from: Path(base)).string
|
||||
}
|
||||
|
||||
// These are based on ruby's tests for Pathname#relative_path_from:
|
||||
|
@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
func nested() -> String {
|
||||
return "Nested"
|
||||
"Nested"
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
func standaloneHello() -> String {
|
||||
return "Hello"
|
||||
"Hello"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
public struct SLSwift {
|
||||
public func description() -> String {
|
||||
return "Hello, World!"
|
||||
"Hello, World!"
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,6 @@ class CarthageDependencyResolverTests: XCTestCase {
|
||||
}
|
||||
|
||||
private func makeTestProject(with targets: [Target] = [], options: SpecOptions = SpecOptions()) -> Project {
|
||||
return Project(name: "Test Project", targets: targets, options: options)
|
||||
Project(name: "Test Project", targets: targets, options: options)
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import TestSupport
|
||||
extension Project {
|
||||
|
||||
func generateXcodeProject(validate: Bool = true, file: String = #file, line: Int = #line) throws -> XcodeProj {
|
||||
return try doThrowing(file: file, line: line) {
|
||||
try doThrowing(file: file, line: line) {
|
||||
if validate {
|
||||
try self.validate()
|
||||
}
|
||||
@ -20,7 +20,7 @@ extension Project {
|
||||
}
|
||||
|
||||
func generatePbxProj(specValidate: Bool = true, projectValidate: Bool = true, file: String = #file, line: Int = #line) throws -> PBXProj {
|
||||
return try doThrowing(file: file, line: line) {
|
||||
try doThrowing(file: file, line: line) {
|
||||
let xcodeProject = try generateXcodeProject(validate: specValidate).pbxproj
|
||||
if projectValidate {
|
||||
try xcodeProject.validate()
|
||||
|
@ -1004,7 +1004,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
// generated plist should not be in buildsettings
|
||||
try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == predefinedPlistPath
|
||||
}
|
||||
|
||||
|
||||
describe("Carthage dependencies") {
|
||||
$0.context("with static dependency") {
|
||||
$0.it("should set dependencies") {
|
||||
@ -1018,7 +1018,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
)
|
||||
let project = Project(name: "test", targets: [app])
|
||||
let pbxProject = try project.generatePbxProj()
|
||||
|
||||
|
||||
let target = pbxProject.nativeTargets.first!
|
||||
let configuration = target.buildConfigurationList!.buildConfigurations.first!
|
||||
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static"]
|
||||
@ -1027,11 +1027,11 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
return XCTFail("frameworkBuildPhase should have files")
|
||||
}
|
||||
try expect(file.file?.nameOrPath) == "MyStaticFramework.framework"
|
||||
|
||||
|
||||
try expect(target.carthageCopyFrameworkBuildPhase).beNil()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$0.context("with mixed dependencies") {
|
||||
$0.it("should set dependencies") {
|
||||
let app = Target(
|
||||
@ -1045,7 +1045,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
)
|
||||
let project = Project(name: "test", targets: [app])
|
||||
let pbxProject = try project.generatePbxProj()
|
||||
|
||||
|
||||
let target = pbxProject.nativeTargets.first!
|
||||
let configuration = target.buildConfigurationList!.buildConfigurations.first!
|
||||
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static", "$(PROJECT_DIR)/Carthage/Build/iOS"]
|
||||
@ -1059,7 +1059,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
guard let _ = files.first(where: { $0.file?.nameOrPath == "MyStaticFramework.framework" }) else {
|
||||
return XCTFail("Framework Build Phase should have Static Framework")
|
||||
}
|
||||
|
||||
|
||||
guard let copyCarthagePhase = target.carthageCopyFrameworkBuildPhase else {
|
||||
return XCTFail("Carthage Build Phase should be exist")
|
||||
}
|
||||
@ -1144,7 +1144,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
describe("Carthage dependencies") {
|
||||
$0.context("with static dependency") {
|
||||
$0.it("should set dependencies") {
|
||||
@ -1158,7 +1158,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
)
|
||||
let project = Project(name: "test", targets: [app])
|
||||
let pbxProject = try project.generatePbxProj()
|
||||
|
||||
|
||||
let target = pbxProject.nativeTargets.first!
|
||||
let configuration = target.buildConfigurationList!.buildConfigurations.first!
|
||||
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static"]
|
||||
@ -1167,11 +1167,11 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
return XCTFail("frameworkBuildPhase should have files")
|
||||
}
|
||||
try expect(file.file?.nameOrPath) == "MyStaticFramework.framework"
|
||||
|
||||
|
||||
try expect(target.carthageCopyFrameworkBuildPhase).beNil()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$0.context("with mixed dependencies") {
|
||||
$0.it("should set dependencies") {
|
||||
let app = Target(
|
||||
@ -1185,7 +1185,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
)
|
||||
let project = Project(name: "test", targets: [app])
|
||||
let pbxProject = try project.generatePbxProj()
|
||||
|
||||
|
||||
let target = pbxProject.nativeTargets.first!
|
||||
let configuration = target.buildConfigurationList!.buildConfigurations.first!
|
||||
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "$(PROJECT_DIR)/Carthage/Build/iOS/Static", "$(PROJECT_DIR)/Carthage/Build/iOS"]
|
||||
@ -1199,7 +1199,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
guard let _ = files.first(where: { $0.file?.nameOrPath == "MyStaticFramework.framework" }) else {
|
||||
return XCTFail("Framework Build Phase should have Static Framework")
|
||||
}
|
||||
|
||||
|
||||
guard let copyCarthagePhase = target.carthageCopyFrameworkBuildPhase else {
|
||||
return XCTFail("Carthage Build Phase should be exist")
|
||||
}
|
||||
@ -1214,6 +1214,6 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
|
||||
private extension PBXTarget {
|
||||
var carthageCopyFrameworkBuildPhase: PBXShellScriptBuildPhase? {
|
||||
return buildPhases.first(where: { $0.name() == "Carthage" }) as? PBXShellScriptBuildPhase
|
||||
buildPhases.first(where: { $0.name() == "Carthage" }) as? PBXShellScriptBuildPhase
|
||||
}
|
||||
}
|
||||
|
@ -142,11 +142,11 @@ class SourceGeneratorTests: XCTestCase {
|
||||
let pbxProj = try project.generatePbxProj()
|
||||
|
||||
func getFileReferences(_ path: String) -> [PBXFileReference] {
|
||||
return pbxProj.fileReferences.filter { $0.path == path }
|
||||
pbxProj.fileReferences.filter { $0.path == path }
|
||||
}
|
||||
|
||||
func getVariableGroups(_ name: String?) -> [PBXVariantGroup] {
|
||||
return pbxProj.variantGroups.filter { $0.name == name }
|
||||
pbxProj.variantGroups.filter { $0.name == name }
|
||||
}
|
||||
|
||||
let resourceName = "LocalizedStoryboard.storyboard"
|
||||
@ -199,11 +199,11 @@ class SourceGeneratorTests: XCTestCase {
|
||||
let pbxProj = inputXcodeProj.pbxproj
|
||||
|
||||
func getFileReferences(_ path: String) -> [PBXFileReference] {
|
||||
return pbxProj.fileReferences.filter { $0.path == path }
|
||||
pbxProj.fileReferences.filter { $0.path == path }
|
||||
}
|
||||
|
||||
func getVariableGroups(_ name: String?) -> [PBXVariantGroup] {
|
||||
return pbxProj.variantGroups.filter { $0.name == name }
|
||||
pbxProj.variantGroups.filter { $0.name == name }
|
||||
}
|
||||
|
||||
let stringsResourceName = "Localizable.strings"
|
||||
|
Loading…
Reference in New Issue
Block a user