rules_xcodeproj icon indicating copy to clipboard operation
rules_xcodeproj copied to clipboard

Feature Request: Auto-discovery of top-level targets

Open thii opened this issue 3 years ago • 4 comments

In our current project generator, top-level targets are auto-discovered based on the provided target kinds. For example, if we request ios_application and ios_unit_test in the //path/to/package package, all ios_application and ios_unit_test targets defined in that package will be included in the generated project. The motivation is to remove the need to update the xcodeproj target whenever someone adds a new target.

The xcodeproj rule currently requires top-level targets to be explicitly specified via the top_level_targets attribute.

thii avatar Sep 05 '22 06:09 thii

Found this in the docs https://github.com/buildbuddy-io/rules_xcodeproj/blob/main/doc/design/high-level.md#defined-in-build-files, will use the recommended approach for now.

thii avatar Sep 05 '22 06:09 thii

There's a problem with the dynamic generation approach is that the workspace won't be a valid Bazel workspace until the generation is done, making the generation step a dependency of the build even if we build without the Xcode project.

thii avatar Sep 05 '22 08:09 thii

To work around the invalid workspace, we can write the BUILD file and any needed .bzl files into .rules_xcodeproj/. Users can add that to their .gitignore. The runner script will create the generator target in there. Only the runner script would invoke the generator target, so the workspace will never be in an invalid state.

brentleyjones avatar Feb 24 '23 20:02 brentleyjones

With https://github.com/buildbuddy-io/rules_xcodeproj/commit/9138d70a2955c9307f9c599e0d8655908d54e5e7, we now generate the BUILD and .bzl files for the generator target. That can be extended to be the result of a query.

brentleyjones avatar Mar 08 '23 15:03 brentleyjones