Compiling iOS frameworks for Mac Catalyst does not work
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
MacOS Catalyst was a feature Apple introduced in 2019 which allowed developers to deploy their iOS applications onto macOS without modification by shimming / emulating the UIKit API.
Bazel has a catalyst ApplePlatform which was introduced around the same time but it's currently broken:
https://github.com/bazelbuild/bazel/blob/dd000460e58bb5ca332676b48810ee381a37a2d0/src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java#L42
There is already some discussion of this issue on the rules_apple side:
https://github.com/bazelbuild/rules_apple/issues/658
In order to get this working, @Keith said we need to fix the crosstool logic to support building for the catalyst platform.
The root of the issue seems to be that crosstool doesn't support the catalyst CPU identifier:
https://github.com/bazelbuild/bazel/blob/86b800e4066389d4535fbdf280cfe9447b06df15/tools/osx/crosstool/cc_toolchain_config.bzl
It looks like rules_swift already has support for this with the catalyst_x86_64 CPU:
https://github.com/bazelbuild/rules_swift/blob/e0009f99e767c8ca962c22a849849f0c3c7d814c/swift/internal/BUILD
So we can build swift_frameworks for Mac Catalyst but if we want to link these into an ios_application or use any objc dependencies we're currently blocked.
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Compile an ios_framework for Mac Catalyst with `--apple_platform_type=catalyst` and note that the Info.plist of the resulting framework has `"DTPlatformName" => "iphonesimulator"`. Also when you try to use this framework you'll get the error: `Both 'ios-x86_64-simulator' and 'ios-arm64_x86_64-simulator' represent two equivalent library definitions.`
### Which operating system are you running Bazel on?
macOS 13.2 Ventura
### What is the output of `bazel info release`?
release 6.0.0
### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.
_No response_
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Start with src/main/java/com/google/devtools/build/lib/rules/apple/ApplePlatform.java and tools/osx/crosstool/cc_toolchain_config.bzl, then compare the catalyst_x86_64 support in rules_swift's swift/internal/BUILD. Reproduce with --apple_platform_type=catalyst and inspect the framework's Info.plist and linker output. Done means the catalyst framework reports the correct platform and no longer produces the equivalent library definitions error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ios, java, macos, swift
- Domain
- build-system, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100