bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Command to generate project file for Xcode or IntelliJ

Open adamhowardprice opened this issue 11 years ago • 7 comments

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.

adamhowardprice avatar Oct 28 '15 20:10 adamhowardprice

Why wouldn't you do bazel build <ProjectName>.xcodeproj/project.pbxproj?

kchodorow avatar Oct 28 '15 20:10 kchodorow

When working with Xcode as an IDE, it may be desirable to regenerate an Xcode project separate from the actual building of the target.

adamhowardprice avatar Oct 28 '15 21:10 adamhowardprice

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 avatar Oct 28 '15 21:10 adamhowardprice

@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. :)

philwo avatar Oct 28 '15 21:10 philwo

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

adamhowardprice avatar Oct 28 '15 21:10 adamhowardprice

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.

kchodorow avatar Oct 28 '15 21:10 kchodorow

Got it! Thanks!

adamhowardprice avatar Oct 28 '15 22:10 adamhowardprice