Skip to content

Commit 00dce41

Browse files
committed
Adding support for macos + package swiftinterface
1 parent 8f4caa2 commit 00dce41

File tree

14 files changed

+128
-14
lines changed

14 files changed

+128
-14
lines changed

.github/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: 🛠️ Build with release configuration
2626
run: |
27-
swift build --configuration release -skipPackagePluginValidation | xcpretty --utf --color && exit ${PIPESTATUS[0]}
27+
swift build --configuration release | xcpretty --utf --color && exit ${PIPESTATUS[0]}
2828
2929
- uses: actions/upload-artifact@v4
3030
with:

.github/workflows/detect-api.changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
OLD="${{ env.target }}~${{ env.githubRepo }}"
4848
fi
4949
50-
swift run public-api-diff project --new "$NEW" --old "$OLD" --output "$PROJECT_FOLDER/api_comparison.md" --log-level debug --log-output "$PROJECT_FOLDER/logs.txt"
50+
swift run public-api-diff project --new "$NEW" --old "$OLD" --platform macos --output "$PROJECT_FOLDER/api_comparison.md" --log-level debug --log-output "$PROJECT_FOLDER/logs.txt"
5151
cat "$PROJECT_FOLDER/logs.txt"
5252
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
5353
env:

.github/workflows/stale-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# You can adjust the behavior by modifying this file.
44
# For more information, see:
55
# https://github.com/actions/stale
6-
name: Manage stale issues
6+
name: 🏷️ Manage stale issues
77

88
on:
99
schedule:

.swiftlint.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
disabled_rules:
2+
- trailing_whitespace
3+
- nesting
4+
- todo
5+
- for_where
6+
7+
excluded:
8+
- Build
9+
- .build
10+
- Tests
11+
- Internal
12+
- Docs
13+
- Demo
14+
- Package.swift
15+
- DerivedData
16+
- Carthage
17+
- TempProject
18+
- Scripts
19+
20+
line_length:
21+
ignores_function_declarations: true
22+
ignores_urls: true
23+
warning: 140
24+
25+
file_length:
26+
warning: 500
27+
28+
function_parameter_count:
29+
warning: 10
30+
error: 15
31+
32+
identifier_name:
33+
min_length:
34+
warning: 2
35+
max_length:
36+
warning: 40

Sources/ExecutableTargets/CommandLineTool/CommandLineTool+Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extension SwiftInterfaceType: ExpressibleByArgument {
1414
switch argument {
1515
case "public": self = .public
1616
case "private": self = .private
17+
case "package": self = .package
1718
default: return nil
1819
}
1920
}

Sources/ExecutableTargets/CommandLineTool/ProjectToOutputCommand.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ struct ProjectToOutputCommand: AsyncParsableCommand {
2929
@Option(help: "Specify the old version to compare to")
3030
public var old: String
3131

32+
@Option(help: "The platform to build the project for (iOS/macOS)")
33+
public var platform: ProjectPlatform
34+
3235
/// The (optional) scheme to build
3336
///
3437
/// Needed when comparing 2 xcode projects
@@ -74,6 +77,7 @@ struct ProjectToOutputCommand: AsyncParsableCommand {
7477
oldSource: oldSource,
7578
newSource: newSource,
7679
projectType: projectType,
80+
platform: platform,
7781
swiftInterfaceType: swiftInterfaceType,
7882
logger: logger
7983
)
@@ -136,12 +140,14 @@ private extension ProjectToOutputCommand {
136140
oldSource: ProjectSource,
137141
newSource: ProjectSource,
138142
projectType: ProjectType,
143+
platform: ProjectPlatform,
139144
swiftInterfaceType: SwiftInterfaceType,
140145
logger: any Logging
141146
) async throws -> ProjectBuilder.Result {
142147

143148
let projectBuilder = ProjectBuilder(
144149
projectType: projectType,
150+
platform: platform,
145151
swiftInterfaceType: swiftInterfaceType,
146152
logger: logger
147153
)
@@ -207,3 +213,22 @@ private extension ProjectToOutputCommand {
207213
)
208214
}
209215
}
216+
217+
extension ProjectPlatform: ExpressibleByArgument {
218+
219+
static var mapping: [String: ProjectPlatform] = [
220+
"iOS": .iOS,
221+
"macOS": .macOS
222+
]
223+
224+
public init?(argument: String) {
225+
for (key, value) in Self.mapping {
226+
if argument.compare(key, options: .caseInsensitive) == .orderedSame {
227+
self = value
228+
return
229+
}
230+
}
231+
232+
return nil
233+
}
234+
}

Sources/PublicModules/PADProjectBuilder/ProjectBuilder.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ public struct ProjectBuilder {
3333
}
3434

3535
private let projectType: ProjectType
36+
private let platform: ProjectPlatform
3637
private let swiftInterfaceType: SwiftInterfaceType
3738
private let fileHandler: any FileHandling
3839
private let shell: any ShellHandling
3940
private let logger: (any Logging)?
4041

4142
public init(
4243
projectType: ProjectType,
44+
platform: ProjectPlatform,
4345
swiftInterfaceType: SwiftInterfaceType,
4446
logger: (any Logging)? = nil
4547
) {
4648
self.init(
4749
projectType: projectType,
50+
platform: platform,
4851
swiftInterfaceType: swiftInterfaceType,
4952
fileHandler: FileManager.default,
5053
shell: Shell(),
@@ -54,12 +57,14 @@ public struct ProjectBuilder {
5457

5558
init(
5659
projectType: ProjectType,
60+
platform: ProjectPlatform,
5761
swiftInterfaceType: SwiftInterfaceType,
5862
fileHandler: any FileHandling = FileManager.default,
5963
shell: any ShellHandling = Shell(),
6064
logger: (any Logging)?
6165
) {
6266
self.projectType = projectType
67+
self.platform = platform
6368
self.swiftInterfaceType = swiftInterfaceType
6469
self.fileHandler = fileHandler
6570
self.shell = shell
@@ -99,6 +104,7 @@ public struct ProjectBuilder {
99104
let producer = SwiftInterfaceProducer(
100105
workingDirectoryPath: workingDirectoryPath,
101106
projectType: projectType,
107+
platform: platform,
102108
swiftInterfaceType: swiftInterfaceType,
103109
fileHandler: fileHandler,
104110
shell: shell,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ProjectPlatform.swift
3+
// public-api-diff
4+
//
5+
// Created by Alexander Guretzki on 13/11/2024.
6+
//
7+
8+
/// The platform to build the project on
9+
public enum ProjectPlatform {
10+
11+
case macOS
12+
case iOS
13+
}

Sources/PublicModules/PADProjectBuilder/SwiftInterfaceProducer/SwiftInterfaceProducer.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct SwiftInterfaceProducer {
2222

2323
let workingDirectoryPath: String
2424
let projectType: ProjectType
25+
let platform: ProjectPlatform
2526
let swiftInterfaceType: SwiftInterfaceType
2627
let fileHandler: any FileHandling
2728
let shell: any ShellHandling
@@ -122,12 +123,14 @@ extension SwiftInterfaceProducer {
122123
let newDerivedDataPath = try await xcodeTools.archive(
123124
projectDirectoryPath: newProjectDirectoryPath,
124125
scheme: scheme,
125-
projectType: projectType
126+
projectType: projectType,
127+
platform: platform
126128
)
127129
let oldDerivedDataPath = try await xcodeTools.archive(
128130
projectDirectoryPath: oldProjectDirectoryPath,
129131
scheme: scheme,
130-
projectType: projectType
132+
projectType: projectType,
133+
platform: platform
131134
)
132135

133136
return (newDerivedDataPath, oldDerivedDataPath)

Sources/PublicModules/PADProjectBuilder/SwiftInterfaceProducer/XcodeTools.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,28 @@ struct XcodeTools {
4949
func archive(
5050
projectDirectoryPath: String,
5151
scheme: String,
52-
projectType: ProjectType
52+
projectType: ProjectType,
53+
platform: ProjectPlatform
5354
) async throws -> String {
55+
5456
var commandComponents = [
5557
"cd \(projectDirectoryPath);",
5658
"xcodebuild clean build -scheme \"\(scheme)\"",
57-
"-destination \"generic/platform=iOS\"",
5859
"-derivedDataPath \(Constants.derivedDataPath)",
59-
"-sdk `\(Constants.simulatorSdkCommand)`",
6060
"BUILD_LIBRARY_FOR_DISTRIBUTION=YES"
6161
]
62+
63+
switch platform {
64+
case .iOS:
65+
commandComponents += [
66+
"-sdk `\(Constants.simulatorSdkCommand)`",
67+
"-destination \"generic/platform=iOS\"",
68+
]
69+
case .macOS:
70+
commandComponents += [
71+
"-destination \"generic/platform=macOS\"",
72+
]
73+
}
6274

6375
switch projectType {
6476
case .swiftPackage:

0 commit comments

Comments
 (0)