bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Build rule for compiling objc binaries for Mac OS X

Open trevorgray opened this issue 11 years ago • 20 comments

It looks like objc_binary is currently for iOS applications. It would be nice to provide a build rule that builds Mac OS X applications (ie. "foo.app").

trevorgray avatar Apr 15 '15 23:04 trevorgray

Adding @Aragos for comment.

kchodorow avatar Apr 16 '15 15:04 kchodorow

The objective C rules currently don't support targeting OS X, they have some of hardcoded stuff that's particular to iOS. Eventually we should parametrize them using some kind of declarative tool chain and then it should be much easier to build targeting OS X.

aragos avatar Apr 16 '15 15:04 aragos

Is this on a roadmap somewhere? It'd be really helpful on one of my projects.

mbeards avatar Jun 07 '15 20:06 mbeards

The swappable objc toolchain support is likely to happen within the next 2-3 months. While I'm unlikely to add an OS X toolchain myself that should at least make it much easier to add one for anyone who wants to contribute.

aragos avatar Jun 09 '15 14:06 aragos

OK. For now, I've been able to get away with cc_library and adding -ObjC to copts.

mbeards avatar Jun 09 '15 22:06 mbeards

Have you guys made any progress on this? I want to use Bazel for a cross-platform project I'm working on but the lack of OS X rules is really a show-stopper.

technoir42 avatar Apr 05 '16 19:04 technoir42

I have no idea how far the people who work on that are. Maybe @dmaclach or @aragos knows.

damienmg avatar Apr 05 '16 20:04 damienmg

Sorry to bump again, but can we get an update on this? Any accepted solutions? Workarounds?

dflems avatar Apr 13 '16 17:04 dflems

We are currently working on exposing a lot more of the objc compilation logic to skylark so that in a few weeks/months it should be much easier to write custom bundling logic (which is one of the main differences between iOS and OS X). While I'm not sure whether we'll provide our own rule targeting OS X that should make it fairly simple for you to write your own while using existing compilation infrastructure.

On Wed, Apr 13, 2016 at 1:34 PM, Dan Fleming [email protected] wrote:

Sorry to bump again, but can we get an update on this? Any accepted solutions? Workarounds?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/bazelbuild/bazel/issues/125#issuecomment-209557454

aragos avatar Apr 13 '16 18:04 aragos

I don't want to make any guarantees either, but I am very interested in having a Mac OS X rule available.

On Wed, Apr 13, 2016 at 11:02 AM, aragos [email protected] wrote:

We are currently working on exposing a lot more of the objc compilation logic to skylark so that in a few weeks/months it should be much easier to write custom bundling logic (which is one of the main differences between iOS and OS X). While I'm not sure whether we'll provide our own rule targeting OS X that should make it fairly simple for you to write your own while using existing compilation infrastructure.

On Wed, Apr 13, 2016 at 1:34 PM, Dan Fleming [email protected] wrote:

Sorry to bump again, but can we get an update on this? Any accepted solutions? Workarounds?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/bazelbuild/bazel/issues/125#issuecomment-209557454

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/bazelbuild/bazel/issues/125#issuecomment-209570885

dmaclach avatar Apr 14 '16 04:04 dmaclach

Just saw this commit got merged in yesterday, which looks like a step toward exposing ObjC rules to Skylark. Very encouraging. Some documentation or further comments about the plans for this w/r/t OS X builds would be super useful!

adamhowardprice avatar Apr 14 '16 16:04 adamhowardprice

We hit that today. So is objc* an option for OSX by now or not?

abergmeier-dsfishlabs avatar Jul 20 '16 08:07 abergmeier-dsfishlabs

We're currently doing a large refactoring of the objc rules' backend to use a crosstool (like https://github.com/bazelbuild/bazel/blob/master/tools/cpp/CROSSTOOL) to encode differences between platforms. Once that work is complete, building for OSX should be a simple matter of writing an appropriate toolchain in the crosstool.

That work targets end of year. Since OSX support will be easy once that milestone is reached, we're not prioritizing OSX support in the current objc rules (since that code is going away in a few months). However, if anyone is seriously interested in contributing that, we can look into whether or not its feasible and how much work it would be.

calpeyser avatar Jul 20 '16 18:07 calpeyser

Friendly Ping :)

Ping

StevenEWright avatar Mar 28 '17 17:03 StevenEWright

In addition to the objc-to-CROSSTOOL work that @calpeyser mentioned, there has also been an ongoing effort to move the application bundling rules for Apple platforms to Skylark that we hope to have released in the coming weeks. Once both of those pieces are in place we plan to have some macOS rules ready for folks to try out.

So... things are happening. Please stay tuned :)

allevato avatar Mar 28 '17 17:03 allevato

Any updates here?

perezd avatar Jul 18 '17 04:07 perezd

Closing out this obsolete issue; build rules for macOS have been available for quite some time in https://github.com/bazelbuild/rules_apple.

allevato avatar Nov 19 '18 15:11 allevato

It seems still we need to set the command-line flag, apple_platform_type to macos to compile objc_library for macOS (https://github.com/bazelbuild/bazel/pull/6366). The flag is defaulted to ios.

kangnak avatar Nov 21 '18 01:11 kangnak

this issue is about ObjC binaries, not objc_library

sergiocampama avatar Nov 21 '18 05:11 sergiocampama

In addition to what @sergiocampama said, there should really be no assumption that building a *_library target at the top level will use a particular configuration; changing the default just inverts the set of people who need to set the flag, and many objc_libraries are valid for multiple configurations. Building an {ios,macos,tvos,watchos}_application that depends on that library will cause it to inherit the correct configuration, but I would argue that building a library target should require the configuration be explicitly specified since it won't be found elsewhere.

allevato avatar Nov 21 '18 15:11 allevato