Skip to content

Commit 5eae2a6

Browse files
committedOct 20, 2020
Addressed other swiftlint warnings
1 parent ec48450 commit 5eae2a6

8 files changed

+47
-16
lines changed
 

‎.swiftlint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ disabled_rules:
33
- object_literal
44
- prefixed_toplevel_constant
55
- todo
6+
- let_var_whitespace
67
- type_name
78
- vertical_whitespace
89

@@ -28,7 +29,6 @@ opt_in_rules:
2829
- last_where
2930
- legacy_multiple
3031
- legacy_random
31-
- let_var_whitespace
3232
- literal_expression_end_indentation
3333
- lower_acl_than_parent
3434
- modifier_order

‎Sources/CreateXCFramework/Command+Options.swift

+15-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ extension Command {
3737

3838
// MARK: - Output Options
3939

40-
@Option(help: ArgumentHelp("A list of platforms you want to build for. Can be specified multiple times. Default is to build for all platforms supported in your Package.swift, or all Apple platforms if omitted", valueName: TargetPlatform.allCases.map({ $0.rawValue }).joined(separator: "|")))
40+
@Option (
41+
help: ArgumentHelp (
42+
"A list of platforms you want to build for. Can be specified multiple times."
43+
+ " Default is to build for all platforms supported in your Package.swift, or all Apple platforms if omitted",
44+
valueName: TargetPlatform.allCases.map({ $0.rawValue }).joined(separator: "|")
45+
)
46+
)
4147
var platform: [TargetPlatform]
4248

4349
@Option(help: ArgumentHelp("Where to place the compiled .xcframework(s)", valueName: "directory"))
@@ -46,7 +52,14 @@ extension Command {
4652
@Flag(help: "Whether to wrap the .xcframework(s) up in a versioned zip file ready for deployment")
4753
var zip = false
4854

49-
@Option(help: ArgumentHelp("The version number to append to the name of the zip file\n\nIf the target you are packaging is a dependency, swift-create-xcframework will look into the package graph and locate the version number the dependency resolved to. As there is no standard way to specify the version inside your Swift Package, --zip-version lets you specify it manually.", valueName: "version"))
55+
@Option (
56+
help: ArgumentHelp (
57+
"The version number to append to the name of the zip file\n\nIf the target you are packaging is a dependency,"
58+
+ " swift-create-xcframework will look into the package graph and locate the version number the dependency resolved to."
59+
+ " As there is no standard way to specify the version inside your Swift Package, --zip-version lets you specify it manually.",
60+
valueName: "version"
61+
)
62+
)
5063
var zipVersion: String?
5164

5265
@Flag(help: .hidden)

‎Sources/CreateXCFramework/Extensions/PackageModel+Extensions.swift

-2
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ extension Manifest {
2525
}
2626
}
2727
}
28-
29-

‎Sources/CreateXCFramework/PackageInfo.swift

+23-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import ArgumentParser
99
import Build
1010
import Foundation
11-
import PackageModel
1211
import PackageLoading
12+
import PackageModel
1313
import SPMBuildCore
1414
import Workspace
1515
import Xcodeproj
@@ -74,9 +74,22 @@ struct PackageInfo {
7474
let loader = ManifestLoader(manifestResources: resources)
7575
self.workspace = Workspace.create(forRootPackage: root, manifestLoader: loader)
7676

77-
self.package = try PackageBuilder.loadPackage(packagePath: root, swiftCompiler: self.toolchain.swiftCompiler, swiftCompilerFlags: self.toolchain.extraSwiftCFlags, xcTestMinimumDeploymentTargets: [:], diagnostics: self.diagnostics)
77+
self.package = try PackageBuilder.loadPackage (
78+
packagePath: root,
79+
swiftCompiler: self.toolchain.swiftCompiler,
80+
swiftCompilerFlags: self.toolchain.extraSwiftCFlags,
81+
xcTestMinimumDeploymentTargets: [:],
82+
diagnostics: self.diagnostics
83+
)
84+
7885
self.graph = self.workspace.loadPackageGraph(root: root, diagnostics: self.diagnostics)
79-
self.manifest = try ManifestLoader.loadManifest(packagePath: root, swiftCompiler: self.toolchain.swiftCompiler, swiftCompilerFlags: self.toolchain.extraSwiftCFlags, packageKind: .root)
86+
87+
self.manifest = try ManifestLoader.loadManifest (
88+
packagePath: root,
89+
swiftCompiler: self.toolchain.swiftCompiler,
90+
swiftCompilerFlags: self.toolchain.extraSwiftCFlags,
91+
packageKind: .root
92+
)
8093
}
8194

8295

@@ -93,10 +106,15 @@ struct PackageInfo {
93106
}
94107

95108
// validation
96-
guard productNames.isEmpty == false else { throw ValidationError("No products to create frameworks for were found. Add library products to Package.swift or specify products/targets on the command line.") }
109+
guard productNames.isEmpty == false else {
110+
throw ValidationError (
111+
"No products to create frameworks for were found. Add library products to Package.swift"
112+
+ " or specify products/targets on the command line."
113+
)
114+
}
97115

98116
let xcodeTargetNames = project.frameworkTargets.map { $0.name }
99-
let invalidProducts = productNames.filter { xcodeTargetNames.contains($0) == false}
117+
let invalidProducts = productNames.filter { xcodeTargetNames.contains($0) == false }
100118
guard invalidProducts.isEmpty == true else {
101119

102120
let allLibraryProductNames = self.package.manifest.libraryProductNames

‎Sources/CreateXCFramework/Platforms.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ enum TargetPlatform: String, ExpressibleByArgument, CaseIterable {
4242
case .tvos:
4343
return [
4444
SDK(sdkName: "appletvos", directorySuffix: "-appletvos"),
45-
SDK(sdkName: "appletvsimulator", directorySuffix: "-appletvsimulator"),
45+
SDK(sdkName: "appletvsimulator", directorySuffix: "-appletvsimulator")
4646
]
4747

4848
case .watchos:

‎Sources/CreateXCFramework/ProjectGenerator.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ extension Xcode.Project {
124124
///// directory that Xcode project is generated
125125
let name = "\(target.name.spm_mangledToC99ExtendedIdentifier())_Info.plist"
126126
try open(path.appending(RelativePath(name))) { print in
127-
print("""
127+
print(
128+
"""
128129
<?xml version="1.0" encoding="UTF-8"?>
129130
<plist version="1.0">
130131
<dict>
@@ -150,7 +151,8 @@ extension Xcode.Project {
150151
<string></string>
151152
</dict>
152153
</plist>
153-
""")
154+
"""
155+
)
154156
}
155157
}
156158
}
@@ -160,7 +162,7 @@ extension Xcode.Project {
160162
///
161163
/// This method doesn't rewrite the file in case the new and old contents of
162164
/// file are same.
163-
fileprivate func open(_ path: AbsolutePath, body: ((String) -> Void) throws -> Void) throws {
165+
private func open(_ path: AbsolutePath, body: ((String) -> Void) throws -> Void) throws {
164166
let stream = BufferedOutputByteStream()
165167
try body { line in
166168
stream <<< line

‎Sources/CreateXCFramework/XcodeBuilder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import Build
99
import Foundation
1010
import PackageModel
11-
import Xcodeproj
1211
import TSCBasic
1312
import TSCUtility
13+
import Xcodeproj
1414

1515
struct XcodeBuilder {
1616

‎Sources/CreateXCFramework/Zipper.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct Zipper {
7171
private func versionSuffix (target: String, default fallback: String?) -> String? {
7272

7373
// find the package that contains our target
74-
guard let packageRef = self.package.graph.packages.first(where: { $0.targets.contains(where: { $0.name == target } ) }) else { return nil }
74+
guard let packageRef = self.package.graph.packages.first(where: { $0.targets.contains(where: { $0.name == target }) }) else { return nil }
7575

7676
guard
7777
let dependency = self.package.workspace.state.dependencies[forNameOrIdentity: packageRef.name],

0 commit comments

Comments
 (0)