MobileNativeFoundation / MobileNativeFoundation/rules_xcodeproj

Bug: Internal precondition failure when generating xcode project.

Open
#3,090 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
626
Forks
124
PR merge metrics
No merged PRs in 30d

Description

Description

Under incremental generation mode, we hit Internal precondition failure when generating the xcode project. Specifically, the top level target is an ios_application with extensions. The error seems to indicate when creating scheme, the extension target ID is not found:

tools/generators/xcschemes/src/Generator/CreateScheme.swift:181: Extension Target ID "@@//:example_extension ios_arm64-dbg-ios-arm64-min18.0-applebin_ios-ST-a34dd529b319" not found in:
[@@//:example_control_widget ios_arm64-dbg-ios-arm64-min18.0-applebin_ios-ST-a34dd529b319, @@//:example_control_widget ios_sim_arm64-dbg-ios-sim_arm64-min18.0-applebin_ios-ST-3e8967f1473a]
Please file a bug report at https://github.com/MobileNativeFoundation/rules_xcodeproj/issues/new?template=bug.md

The project generation works fine if I set generation_mode = "legacy". But under legacy mode, building the project inside xcode will throw an error suggeting ld in the sandbox does not have the right permission:

error: unable to spawn process  `PATH_TO_PROJECT/example.xcodeproj/rules_xcodeproj/bazel/ld' (permission denied).

Indeed, ld only has permission -rw-r--r--. It goes away when I mannually grant +x permission.

Reproduction steps

Here's a self-contained, reproducible repo:
https://github.com/ztzhang/rules_xcodeproj_bug.

Expected behavior

Project generation works as expected, and build inside xcode works as expected.

rules_xcodeproj version

2.6.1, or 2.7.0

Xcode version

16.1 (beta) or 16.0

Bazel version

7.1.0

rules_apple version

3.8.0

rules_swift version

No response

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked rules_xcodeproj_bug repository to reproduce generation with the listed Bazel, Xcode, and rules versions. Then inspect tools/generators/xcschemes/src/Generator/CreateScheme.swift:181 and compare legacy and incremental generation. Done means the Xcode project generates and builds without the missing extension target or ld permission errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.