Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build settings have the same values repeated multiple times #391

Merged
merged 4 commits into from Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
### Fixed

- Ensuring the correct default settings provider dependency is used https://github.com/tuist/tuist/pull/389 by @kwridan
- Fixing build settings repeated same value https://github.com/tuist/tuist/pull/391 @platonsi

## 0.15.0

Expand Down
3 changes: 2 additions & 1 deletion Sources/TuistGenerator/Utils/SettingsHelper.swift
Expand Up @@ -6,7 +6,8 @@ final class SettingsHelper {
other.forEach { key, value in
if buildSettings[key] == nil || (value as? String)?.contains("$(inherited)") == false {
buildSettings[key] = value
} else if let previousValueString = buildSettings[key] as? String, let newValueString = value as? String {
} else if let previousValueString = buildSettings[key] as? String, let newValueString = value as? String,
previousValueString != newValueString {
buildSettings[key] = "\(previousValueString) \(newValueString)"
} else {
buildSettings[key] = value
Expand Down
Expand Up @@ -49,15 +49,15 @@ final class DefaultSettingsProvider_iOSTests: XCTestCase {

private let appTargetEssentialDebugSettings: [String: Any] = [
"SDKROOT": "iphoneos",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks $(inherited) @executable_path/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks",
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": "DEBUG",
"CODE_SIGN_IDENTITY": "iPhone Developer",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"TARGETED_DEVICE_FAMILY": "1,2",
]

private let appTargetEssentialReleaseSettings: [String: Any] = [
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks $(inherited) @executable_path/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks",
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"TARGETED_DEVICE_FAMILY": "1,2",
"SWIFT_COMPILATION_MODE": "wholemodule",
Expand All @@ -77,7 +77,7 @@ final class DefaultSettingsProvider_iOSTests: XCTestCase {
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"TARGETED_DEVICE_FAMILY": "1,2",
"SDKROOT": "iphoneos",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(inherited) @executable_path/Frameworks @loader_path/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @loader_path/Frameworks",
"DEFINES_MODULE": "YES",
"VERSION_INFO_PREFIX": "",
"CURRENT_PROJECT_VERSION": "1",
Expand All @@ -88,7 +88,7 @@ final class DefaultSettingsProvider_iOSTests: XCTestCase {

private let frameworkTargetEssentialReleaseSettings: [String: Any] = [
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(inherited) @executable_path/Frameworks @loader_path/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": "$(inherited) @executable_path/Frameworks @loader_path/Frameworks",
"DEFINES_MODULE": "YES",
"DYLIB_INSTALL_NAME_BASE": "@rpath",
"INSTALL_PATH": "$(LOCAL_LIBRARY_DIR)/Frameworks",
Expand Down
23 changes: 23 additions & 0 deletions Tests/TuistGeneratorTests/Utils/SettingsHelperTests.swift
Expand Up @@ -64,6 +64,29 @@ final class SettingsHelpersTests: XCTestCase {
XCTAssertEqualDictionaries(settings, ["A": "A_VALUE $(inherited) A_VALUE_2", "B": "B_VALUE", "C": "C_VALUE"])
}

func testNotExtend_whenExistingSettingsAndNewWithSameValues() {
// Given
settings["A"] = "A_VALUE"
settings["B"] = "B_VALUE"

// When
subject.extend(buildSettings: &settings, with: ["A": "A_VALUE"])

// Then
XCTAssertEqualDictionaries(settings, ["A": "A_VALUE", "B": "B_VALUE"])
}

func testNotExtend_whenExistingSettingsAndNewWithInheritedDeclarationAndSameValues() {
// Given
settings["A"] = "$(inherited) A_VALUE"

// When
subject.extend(buildSettings: &settings, with: ["A": "$(inherited) A_VALUE",])

// Then
XCTAssertEqualDictionaries(settings, ["A": "$(inherited) A_VALUE"])
}

func testSettingsProviderPlatform() {
XCTAssertEqual(subject.settingsProviderPlatform(.test(platform: .iOS)), .iOS)
XCTAssertEqual(subject.settingsProviderPlatform(.test(platform: .macOS)), .macOS)
Expand Down