Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 859acbb

Browse files
authored
Merge pull request #56 from unsignedapps/feature/stack-evolution
Added the `--stack-evolution` option
2 parents f678c99 + 4785977 commit 859acbb

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

Sources/CreateXCFramework/Command+Options.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ extension Command {
3737
@Option(help: "The path to a .xcconfig file that can be used to override Xcode build settings. Relative to the package path.")
3838
var xcconfig: String?
3939

40+
@Flag(help: "Enables Library Evolution for the whole build stack. Normally we apply it only to the targets listed to be built to work around issues with projects that don't support it.")
41+
var stackEvolution: Bool = false
42+
4043
@Option(help: ArgumentHelp("Arbitrary Xcode build settings that are passed directly to the `xcodebuild` invocation. Can be specified multiple times.", valueName: "NAME=VALUE"))
4144
var xcSetting: [BuildSetting] = []
4245

Sources/CreateXCFramework/Command.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ struct Command: ParsableCommand {
7777

7878
// we've applied the xcconfig to everything, but some dependencies (*cough* swift-nio)
7979
// have build errors, so we remove it from targets we're not building
80-
try project.enableDistribution(targets: productNames, xcconfig: AbsolutePath(package.distributionBuildXcconfig.path).relative(to: AbsolutePath(package.rootDirectory.path)))
80+
if self.options.stackEvolution == false {
81+
try project.enableDistribution(targets: productNames, xcconfig: AbsolutePath(package.distributionBuildXcconfig.path).relative(to: AbsolutePath(package.rootDirectory.path)))
82+
}
8183

8284
// save the project
8385
try project.save(to: generator.projectPath)

Sources/CreateXCFramework/PackageInfo.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ struct PackageInfo {
2727
.absoluteURL
2828
}
2929

30+
var hasDistributionBuildXcconfig: Bool {
31+
self.overridesXcconfig != nil || self.options.stackEvolution == false
32+
}
33+
3034
var distributionBuildXcconfig: Foundation.URL {
3135
return self.projectBuildDirectory
3236
.appendingPathComponent("Distribution.xcconfig")
@@ -232,7 +236,7 @@ enum SupportedPlatforms {
232236
case packageValid (plan: [SupportedPlatform])
233237
}
234238

235-
extension SupportedPlatform: Equatable, Comparable {
239+
extension SupportedPlatform: Comparable {
236240
public static func == (lhs: SupportedPlatform, rhs: SupportedPlatform) -> Bool {
237241
return lhs.platform == rhs.platform && lhs.version == rhs.version
238242
}

Sources/CreateXCFramework/ProjectGenerator.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ struct ProjectGenerator {
3838

3939
/// Writes out the Xcconfig file
4040
func writeDistributionXcconfig () throws {
41+
guard self.package.hasDistributionBuildXcconfig else {
42+
return
43+
}
44+
4145
try makeDirectories(self.projectPath)
4246

4347
let path = AbsolutePath(self.package.distributionBuildXcconfig.path)
@@ -56,14 +60,6 @@ struct ProjectGenerator {
5660
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
5761
"""
5862
)
59-
60-
if package.options.platform.contains(.maccatalyst) {
61-
stream (
62-
"""
63-
SUPPORTS_MACCATALYST=YES
64-
"""
65-
)
66-
}
6763
}
6864
}
6965

Sources/CreateXCFramework/XcodeBuilder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,13 @@ struct XcodeBuilder {
122122
}
123123
}
124124

125+
// enable evolution for the whole stack
126+
if self.options.stackEvolution {
127+
command.append("BUILD_LIBRARY_FOR_DISTRIBUTION=YES")
128+
}
129+
125130
// add build settings provided in the invocation
126-
options.xcSetting.forEach { setting in
131+
self.options.xcSetting.forEach { setting in
127132
command.append("\(setting.name)=\(setting.value)")
128133
}
129134

Sources/CreateXCFramework/Zipper.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct Zipper {
7474
guard let packageRef = self.package.graph.packages.first(where: { $0.targets.contains(where: { $0.name == target }) }) else { return nil }
7575

7676
guard
77-
let dependency = self.package.workspace.state.dependencies[forNameOrIdentity: packageRef.name],
77+
let dependency = self.package.workspace.state.dependencies[forNameOrIdentity: packageRef.packageName],
7878
case let .checkout(checkout) = dependency.state,
7979
let version = checkout.version
8080
else {
@@ -91,3 +91,17 @@ struct Zipper {
9191
try FileManager.default.removeItem(at: file)
9292
}
9393
}
94+
95+
#if swift(>=5.5)
96+
private extension ResolvedPackage {
97+
var packageName: String {
98+
self.manifestName
99+
}
100+
}
101+
#else
102+
private extension ResolvedPackage {
103+
var packageName: String {
104+
self.name
105+
}
106+
}
107+
#endif

0 commit comments

Comments
 (0)