Fix test target build settings (#661)

Resolves: https://github.com/tuist/tuist/issues/660

- Ensure the `LD_RUNPATH_SEARCH_PATHS` build setting is set for test targets

Test Plan:

- Generate `fixtures/ios_app_with_tests`
- Verify the generated project's test target contains a valid `LD_RUNPATH_SEARCH_PATHS` build setting
This commit is contained in:
Kas 2019-11-13 14:06:30 +00:00 committed by GitHub
parent 0fe1107d20
commit d88e11951d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 81 additions and 3 deletions

View File

@ -28,6 +28,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
### Fixed
- Fix false positive cycle detection https://github.com/tuist/tuist/pull/546 by @kwridan
- Fix test target build settings https://github.com/tuist/tuist/pull/661 by @kwridan
## 0.18.1

View File

@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/tuist/XcodeProj",
"state": {
"branch": null,
"revision": "0bea96dacbc7031893646be56c19e7a5e2c2881d",
"version": "7.4.0"
"revision": "23f7e12a7e0db29b4f16052692d99f9fbe41fa15",
"version": "7.5.0"
}
}
]

View File

@ -26,7 +26,7 @@ let package = Package(
targets: ["TuistGenerator"]),
],
dependencies: [
.package(url: "https://github.com/tuist/XcodeProj", .upToNextMajor(from: "7.4.0")),
.package(url: "https://github.com/tuist/XcodeProj", .upToNextMajor(from: "7.5.0")),
.package(url: "https://github.com/apple/swift-package-manager", .upToNextMajor(from: "0.5.0")),
],
targets: [

View File

@ -39,6 +39,10 @@ final class SettingsHelper {
return .appExtension
case .watch2Extension:
return .watchExtension
case .unitTests:
return .unitTests
case .uiTests:
return .uiTests
default:
return nil
}

View File

@ -104,6 +104,15 @@ final class DefaultSettingsProvider_iOSTests: XCTestCase {
"DYLIB_CURRENT_VERSION": "1",
]
private let testTargetEssentialDebugSettings: [String: SettingValue] = [
"SDKROOT": "iphoneos",
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
"CODE_SIGN_IDENTITY": "iPhone Developer",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"TARGETED_DEVICE_FAMILY": "1,2",
]
override func setUp() {
super.setUp()
subject = DefaultSettingsProvider()
@ -355,6 +364,70 @@ final class DefaultSettingsProvider_iOSTests: XCTestCase {
// Then
XCTAssertEqual(got.count, 0)
}
func testTargetSettings_whenRecommendedDebug_UnitTests() throws {
// Given
let buildConfiguration: BuildConfiguration = .debug
let settings = Settings(base: [:],
configurations: [buildConfiguration: nil],
defaultSettings: .recommended)
let target = Target.test(product: .unitTests, settings: settings)
// When
let got = try subject.targetSettings(target: target,
buildConfiguration: buildConfiguration)
// Then
XCTAssertSettings(got, containsAll: testTargetEssentialDebugSettings)
}
func testTargetSettings_whenRecommendedDebug_UITests() throws {
// Given
let buildConfiguration: BuildConfiguration = .debug
let settings = Settings(base: [:],
configurations: [buildConfiguration: nil],
defaultSettings: .recommended)
let target = Target.test(product: .uiTests, settings: settings)
// When
let got = try subject.targetSettings(target: target,
buildConfiguration: buildConfiguration)
// Then
XCTAssertSettings(got, containsAll: testTargetEssentialDebugSettings)
}
func testTargetSettings_whenEssentialDebug_UnitTests() throws {
// Given
let buildConfiguration: BuildConfiguration = .debug
let settings = Settings(base: [:],
configurations: [buildConfiguration: nil],
defaultSettings: .essential)
let target = Target.test(product: .unitTests, settings: settings)
// When
let got = try subject.targetSettings(target: target,
buildConfiguration: buildConfiguration)
// Then
XCTAssertEqual(got, testTargetEssentialDebugSettings)
}
func testTargetSettings_whenEssentialDebug_UITests() throws {
// Given
let buildConfiguration: BuildConfiguration = .debug
let settings = Settings(base: [:],
configurations: [buildConfiguration: nil],
defaultSettings: .essential)
let target = Target.test(product: .uiTests, settings: settings)
// When
let got = try subject.targetSettings(target: target,
buildConfiguration: buildConfiguration)
// Then
XCTAssertEqual(got, testTargetEssentialDebugSettings)
}
}
final class DictionaryStringAnyExtensionTests: XCTestCase {