Skip to content

Commit

Permalink
Fix default settings for multiplatform targets (tuist#7295)
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek authored Feb 4, 2025
1 parent 717d701 commit 46a1772
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
13 changes: 12 additions & 1 deletion Sources/TuistGenerator/Settings/DefaultSettingsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ public final class DefaultSettingsProvider: DefaultSettingsProviding {
let filteredSettings = platformSetting
.filter { !DefaultSettingsProvider.multiplatformExcludedSettingsKeys.contains($0.key) }

settings.overlay(with: filteredSettings, for: platform)
for (key, newValue) in filteredSettings {
if settings[key] == nil {
settings[key] = newValue
} else if settings[key] != newValue {
let newKey = "\(key)[sdk=\(platform.xcodeSdkRoot)*]"
settings[newKey] = newValue
if platform.hasSimulators, let simulatorSDK = platform.xcodeSimulatorSDK {
let newKey = "\(key)[sdk=\(simulatorSDK)*]"
settings[newKey] = newValue
}
}
}
}
} else if let platform = target.supportedPlatforms.first {
settings = try await targetSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,8 @@ final class ConfigGeneratorTests: TuistUnitTestCase {
"SDKROOT": "auto",
"TARGETED_DEVICE_FAMILY": "1,2",
"SUPPORTED_PLATFORMS": "iphoneos iphonesimulator macosx",
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks"],
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]": ["$(inherited)", "@executable_path/../Frameworks"],
"LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*]": ["$(inherited)", "@executable_path/Frameworks"],
"LD_RUNPATH_SEARCH_PATHS[sdk=iphonesimulator*]": ["$(inherited)", "@executable_path/Frameworks"],
]

assert(config: debugConfig, contains: expectedSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,34 +123,23 @@ final class DefaultSettingsProvider_iOSTests: TuistUnitTestCase {
"SWIFT_VERSION": "5.0",
]

private let multiplatformFrameworkTargetEssentialDebugSettings: [String: SettingValue] = ([
private let multiplatformFrameworkTargetEssentialDebugSettings: [String: SettingValue] = [
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": .array(["$(inherited)", "DEBUG"]),
"SKIP_INSTALL": "YES",
"VERSIONING_SYSTEM": "apple-generic",
"DYLIB_CURRENT_VERSION": "1",
"DYLIB_INSTALL_NAME_BASE": "@rpath",
"PRODUCT_NAME": "$(TARGET_NAME:c99extidentifier)",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"LD_RUNPATH_SEARCH_PATHS[sdk=iphoneos*]": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
"LD_RUNPATH_SEARCH_PATHS[sdk=iphonesimulator*]": ["$(inherited)", "@executable_path/Frameworks",
"@loader_path/Frameworks"],
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]": ["$(inherited)", "@executable_path/../Frameworks", "@loader_path/../Frameworks"],
"DEFINES_MODULE": "YES",
"VERSION_INFO_PREFIX": "",
"CURRENT_PROJECT_VERSION": "1",
"INSTALL_PATH": "$(LOCAL_LIBRARY_DIR)/Frameworks",
"DYLIB_COMPATIBILITY_VERSION": "1",
"SWIFT_VERSION": "5.0",
] as [String: SettingValue])
.reduce(into: [String: SettingValue]()) { acc, element in
if element.key.contains("sdk") {
acc[element.key] = element.value
} else {
acc["\(element.key)[sdk=macosx*]"] = element.value
acc["\(element.key)[sdk=iphonesimulator*]"] = element.value
acc["\(element.key)[sdk=iphoneos*]"] = element.value
}
}
]

override func setUp() {
super.setUp()
Expand Down

0 comments on commit 46a1772

Please sign in to comment.