Command to generate project file for Xcode or IntelliJ
For example, Bazel automatically generates a <ProjectName>.xcodeproj/project.pbxproj file when you use bazel build. Is there any way to generate an IDE project file without building the target? This could be either a top-level command like bazel project (similar to buck project) or an option on bazel build to just generate the project file.
Why wouldn't you do bazel build <ProjectName>.xcodeproj/project.pbxproj?
When working with Xcode as an IDE, it may be desirable to regenerate an Xcode project separate from the actual building of the target.
One example: When starting down the road of converting a non-Bazel project to a Bazel project, I'd like to first rough in some BUILD files to get the project generating in Xcode, and then tweak things to eventually get it to build. I can't do that today because bazel build attempts to both generate the xcodeproj and also build the target which outputs the .ipa. I think most users would consider these two separate actions that merit two separate commands.
@adamhowardprice I think if you literally run bazel build <ProjectName>.xcodeproj/project.pbxproj, it should only generate the project file, even if it doesn't / can't build the whole project yet. :)
Oh, I didn't know it's supposed to work like that.
In the https://github.com/bazelbuild/examples project, it doesn't seem to work that way.
$ bazel build bazel-bin/ios-app/ios-app.xcodeproj/project.pbxproj
ERROR: couldn't determine target from filename 'bazel-bin/ios-app/ios-app.xcodeproj/project.pbxproj'.
INFO: Elapsed time: 0.904s
$ bazel build ios-app.xcodeproj/project.pbxproj
ERROR: couldn't determine target from filename 'ios-app.xcodeproj/project.pbxproj'.
INFO: Elapsed time: 0.959s
You don't use the bazel-bin prefix. I think it'd be something like:
bazel build //ios-app:ios-app.xcodeproj/project.pbxproj
It's not defined in the build file, but it's an implicit target of objc_binary (I'd assume), so you should be able to specify it as a build target.
Got it! Thanks!