bazelbuild / bazelbuild/rules_apple

`ios_build_test` and `ios_application ` cannot be directly used with default platform from apple_support

Open
#2,410 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
593
Forks
334
Avg merge
16h 48m
Merged PRs (30d)
9

Description

on Bazel 7.0.2 and rule_apple 3.3.0, I'm unable to use `ios_build_test` and `ios_application` with the default platform from apple_support.

Here's a minimum example with a hello world `ios_build_test` target.
https://github.com/yyuting/bazel_apple_platform/tree/main

The target is set to only be compatible with ios arm64 device (not simulator).

Build succeeds with a custom platform and explicit platform mapping:

`bazel test //:ios_build_tests --platforms=//:platform_ios`

But building with the default `ios_arm64` platform from apple_support would fail, it seems apple rules is picking up ios_sim_arm64 for the cc_library that the ios_build_test target depends on.

`bazel test //:ios_build_tests --platforms=@build_bazel_apple_support//platforms:ios_arm64`

Here's the error message:
```
Target //:ios_build_tests failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: Analysis of target '//:ios_build_tests' failed; build aborted: Target //:ios_build_tests is incompatible and cannot be built, but was explicitly requested.
Dependency chain:
//:ios_build_tests (7e114e)
//:hello_world (9a2e98) <-- target platform (@@build_bazel_apple_support//platforms:ios_sim_arm64) didn't satisfy constraint @@platforms//:incompatible
INFO: Elapsed time: 0.097s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in the linked minimum example with //:ios_build_tests, comparing the custom //:platform_ios invocation with @build_bazel_apple_support//platforms:ios_arm64. Trace why the default platform selects ios_sim_arm64 for //:hello_world; done means the default ios_arm64 platform builds and tests the device-only target successfully.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.