mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-12-11 07:16:40 +03:00
Merge pull request #433 from yonaskolb/set_project_sdk_root
Automatically set project SDK root if there is only a single platform
This commit is contained in:
commit
642b116021
@ -7,6 +7,7 @@
|
||||
- Added `info` to targets for generating an `Info.plist` [#415](https://github.com/yonaskolb/XcodeGen/pull/415) @yonaskolb
|
||||
- Added `entitlements` to targets for generating an `.entitlement` file [#415](https://github.com/yonaskolb/XcodeGen/pull/415) @yonaskolb
|
||||
- Validate incorrect config setting definitions [#431](https://github.com/yonaskolb/XcodeGen/pull/431) @yonaskolb
|
||||
- Automatically set project `SDKROOT` if there is only a single platform within the project [#433](https://github.com/yonaskolb/XcodeGen/pull/433) @yonaskolb
|
||||
|
||||
#### Changed
|
||||
- Performance improvements for large projects [#388](https://github.com/yonaskolb/XcodeGen/pull/388) [#417](https://github.com/yonaskolb/XcodeGen/pull/417) [#416](https://github.com/yonaskolb/XcodeGen/pull/416) @yonaskolb @kastiglione
|
||||
|
@ -40,6 +40,15 @@ extension Platform {
|
||||
case .macOS: return "MACOSX_DEPLOYMENT_TARGET"
|
||||
}
|
||||
}
|
||||
|
||||
public var sdkRoot: String {
|
||||
switch self {
|
||||
case .iOS: return "iphoneos"
|
||||
case .tvOS: return "appletvos"
|
||||
case .watchOS: return "watchos"
|
||||
case .macOS: return "macosx"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Version {
|
||||
|
@ -10,6 +10,15 @@ extension Project {
|
||||
public func getProjectBuildSettings(config: Config) -> BuildSettings {
|
||||
var buildSettings: BuildSettings = [:]
|
||||
|
||||
// set project SDKROOT is a single platform
|
||||
if targets.count > 0 {
|
||||
let platforms = Dictionary(grouping: targets) { $0.platform }
|
||||
if platforms.count == 1 {
|
||||
let platform = platforms.first!.key
|
||||
buildSettings["SDKROOT"] = platform.sdkRoot
|
||||
}
|
||||
}
|
||||
|
||||
if let type = config.type, options.settingPresets.applyProject {
|
||||
buildSettings += SettingsPresetFile.base.getBuildSettings()
|
||||
buildSettings += SettingsPresetFile.config(type).getBuildSettings()
|
||||
|
@ -60,7 +60,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
let project = Project(basePath: "", name: "test", targets: [framework], options: options)
|
||||
let pbxProj = try project.generatePbxProj()
|
||||
let allSettings = pbxProj.buildConfigurations.reduce([:]) { $0.merged($1.buildSettings) }.keys.sorted()
|
||||
try expect(allSettings) == ["SETTING_2"]
|
||||
try expect(allSettings) == ["SDKROOT", "SETTING_2"]
|
||||
}
|
||||
|
||||
$0.it("generates development language") {
|
||||
@ -154,6 +154,7 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
let targetDebugSettings = project.getTargetBuildSettings(target: target, config: config)
|
||||
|
||||
var buildSettings = BuildSettings()
|
||||
buildSettings += ["SDKROOT": "iphoneos"]
|
||||
buildSettings += SettingsPresetFile.base.getBuildSettings()
|
||||
buildSettings += SettingsPresetFile.config(.debug).getBuildSettings()
|
||||
|
||||
@ -188,6 +189,23 @@ class ProjectGeneratorTests: XCTestCase {
|
||||
try expect(buildSettings["SETTING1"] as? String) == "VALUE1"
|
||||
try expect(buildSettings["SETTING2"] as? String) == "VALUE2"
|
||||
}
|
||||
|
||||
$0.it("sets project SDKROOT if there is only a single platform") {
|
||||
var project = Project(
|
||||
basePath: "",
|
||||
name: "test",
|
||||
targets: [
|
||||
Target(name: "1", type: .application, platform: .iOS),
|
||||
Target(name: "2", type: .framework, platform: .iOS),
|
||||
]
|
||||
)
|
||||
var buildSettings = project.getProjectBuildSettings(config: project.configs.first!)
|
||||
try expect(buildSettings["SDKROOT"] as? String) == "iphoneos"
|
||||
|
||||
project.targets.append(Target(name: "3", type: .application, platform: .tvOS))
|
||||
buildSettings = project.getProjectBuildSettings(config: project.configs.first!)
|
||||
try expect(buildSettings["SDKROOT"]).beNil()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user