Build rule for compiling objc binaries for Mac OS X
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").
Adding @Aragos for comment.
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.
Is this on a roadmap somewhere? It'd be really helpful on one of my projects.
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.
OK. For now, I've been able to get away with cc_library and adding -ObjC to copts.
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.
I have no idea how far the people who work on that are. Maybe @dmaclach or @aragos knows.
Sorry to bump again, but can we get an update on this? Any accepted solutions? Workarounds?
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
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
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!
We hit that today. So is objc* an option for OSX by now or not?
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.
Friendly Ping :)

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 :)
Any updates here?
Closing out this obsolete issue; build rules for macOS have been available for quite some time in https://github.com/bazelbuild/rules_apple.
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.
this issue is about ObjC binaries, not objc_library
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.