Skip to content

Commit cdc9325

Browse files
authored
Provide default build settings for unit and ui test targets (tuist#501)
- The previous diff tuist#497 restructured the way the build settings were provided - This sadly caused a regression of not providing default build settings for Unit/UI test bundles - Those are now explictily added as product types - Tests have been added to prevent future regressions Test Plan: - Verify the build settings match those provided by Xcode
1 parent 0bea96d commit cdc9325

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Next
44

5+
### Fixed
6+
7+
- Provide default build settings for unit and ui test targets https://github.com/tuist/XcodeProj/pull/501 by @kwridan
8+
59
## 7.4.0
610

711
### Changed

Sources/XcodeProj/Utils/BuildSettingsProvider.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class BuildSettingsProvider {
3232
/// - appExtension: application extension
3333
/// - watchExtension: watch extension
3434
public enum Product {
35-
case framework, staticLibrary, dynamicLibrary, application, bundle, appExtension, watchExtension
35+
case framework, staticLibrary, dynamicLibrary, application, bundle, appExtension, watchExtension, unitTests, uiTests
3636
}
3737

3838
/// Returns the default target build settings.
@@ -308,6 +308,14 @@ public class BuildSettingsProvider {
308308
"@executable_path/../../../../Frameworks"
309309
]
310310
]
311+
case ([.iOS, .tvOS], [.unitTests, .uiTests]):
312+
return [
313+
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
314+
]
315+
case (.macOS, [.unitTests, .uiTests]):
316+
return [
317+
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/../Frameworks", "@loader_path/../Frameworks"]
318+
]
311319
default:
312320
return [:]
313321
}

Tests/XcodeProjTests/Utils/BuildSettingsProviderTests.swift

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,96 @@ class BuildSettingProviderTests: XCTestCase {
143143
])
144144
}
145145

146+
func test_targetSettings_iOSUnitTests() {
147+
// Given / When
148+
let results = BuildSettingsProvider.targetDefault(variant: .debug,
149+
platform: .iOS,
150+
product: .unitTests,
151+
swift: true)
152+
153+
// Then
154+
assertEqualSettings(results, [
155+
"CODE_SIGN_IDENTITY": "iPhone Developer",
156+
"SDKROOT": "iphoneos",
157+
"LD_RUNPATH_SEARCH_PATHS": [
158+
"$(inherited)",
159+
"@executable_path/Frameworks",
160+
"@loader_path/Frameworks"
161+
],
162+
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
163+
"SWIFT_COMPILATION_MODE": "singlefile",
164+
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
165+
"TARGETED_DEVICE_FAMILY": "1,2"
166+
])
167+
}
168+
169+
func test_targetSettings_iOSUITests() {
170+
// Given / When
171+
let results = BuildSettingsProvider.targetDefault(variant: .debug,
172+
platform: .iOS,
173+
product: .uiTests,
174+
swift: true)
175+
176+
// Then
177+
assertEqualSettings(results, [
178+
"CODE_SIGN_IDENTITY": "iPhone Developer",
179+
"SDKROOT": "iphoneos",
180+
"LD_RUNPATH_SEARCH_PATHS": [
181+
"$(inherited)",
182+
"@executable_path/Frameworks",
183+
"@loader_path/Frameworks"
184+
],
185+
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
186+
"SWIFT_COMPILATION_MODE": "singlefile",
187+
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
188+
"TARGETED_DEVICE_FAMILY": "1,2"
189+
])
190+
}
191+
192+
func test_targetSettings_macOSUnitTests() {
193+
// Given / When
194+
let results = BuildSettingsProvider.targetDefault(variant: .debug,
195+
platform: .macOS,
196+
product: .unitTests,
197+
swift: true)
198+
199+
// Then
200+
assertEqualSettings(results, [
201+
"CODE_SIGN_IDENTITY": "-",
202+
"SDKROOT": "macosx",
203+
"LD_RUNPATH_SEARCH_PATHS": [
204+
"$(inherited)",
205+
"@executable_path/../Frameworks",
206+
"@loader_path/../Frameworks"
207+
],
208+
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
209+
"SWIFT_COMPILATION_MODE": "singlefile",
210+
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
211+
])
212+
}
213+
214+
func test_targetSettings_tvOSUnitTests() {
215+
// Given / When
216+
let results = BuildSettingsProvider.targetDefault(variant: .debug,
217+
platform: .tvOS,
218+
product: .unitTests,
219+
swift: true)
220+
221+
// Then
222+
assertEqualSettings(results, [
223+
"SDKROOT": "appletvos",
224+
"LD_RUNPATH_SEARCH_PATHS": [
225+
"$(inherited)",
226+
"@executable_path/Frameworks",
227+
"@loader_path/Frameworks"
228+
],
229+
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
230+
"SWIFT_COMPILATION_MODE": "singlefile",
231+
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
232+
"TARGETED_DEVICE_FAMILY": "3"
233+
])
234+
}
235+
146236
// MARK: - Helpers
147237

148238
func assertEqualSettings(_ lhs: BuildSettings, _ rhs: BuildSettings, file: StaticString = #file, line: UInt = #line) {

0 commit comments

Comments
 (0)