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

fix: add missing BuildSettingsProvider for visionOS #898

Merged
merged 2 commits into from
Jan 24, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Sources/XcodeProj/Utils/BuildSettingsProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public class BuildSettingsProvider {
case .visionOS:
[
"SDKROOT": "xros",
"CODE_SIGN_IDENTITY": "iPhone Developer",
"TARGETED_DEVICE_FAMILY": "1,2,7",
]
}
Expand Down Expand Up @@ -247,6 +248,10 @@ public class BuildSettingsProvider {
"SKIP_INSTALL": "YES",
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks"],
]
case (.visionOS, .application):
[
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks"],
]
case (.iOS, .framework):
[
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
Expand All @@ -266,7 +271,11 @@ public class BuildSettingsProvider {
"APPLICATION_EXTENSION_API_ONLY": "YES",
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
]
case ([.iOS, .tvOS, .watchOS], .staticLibrary):
case (.visionOS, .framework):
[
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
]
case ([.iOS, .tvOS, .watchOS, .visionOS], .staticLibrary):
[
"OTHER_LDFLAGS": "-ObjC",
"SKIP_INSTALL": "YES",
Expand All @@ -288,7 +297,7 @@ public class BuildSettingsProvider {
"COMBINE_HIDPI_IMAGES": "YES",
"INSTALL_PATH": "$(LOCAL_LIBRARY_DIR)/Bundles",
]
case ([.iOS, .tvOS], .appExtension):
case ([.iOS, .tvOS, .visionOS], .appExtension):
[
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@executable_path/../../Frameworks"],
]
Expand Down Expand Up @@ -317,7 +326,7 @@ public class BuildSettingsProvider {
"@executable_path/../../../../Frameworks",
],
]
case ([.iOS, .tvOS], [.unitTests, .uiTests]):
case ([.iOS, .tvOS, .visionOS], [.unitTests, .uiTests]):
[
"LD_RUNPATH_SEARCH_PATHS": ["$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks"],
]
Expand Down
178 changes: 178 additions & 0 deletions Tests/XcodeProjTests/Utils/BuildSettingsProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,138 @@ class BuildSettingProviderTests: XCTestCase {
])
}

func test_targetSettings_watchOSFramework() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .release,
platform: .watchOS,
product: .framework,
swift: true)

// Then
assertEqualSettings(results, [
"APPLICATION_EXTENSION_API_ONLY": "YES",
"CODE_SIGN_IDENTITY": "",
"CURRENT_PROJECT_VERSION": "1",
"DEFINES_MODULE": "YES",
"DYLIB_COMPATIBILITY_VERSION": "1",
"DYLIB_CURRENT_VERSION": "1",
"DYLIB_INSTALL_NAME_BASE": "@rpath",
"INSTALL_PATH": "$(LOCAL_LIBRARY_DIR)/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
],
"PRODUCT_NAME": "$(TARGET_NAME:c99extidentifier)",
"SDKROOT": "watchos",
"SKIP_INSTALL": "YES",
"SWIFT_COMPILATION_MODE": "wholemodule",
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"TARGETED_DEVICE_FAMILY": "4",
"VERSIONING_SYSTEM": "apple-generic",
"VERSION_INFO_PREFIX": "",
])
}

func test_targetSettings_watchOSExtension() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .release,
platform: .watchOS,
product: .appExtension,
swift: true)

// Then
assertEqualSettings(results, [
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
"@executable_path/../../../../Frameworks",
],
"SDKROOT": "watchos",
"SWIFT_COMPILATION_MODE": "wholemodule",
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"TARGETED_DEVICE_FAMILY": "4",
])
}

func test_targetSettings_visionOSAplication() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .release,
platform: .visionOS,
product: .application,
swift: true)

// Then
assertEqualSettings(results, [
"CODE_SIGN_IDENTITY": "iPhone Developer",
"ASSETCATALOG_COMPILER_APPICON_NAME": "AppIcon",
"ENABLE_PREVIEWS": "YES",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
],
"SDKROOT": "xros",
"SWIFT_COMPILATION_MODE": "wholemodule",
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"TARGETED_DEVICE_FAMILY": "1,2,7",
])
}

func test_targetSettings_visionOSFramework() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .release,
platform: .visionOS,
product: .framework,
swift: true)

// Then
assertEqualSettings(results, [
"CODE_SIGN_IDENTITY": "",
"CURRENT_PROJECT_VERSION": "1",
"DEFINES_MODULE": "YES",
"DYLIB_COMPATIBILITY_VERSION": "1",
"DYLIB_CURRENT_VERSION": "1",
"DYLIB_INSTALL_NAME_BASE": "@rpath",
"INSTALL_PATH": "$(LOCAL_LIBRARY_DIR)/Frameworks",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
],
"PRODUCT_NAME": "$(TARGET_NAME:c99extidentifier)",
"SDKROOT": "xros",
"SKIP_INSTALL": "YES",
"SWIFT_COMPILATION_MODE": "wholemodule",
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"TARGETED_DEVICE_FAMILY": "1,2,7",
"VERSIONING_SYSTEM": "apple-generic",
"VERSION_INFO_PREFIX": "",
])
}

func test_targetSettings_visionOSExtension() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .release,
platform: .visionOS,
product: .appExtension,
swift: true)

// Then
assertEqualSettings(results, [
"CODE_SIGN_IDENTITY": "iPhone Developer",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
],
"SDKROOT": "xros",
"SWIFT_COMPILATION_MODE": "wholemodule",
"SWIFT_OPTIMIZATION_LEVEL": "-Owholemodule",
"TARGETED_DEVICE_FAMILY": "1,2,7",
])
}

func test_targetSettings_iOSUnitTests() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .debug,
Expand Down Expand Up @@ -236,6 +368,52 @@ class BuildSettingProviderTests: XCTestCase {
])
}

func test_targetSettings_visionOSUnitTests() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .debug,
platform: .visionOS,
product: .unitTests,
swift: true)

// Then
assertEqualSettings(results, [
"CODE_SIGN_IDENTITY": "iPhone Developer",
"SDKROOT": "xros",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
],
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)", "DEBUG"],
"SWIFT_COMPILATION_MODE": "singlefile",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"TARGETED_DEVICE_FAMILY": "1,2,7",
])
}

func test_targetSettings_visionOSUITests() {
// Given / When
let results = BuildSettingsProvider.targetDefault(variant: .debug,
platform: .visionOS,
product: .uiTests,
swift: true)

// Then
assertEqualSettings(results, [
"CODE_SIGN_IDENTITY": "iPhone Developer",
"SDKROOT": "xros",
"LD_RUNPATH_SEARCH_PATHS": [
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
],
"SWIFT_ACTIVE_COMPILATION_CONDITIONS": ["$(inherited)", "DEBUG"],
"SWIFT_COMPILATION_MODE": "singlefile",
"SWIFT_OPTIMIZATION_LEVEL": "-Onone",
"TARGETED_DEVICE_FAMILY": "1,2,7",
])
}

// MARK: - Helpers

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