Skip to content

Commit

Permalink
Avoid generating a CompileAssetCatalog build phase by setting buildph…
Browse files Browse the repository at this point in the history
…ase to none for xcassets sources
  • Loading branch information
amberdixon committed Apr 16, 2020
1 parent 6b4f101 commit 3e2292f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
1 change: 1 addition & 0 deletions rules/test_host_app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports_files([
ios_application(
name = "iOS-%s-AppHost" % version,
srcs = ["main.m"],
resource_bundles = {"iOS-AppHost-Resources": glob(["AssetCatalogFixture.xcassets/**"])},
bundle_id = "com.example.ios-app-host-%s" % version,
entitlements = "ios.entitlements",
families = [
Expand Down
19 changes: 14 additions & 5 deletions rules/xcodeproj.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,21 @@ def _xcodeproj_impl(ctx):
xcodeproj_schemes_by_name = {}
for target_info in targets:
target_macho_type = "staticlib" if target_info.product_type == "framework" else "$(inherited)"
xcode_sources = []
for s in target_info.srcs.to_list():
src_info = {
"path": paths.join(src_dot_dots, s.short_path),
"group": paths.dirname(s.short_path),
"optional": True,
}
if ".xcassets" in s.path:
# By default, xcasset files are associated with the CompileAssetCatalog build phase.
# Since we do not know how to stub out xcode's CompileAssetCatalog implementation (yet), we
# will just avoid adding this file to a build phase.
src_info['buildPhase'] = 'none'
xcode_sources.append(src_info)
xcodeproj_targets_by_name[target_info.name] = {
"sources": [{
"path": paths.join(src_dot_dots, s.short_path),
"group": paths.dirname(s.short_path),
"optional": True,
} for s in target_info.srcs.to_list()],
"sources": xcode_sources,
"type": target_info.product_type,
"platform": "iOS",
"settings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
730017487BA898EFDC8A3A98 /* resource_bundle.plist in Resources */ = {isa = PBXBuildFile; fileRef = AB7BB9505A64B479DA80B398 /* resource_bundle.plist */; };
8C6CBF1D63DD7DAAE1B93DDE /* test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FF81A9585DBB110EBD9CAC0 /* test.swift */; };
D49E54C698B02F6802182B95 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 219EC613C66D223DC34C2B88 /* main.m */; };
/* End PBXBuildFile section */
Expand All @@ -17,6 +18,9 @@
48A8F4B41EF706F8BEEC7ACB /* Single-Application-UnitTests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = "Single-Application-UnitTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
5FF81A9585DBB110EBD9CAC0 /* test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = test.swift; path = test.swift; sourceTree = "<group>"; };
8DBB99CE021DEB0B97F196EA /* common.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.pch; path = ../../rules/library/common.pch; sourceTree = "<group>"; };
AB7BB9505A64B479DA80B398 /* resource_bundle.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = resource_bundle.plist; path = ../../rules/library/resource_bundle.plist; sourceTree = "<group>"; };
BDFE1D6BB539968405F979CA /* Single_Application_UnitTests-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Single_Application_UnitTests-Swift.h"; path = "Single_Application_UnitTests-Swift.h"; sourceTree = "<group>"; };
C7D23D76EAC581CB42F9ECC8 /* Contents.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = Contents.json; path = ../../rules/test_host_app/AssetCatalogFixture.xcassets/Contents.json; sourceTree = "<group>"; };
E8189BFE61671DD0C36CBACF /* ios.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = ios.entitlements; path = ../../rules/test_host_app/ios.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -41,6 +45,7 @@
21BA00DCD3A39A744A656EFC /* test_host_app */ = {
isa = PBXGroup;
children = (
995075BD7E686FB0D1912DF2 /* AssetCatalogFixture.xcassets */,
E8189BFE61671DD0C36CBACF /* ios.entitlements */,
219EC613C66D223DC34C2B88 /* main.m */,
);
Expand All @@ -59,6 +64,7 @@
7497927D750CB1417F6A9CB5 /* xcodeproj */ = {
isa = PBXGroup;
children = (
BDFE1D6BB539968405F979CA /* Single_Application_UnitTests-Swift.h */,
5FF81A9585DBB110EBD9CAC0 /* test.swift */,
);
name = xcodeproj;
Expand All @@ -73,10 +79,19 @@
);
sourceTree = "<group>";
};
995075BD7E686FB0D1912DF2 /* AssetCatalogFixture.xcassets */ = {
isa = PBXGroup;
children = (
C7D23D76EAC581CB42F9ECC8 /* Contents.json */,
);
name = AssetCatalogFixture.xcassets;
sourceTree = "<group>";
};
D099E71665C7B6C5389FAEDF /* library */ = {
isa = PBXGroup;
children = (
8DBB99CE021DEB0B97F196EA /* common.pch */,
AB7BB9505A64B479DA80B398 /* resource_bundle.plist */,
);
name = library;
sourceTree = "<group>";
Expand Down Expand Up @@ -106,6 +121,7 @@
buildPhases = (
0F6F1388627E323C028D8330 /* Build with bazel */,
623E27DB6A1344826F4BD432 /* Sources */,
CDF0E15D1AD50142030A0441 /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -144,6 +160,17 @@
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
CDF0E15D1AD50142030A0441 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
730017487BA898EFDC8A3A98 /* resource_bundle.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
0D18E1226C90BD70CED2E4C6 /* Build with bazel */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
Binary file not shown.

0 comments on commit 3e2292f

Please sign in to comment.