rules_xcodeproj icon indicating copy to clipboard operation
rules_xcodeproj copied to clipboard

Bug: BazelDependencies invoked without any output groups set.

Open i-pavlov opened this issue 3 years ago • 2 comments

Hi, build buddy folks,

Thank you so much for the amazing tool that you are building! I'm evaluating the possibility of incremental migration to bazel by using rules_xcodeproj, so I'm trying different ways of injecting Bazel-generated xcodeproj into the existing project hierarchy.

I found the use case that looks like a bug and would like to share it with you. Sorry if It already was discussed and I missed it somewhere.

Describe the bug

I created the repository with a minimal example to reproduce the problem: https://github.com/i-pavlov/bazel-showcase.

Problem: BazelDependencies invoked without any output groups set.

The problem can be reproduced with the main branch of the repo.

  1. I generated the TestLibraryProj.pbxproj project for the TestLibrary library in build with Bazel mode.
  2. I opened generated pbxproj and manually added the CreatedByXcode swift static library. Configured TestLibrary as a dependency of CreatedByXcode + linked it. (Added fInal state of a pbxproj to the repo).

After that, I'm trying to compile it.

  1. Compiled TestLibrary target. -- OK
  2. Compiled CreatedByXcode target for iPhoneSimulator --- OK
  3. Cleared build forder by cmd + shift + K.
  4. Try to compile CreatedByXcode for iPhoneSimulator again. --- FAIL

BazelDependencies target fails with this error:

PhaseScriptExecution Bazel\ Build /Users/ipavlov/Library/Developer/Xcode/DerivedData/TestLibraryProj-cvqpnvxrtlvoggbdmzezjtqobhxy/Build/Intermediates.noindex/TestLibraryProj.build/rules_xcodeproj/BazelDependencies/Script-E8D57D94F21E7818DF296078.sh (in target 'BazelDependencies' from project 'TestLibraryProj')
    cd /Users/ipavlov/Developer/bazel-showcase
    /bin/sh -c /Users/ipavlov/Library/Developer/Xcode/DerivedData/TestLibraryProj-cvqpnvxrtlvoggbdmzezjtqobhxy/Build/Intermediates.noindex/TestLibraryProj.build/rules_xcodeproj/BazelDependencies/Script-E8D57D94F21E7818DF296078.sh

error: BazelDependencies invoked without any output groups set. Please file a bug report here: https://github.com/buildbuddy-io/rules_xcodeproj/issues/new?template=bug.md.

The same error happens every time I build the CreatedByXcode target. Clearing derived data helps to reset the state, but the problem happens again if re-run steps (1) - (4). The same thing happens not only with swift_library but also with ios_framework targets

Expected behavior

I'd expect to have consistent behavior before/after cleaning the build folder. Would be great if it will be possible to use targets from Bazel-generated projects as a dependency in other .xcodeproj.

Versions

  • Bazel: 5.2.0
  • rules_xcodeproj: 0.7.0
  • rules_apple: 1.0.1
  • rules_swift: 1.0.0
  • Xcode: 13.2.1 and 13.4.1

i-pavlov avatar Aug 06 '22 17:08 i-pavlov

rules_xcodeproj currently requires specially crafted schemes that have pre-build actions that provide information to the BazelDependencies target. That's what the error is referring to.

We've recently made progress on not needing that, as we can now tell which targets are being built, but it currently doesn't know which variant of a target is being built (e.g. device versus simulator).

This might be solved with Build with Bazel via Proxy, or we might solve it before then... but it's not a high priority for the 1.0 release.

I hadn't seriously considered how the project would interact with other projects in an xcworkspace. I'll have to think on that more.

An issue you might run into though is that not all Bazel targets will exist as Xcode targets. A big thing that rules_xcodeproj does is interopting with Bazel built things. Manually creating targets will most likely never work, as the project generator does a lot of work creating each target. - The general assumption is that your entire build graph can be built with Bazel. I think a tool that helps you migrate entirely to Bazel first, and using rules_xcodeproj's Build with Xcode mode, is a better incremental migration approach. I personally don't think one that uses Bazel for only part of the build graph is going to be easy to pull off.

brentleyjones avatar Aug 07 '22 00:08 brentleyjones

Thanks a lot for the detailed explanation! XCode mode looks promising for my scenario, will try it out

i-pavlov avatar Aug 07 '22 07:08 i-pavlov

I'm going to close as "not planned" for now.

brentleyjones avatar Aug 24 '22 13:08 brentleyjones