Bug: Resource groups appear in a project with a target focusing
Describe the bug
In BwB mode, resource group files are included in the project even if the target is unfocused. There is no way to unfocus them.
Example
We have a swift library:
swift_library(
name = "SomeSwiftLibrary",
data = ["//Some:SomeSwiftLibrary_Resources"]
)
and a resource group:
apple_resource_group(
name = "SomeSwiftLibrary_Resources",
resources = [
"/Some:Resources/asset.xcassets/Contents.json",
"/Some:Resources/asset.xcassets/Contents.json",
"/Some:Resources/asset.xcassets/image.imageset/image.png",
"/Some:Resources/asset.xcassets/image.imageset/[email protected]",
"//Some:Resources/asset.xcassets/image.imageset/[email protected]"
],
)
Even if we add //Some:SomeSwiftLibrary_Resources and //Some:SomeSwiftLibrary to unfocused_targets, the asset.xcassets will still be present in the project.
xcodeproj(
name = "xcodeproj",
project_name = "Project",
build_mode = "bazel",
top_level_targets = ["//iOSApp"],
focused_targets = [...], // do not contain `SomeSwiftLibrary`
unfocused_targets = ["/Some:SomeSwiftLibrary", "//Some:SomeSwiftLibrary_Resources"],
)
Expected behavior
If a target is not focused, all of its resource files should not appear in the project.
Seems we will need to associate owner to resources and extra_files in internal/resources.bzl, instead of just the file_paths. Then when we process those in xcodeproj_rule.bzl, at least for top-level bundles that aren't resource bundles, we can filter those files to only ones in focused_labels.
I've tried to put the resources into the unfocused_targets declaration, but it didn't work too. The focus mode is amazing and this project is what makes Bazel productive for our project. Please let me know if I can help with something, this bugfix is very important to us. Again, thank you for this project!
Hi @narlei. My above comment still holds for how I would go about trying to fix this, if you want to take a stab at it. Though it should be noted, right now you can unfocus resource bundles, just not resource groups.