Skip to content

Commit 7ea68bc

Browse files
committed
Removing more code
1 parent b48d1f6 commit 7ea68bc

File tree

9 files changed

+52
-340
lines changed

9 files changed

+52
-340
lines changed

Package.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ let package = Package(
3434
// Copy Tests/ExampleTests/Resources directories as-is.
3535
// Use to retain directory structure.
3636
// Will be at top level in bundle.
37-
.copy("Resources/dummy.abi.json"),
38-
.copy("Resources/dummi-abi-flat-definition.md"),
3937
.copy("Resources/expected-reference-changes.md")
4038
]
4139
),
@@ -46,7 +44,6 @@ let package = Package(
4644
// Copy Tests/ExampleTests/Resources directories as-is.
4745
// Use to retain directory structure.
4846
// Will be at top level in bundle.
49-
.copy("Resources/expected-reference-changes-sdk-dump.md"),
5047
.copy("Resources/expected-reference-changes-swift-interface-private.md"),
5148
.copy("Resources/expected-reference-changes-swift-interface-public.md")
5249
]

Sources/Helpers/SwiftPackageFileHelper.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,18 @@ struct SwiftPackageFileHelper {
2727

2828
private let fileHandler: FileHandling
2929
private let xcodeTools: XcodeTools
30+
private let shell: any ShellHandling
31+
private let logger: (any Logging)?
3032

3133
init(
3234
fileHandler: FileHandling,
33-
xcodeTools: XcodeTools
35+
shell: any ShellHandling,
36+
logger: (any Logging)?
3437
) {
3538
self.fileHandler = fileHandler
36-
self.xcodeTools = xcodeTools
39+
self.xcodeTools = XcodeTools(shell: shell, fileHandler: fileHandler, logger: logger)
40+
self.shell = shell
41+
self.logger = logger
3742
}
3843

3944
static func packagePath(for projectDirectoryPath: String) -> String {
@@ -93,7 +98,7 @@ private extension SwiftPackageFileHelper {
9398

9499
func generatePackageDescription(at projectDirectoryPath: String) throws -> SwiftPackageDescription {
95100

96-
let result = try xcodeTools.loadPackageDescription(projectDirectoryPath: projectDirectoryPath)
101+
let result = try loadPackageDescription(projectDirectoryPath: projectDirectoryPath)
97102

98103
let newLine = "\n"
99104
let errorTag = "error: "
@@ -133,6 +138,17 @@ private extension SwiftPackageFileHelper {
133138
throw SwiftPackageFileHelperError.couldNotGeneratePackageDescription
134139
}
135140

141+
func loadPackageDescription(
142+
projectDirectoryPath: String
143+
) throws -> String {
144+
let command = [
145+
"cd \(projectDirectoryPath);",
146+
"swift package describe --type json"
147+
]
148+
149+
return shell.execute(command.joined(separator: " "))
150+
}
151+
136152
func decodePackageDescription(from packageDescriptionData: Data, warnings: [String]) throws -> SwiftPackageDescription {
137153
var packageDescription = try JSONDecoder().decode(SwiftPackageDescription.self, from: packageDescriptionData)
138154
packageDescription.warnings = warnings

Sources/Helpers/XcodeTools.swift

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -35,56 +35,6 @@ struct XcodeTools {
3535
self.logger = logger
3636
}
3737

38-
func loadPackageDescription(
39-
projectDirectoryPath: String
40-
) throws -> String {
41-
let command = [
42-
"cd \(projectDirectoryPath);",
43-
"swift package describe --type json"
44-
]
45-
46-
return shell.execute(command.joined(separator: " "))
47-
}
48-
49-
func build(
50-
projectDirectoryPath: String,
51-
scheme: String,
52-
projectType: ProjectType
53-
) throws {
54-
var commandComponents = [
55-
"cd \(projectDirectoryPath);",
56-
"xcodebuild -scheme \"\(scheme)\"",
57-
"-derivedDataPath \(Constants.derivedDataPath)",
58-
iOSTarget,
59-
"-destination \"platform=iOS,name=Any iOS Device\""
60-
]
61-
62-
switch projectType {
63-
case .swiftPackage:
64-
commandComponents += ["-skipPackagePluginValidation"]
65-
case .xcodeProject:
66-
break // Nothing to add
67-
}
68-
69-
let command = commandComponents.joined(separator: " ")
70-
71-
// print("👾 \(command.joined(separator: " "))")
72-
logger?.log("🏗️ Building \(scheme) from `\(projectDirectoryPath)`", from: String(describing: Self.self))
73-
let result = shell.execute(command)
74-
75-
if
76-
!fileHandler.fileExists(atPath: "\(projectDirectoryPath)/\(Constants.derivedDataPath)") ||
77-
result.range(of: "xcodebuild: error:") != nil ||
78-
result.range(of: "BUILD FAILED") != nil
79-
{
80-
print(result)
81-
throw XcodeToolsError(
82-
errorDescription: "💥 Building project failed",
83-
underlyingError: result
84-
)
85-
}
86-
}
87-
8838
func archive(
8939
projectDirectoryPath: String,
9040
scheme: String,
@@ -133,43 +83,6 @@ struct XcodeTools {
13383
}.value
13484
}
13585

136-
func dumpSdk(
137-
projectDirectoryPath: String,
138-
module: String,
139-
outputFilePath: String
140-
) {
141-
let sdkDumpInputPath = "\(Constants.derivedDataPath)/Build/Products/Debug-iphonesimulator"
142-
143-
let command = [
144-
"cd \(projectDirectoryPath);",
145-
"xcrun swift-api-digester -dump-sdk",
146-
"-module \(module)",
147-
"-I \(sdkDumpInputPath)",
148-
"-o \(outputFilePath)",
149-
iOSTarget,
150-
"-abort-on-module-fail"
151-
]
152-
153-
// print("👾 \(command.joined(separator: " "))")
154-
shell.execute(command.joined(separator: " "))
155-
}
156-
157-
func diagnoseSdk(
158-
oldAbiJsonFilePath: String,
159-
newAbiJsonFilePath: String,
160-
module: String
161-
) -> String {
162-
163-
let command = [
164-
"xcrun --sdk iphoneos swift-api-digester -diagnose-sdk",
165-
"-module \(module)",
166-
"-input-paths \(oldAbiJsonFilePath)",
167-
"-input-paths \(newAbiJsonFilePath)"
168-
]
169-
170-
return shell.execute(command.joined(separator: " "))
171-
}
172-
17386
private var iOSTarget: String {
17487
"-sdk `\(Constants.simulatorSdkCommand)` -target \(Constants.deviceTarget)"
17588
}

Sources/Pipeline/Modules/ABIGenerator/ABIGenerator.swift

Lines changed: 0 additions & 58 deletions
This file was deleted.

Sources/Pipeline/Modules/ABIGenerator/PackageABIGenerator.swift

Lines changed: 0 additions & 65 deletions
This file was deleted.

Sources/Pipeline/Modules/ABIGenerator/ProjectABIProvider.swift

Lines changed: 0 additions & 49 deletions
This file was deleted.

Sources/Pipeline/Modules/SwiftPackageFileAnalyzer.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import Foundation
88

99
struct SwiftPackageFileAnalyzer: ProjectAnalyzing {
1010

11-
let fileHandler: FileHandling
12-
let xcodeTools: XcodeTools
11+
private let fileHandler: any FileHandling
12+
private let xcodeTools: XcodeTools
13+
private let shell: any ShellHandling
14+
private let logger: (any Logging)?
1315

1416
private enum Constants {
1517
static let packageFileName = "Package.swift"
@@ -21,10 +23,12 @@ struct SwiftPackageFileAnalyzer: ProjectAnalyzing {
2123
init(
2224
fileHandler: FileHandling = FileManager.default,
2325
shell: ShellHandling = Shell(),
24-
logger: Logging?
26+
logger: (any Logging)?
2527
) {
2628
self.fileHandler = fileHandler
2729
self.xcodeTools = XcodeTools(shell: shell, fileHandler: fileHandler, logger: logger)
30+
self.logger = logger
31+
self.shell = shell
2832
}
2933

3034
func analyze(oldProjectUrl: URL, newProjectUrl: URL) throws -> ProjectAnalyzerResult {
@@ -38,7 +42,8 @@ struct SwiftPackageFileAnalyzer: ProjectAnalyzing {
3842
if fileHandler.fileExists(atPath: oldPackagePath), fileHandler.fileExists(atPath: newPackagePath) {
3943
let packageHelper = SwiftPackageFileHelper(
4044
fileHandler: fileHandler,
41-
xcodeTools: xcodeTools
45+
shell: shell,
46+
logger: logger
4247
)
4348

4449
return try analyze(

0 commit comments

Comments
 (0)