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

Commit 2d1a893

Browse files
authored
Merge pull request #42 from daltonclaybrook/dalton/xc-settings
Add ability to provide arbitrary Xcode build settings
2 parents 56b522a + 5458a47 commit 2d1a893

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// BuildSetting.swift
3+
// swift-create-xcframework
4+
//
5+
// Created by Dalton Claybrook on 4/17/21.
6+
//
7+
8+
import ArgumentParser
9+
10+
/// A representation of a build setting in an Xcode project, e.g.
11+
/// `IPHONEOS_DEPLOYMENT_TARGET=13.0`
12+
struct BuildSetting: ExpressibleByArgument {
13+
/// The name of the build setting, e.g. `IPHONEOS_DEPLOYMENT_TARGET`
14+
let name: String
15+
/// The value of the build setting
16+
let value: String
17+
18+
init?(argument: String) {
19+
let components = argument.components(separatedBy: "=")
20+
guard components.count == 2 else { return nil }
21+
self.name = components[0].trimmingCharacters(in: .whitespacesAndNewlines)
22+
self.value = components[1].trimmingCharacters(in: .whitespacesAndNewlines)
23+
}
24+
}

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+
@Option(help: ArgumentHelp("Arbitrary Xcode build settings that are passed directly to the `xcodebuild` invocation. Can be specified multiple times.", valueName: "NAME=VALUE"))
41+
var xcSetting: [BuildSetting] = []
42+
4043

4144
// MARK: - Output Options
4245

Sources/CreateXCFramework/XcodeBuilder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,18 @@ struct XcodeBuilder {
115115
"SKIP_INSTALL=NO"
116116
]
117117

118-
// add any build settings
118+
// add SDK-specific build settings
119119
if let settings = sdk.buildSettings {
120120
for setting in settings {
121121
command.append("\(setting.key)=\(setting.value)")
122122
}
123123
}
124124

125+
// add build settings provided in the invocation
126+
options.xcSetting.forEach { setting in
127+
command.append("\(setting.name)=\(setting.value)")
128+
}
129+
125130
// add our targets
126131
command += [ "-scheme", target ]
127132

0 commit comments

Comments
 (0)