MobileNativeFoundation / MobileNativeFoundation/rules_xcodeproj

Bug: Project generation error with C++ libraries

Open
#3,278 0 comments 1 reaction 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

I'm getting the following error when attempting to generate an Xcode project from a minimal reproducible. For my real code, I'm seeing it for every C++ library we have in the build.

% bazel run :xcodeproj
(10:48:16) INFO: Current date is 2026-02-19
(10:48:16) INFO: Analyzed target //:xcodeproj (2 packages loaded, 11 targets configured).
(10:48:16) INFO: Found 1 target...
Target //:xcodeproj up-to-date:
  bazel-bin/xcodeproj-runner.sh
(10:48:16) INFO: Elapsed time: 0.332s, Critical Path: 0.03s
(10:48:16) INFO: 11 processes: 10 internal, 1 local.
(10:48:16) INFO: Build completed successfully, 11 total actions
(10:48:16) INFO: Running command line: bazel-bin/xcodeproj-runner.sh

Generating "bazel_test.xcodeproj"
Starting local Bazel server (9.0.0) and connecting to it...
(10:48:18) INFO: Current date is 2026-02-19
(10:48:22) ERROR: /Users/<redacted>/Library/Caches/bazel/_bazel_<redacted>/61126fd48924fbe64a0ab9748ad912bf/rules_xcodeproj.noindex/build_output_base/external/protobuf+/bazel/private/toolchains/prebuilt/BUILD.bazel:25:20: in @@rules_xcodeproj++internal+rules_xcodeproj_generated//generator/xcodeproj:defs.bzl%_aspect aspect on protoc_authenticity rule @@protobuf+//bazel/private/toolchains/prebuilt:authenticity_validation: 
Traceback (most recent call last):
	File "/Users/<redacted>/Library/Caches/bazel/_bazel_<redacted>/61126fd48924fbe64a0ab9748ad912bf/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj+/xcodeproj/internal/xcodeproj_aspect.bzl", line 120, column 35, in _xcodeproj_aspect_impl
		info = xcodeprojinfos.make(
	File "/Users/<redacted>/Library/Caches/bazel/_bazel_<redacted>/61126fd48924fbe64a0ab9748ad912bf/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj+/xcodeproj/internal/xcodeprojinfos.bzl", line 782, column 60, in _make_xcodeprojinfo
		automatic_target_info = calculate_automatic_target_info(
	File "/Users/<redacted>/Library/Caches/bazel/_bazel_<redacted>/61126fd48924fbe64a0ab9748ad912bf/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj+/xcodeproj/automatic_target_info.bzl", line 309, column 40, in calculate_automatic_target_info
		this_target_type = _get_target_type(target = target)
	File "/Users/<redacted>/Library/Caches/bazel/_bazel_<redacted>/61126fd48924fbe64a0ab9748ad912bf/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj+/xcodeproj/automatic_target_info.bzl", line 36, column 15, in _get_target_type
		if CcInfo in target:
Error: Type Target only supports querying by object constructors, got NoneType instead
(10:48:22) ERROR: Analysis of target '@@protobuf+//bazel/private/toolchains/prebuilt:authenticity_validation' (config: 75e7ef6) failed
(10:48:22) INFO: Analyzed target @@rules_xcodeproj++internal+rules_xcodeproj_generated//generator/xcodeproj:xcodeproj (179 packages loaded, 5007 targets configured, 5 aspect applications).
(10:48:22) WARNING: errors encountered while analyzing target '@@rules_xcodeproj++internal+rules_xcodeproj_generated//generator/xcodeproj:xcodeproj', it will not be built.
(10:48:22) INFO: Found 0 targets...
(10:48:22) ERROR: command succeeded, but not all targets were analyzed
(10:48:22) INFO: Elapsed time: 4.762s, Critical Path: 0.01s
(10:48:22) INFO: 1 process: 1 internal.
(10:48:22) ERROR: Build did NOT complete successfully
(10:48:22) ERROR: Build failed. Not running target
Reproduction steps
  1. Download/extract bazel_test.zip
  2. Run bazel build //... in the extracted folder to confirm it builds without issues.
  3. Run bazel run :xcodeproj

Note: I do not have any .bazelrc files in use, locally or globally.

Expected behavior

I would expect a .xcodeproj file to be generated.

rules_xcodeproj version

3.6.0

Xcode version

26.0.1

Bazel version

9.0.0

rules_apple version

4.3.3

rules_swift version

N/A

Additional information

This does not happen with just the protobuf compilation. The same error happens with C++ libraries as well, with libraries compiled natively using cc_library, libraries imported with cc_import, as well as external cmake libraries built using rules_foreign_cc. In all cases, the build itself completes without errors.

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

Start by reproducing the failure with bazel build //... followed by bazel run :xcodeproj from bazel_test.zip. Trace the reported path through xcodeproj_aspect.bzl, xcodeprojinfos.bzl, and automatic_target_info.bzl, especially _get_target_type; done means the minimal reproduction generates a .xcodeproj successfully for the affected C++ targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.