Skip to content

Commit e08bae6

Browse files
committed
Define RESOURCES_UI_FRAMEWORK_FAMILY in the xcspec
Presently this value is taken from SDKSettings. Define it closer to the build setting itself so that it's more obvious how this is used.
1 parent fec0f3e commit e08bae6

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

Sources/SWBApplePlatform/Specs/AssetCatalogCompiler.xcspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@
284284
{
285285
Name = "RESOURCES_UI_FRAMEWORK_FAMILY";
286286
Type = String;
287-
CommandLineFlag = "--ui-framework-family";
287+
Condition = "$(IS_MACCATALYST)";
288+
CommandLineArgs = ("--ui-framework-family", "uikit");
288289
},
289290

290291
// COMPRESS_PNG_FILES is defined by CopyPNGFile.xcspec

Tests/SWBTaskConstructionTests/AssetCatalogTaskConstructionTests.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,60 @@ fileprivate struct AssetCatalogTaskConstructionTests: CoreBasedTests {
577577
}
578578
}
579579

580+
/// `--ui-framework-family uikit` should be passed to actool when (and only when) building for
581+
/// Mac Catalyst.
582+
@Test(.requireSDKs(.macOS, .iOS))
583+
func uiFrameworkFamilyForMacCatalyst() async throws {
584+
let actoolPath = try await self.actoolPath
585+
try await withTemporaryDirectory { tmpDir in
586+
let testProject = TestProject(
587+
"aProject",
588+
sourceRoot: tmpDir,
589+
groupTree: TestGroup("Root", children: [
590+
TestFile("Assets.xcassets"),
591+
]),
592+
buildConfigurations: [
593+
TestBuildConfiguration("Debug", buildSettings: [
594+
"ASSETCATALOG_EXEC": actoolPath.str,
595+
"AD_HOC_CODE_SIGNING_ALLOWED": "YES",
596+
"CODE_SIGN_IDENTITY": "-",
597+
"GENERATE_INFOPLIST_FILE": "YES",
598+
"PRODUCT_NAME": "$(TARGET_NAME)",
599+
"SDKROOT": "iphoneos",
600+
"SUPPORTS_MACCATALYST": "YES",
601+
"TARGETED_DEVICE_FAMILY": "2,6",
602+
])
603+
],
604+
targets: [
605+
TestStandardTarget(
606+
"App",
607+
type: .framework,
608+
buildPhases: [
609+
TestResourcesBuildPhase(["Assets.xcassets"]),
610+
])
611+
]
612+
)
613+
614+
let tester = try await TaskConstructionTester(getCore(), testProject)
615+
616+
// When building for Mac Catalyst, --ui-framework-family uikit should be emitted.
617+
await tester.checkBuild(runDestination: .macCatalyst) { results in
618+
results.checkTask(.matchRuleType("CompileAssetCatalogVariant"), .matchRuleItem("thinned")) { task in
619+
task.checkCommandLineContainsUninterrupted(["--ui-framework-family", "uikit"])
620+
}
621+
results.checkNoDiagnostics()
622+
}
623+
624+
// When building for iOS device (not Mac Catalyst), the flag should NOT be emitted.
625+
await tester.checkBuild(runDestination: .iOS) { results in
626+
results.checkTask(.matchRuleType("CompileAssetCatalogVariant"), .matchRuleItem("thinned")) { task in
627+
task.checkCommandLineDoesNotContain("--ui-framework-family")
628+
}
629+
results.checkNoDiagnostics()
630+
}
631+
}
632+
}
633+
580634
/// When asset symbol generation is disabled, the asset catalog must stay in the Resources phase
581635
/// and not be moved to Sources. This matters for projects where the xcassets is generated by a
582636
/// preceding script phase and doesn't exist during Sources processing.

0 commit comments

Comments
 (0)