MobileNativeFoundation / rules_xcodeproj

Bazel rules for generating Xcode projects.
MIT License
514 stars 81 forks source link

Bug: bash failed: error executing AppleLipo command (from target @@rules_xcodeproj//tools/swiftc_stub:universal_swiftc_stub) #2941

Closed 315567599 closed 5 months ago

315567599 commented 5 months ago

Description

ERROR: /private/var/tmp/_bazel_jiangchao/11a172fb0b7bb90e1ea6fdb4f5a93109/rules_xcodeproj.noindex/build_output_base/external/rules_xcodeproj/tools/swiftc_stub/BUILD:37:23: AppleLipo external/rules_xcodeproj/tools/swiftc_stub/universal_swiftc_stub [for tool] failed: (Exit 1): bash failed: error executing AppleLipo command (from target @@rules_xcodeproj//tools/swiftc_stub:universal_swiftc_stub) (cd /private/var/tmp/_bazel_jiangchao/11a172fb0b7bb90e1ea6fdb4f5a93109/rules_xcodeproj.noindex/build_output_base/execroot/main && \ exec env - \ APPLE_SDK_PLATFORM=MacOSX \ APPLE_SDK_VERSION_OVERRIDE=14.2 \ PATH=/bin:/usr/bin \ XCODE_VERSION_OVERRIDE=15.2.0.15C500b \ /bin/bash -c 'mkdir -p '\''bazel-out/darwin_x86_64-opt-exec-applebin_macos-ST-6d839b844199/bin/external/rules_xcodeproj/tools/swiftc_stub'\'' && /usr/bin/lipo -create '\''bazel-out/darwin_arm64-opt-exec-macos-arm64-min12.0-applebin_macos-ST-9a51b9282f9b/bin/external/rules_xcodeproj/tools/swiftc_stub/swiftc_stub_binary'\'' '\''bazel-out/darwin_x86_64-opt-exec-macos-x86_64-min12.0-applebin_macos-ST-a9a3e02ffc9c/bin/external/rules_xcodeproj/tools/swiftc_stub/swiftc_stub_binary'\'' -output '\''bazel-out/darwin_x86_64-opt-exec-applebin_macos-ST-6d839b844199/bin/external/rules_xcodeproj/tools/swiftc_stub/universal_swiftc_stub'\''')

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: bazel-out/darwin_arm64-opt-exec-macos-arm64-min12.0-applebin_macos-ST-9a51b9282f9b/bin/external/rules_xcodeproj/tools/swiftc_stub/swiftc_stub_binary and bazel-out/darwin_x86_64-opt-exec-macos-x86_64-min12.0-applebin_macos-ST-a9a3e02ffc9c/bin/external/rules_xcodeproj/tools/swiftc_stub/swiftc_stub_binary have the same architectures (arm64) and can't be in the same fat output file

Reproduction steps

bt

Expected behavior

work

rules_xcodeproj version

1.16.0

Xcode version

15.2

Bazel version

7.0.2

rules_apple version

3.3.0

rules_swift version

1.16.0

Additional information

No response

mattrobmattrob commented 5 months ago

Can you please provide a reproduction case to help us understand your issue?

315567599 commented 5 months ago

Can you please provide a reproduction case to help us understand your issue?

change bazel version from 7.0.2 to 6.1.1, then it work. i don't know why...

brentleyjones commented 5 months ago

It looks like you are using the rules from source instead of the release archive (which has precompiled binaries in it). That's not an officially supported way of using rules_xcodeproj.

But it looks like you somehow have your platform or cpu overridden in a way that causes the universal_binary rule to produce two same-cpu slices. I would look into fixing that if you require using the project from source.

315567599 commented 5 months ago

It looks like you are using the rules from source instead of the release archive (which has precompiled binaries in it). That's not an officially supported way of using rules_xcodeproj.

But it looks like you somehow have your platform or cpu overridden in a way that causes the universal_binary rule to produce two same-cpu slices. I would look into fixing that if you require using the project from source.

current using method: git clone https://github.com/MobileNativeFoundation/rules_xcodeproj.git cd rules_xcodeproj & git checkout 1.16.0

then modify WORKSPACE: local_repository( name = "rules_xcodeproj", path = "build-system/bazel-rules/rules_xcodeproj", )

what's the supported ay of using rules_xcodeproj?

brentleyjones commented 5 months ago

The snippet in the release notes, which points to a release archive attached to the release. That archive has an optimized version of the ruleset, including precompiled binaries.

315567599 commented 5 months ago

But it looks like you somehow have your platform or cpu overridden in a way that causes the universal_binary rule to produce two same-cpu slices. I would look into fixing that if you require using the project from source.

I need using rules_xcodeproj from source, thanks very much。

315567599 commented 5 months ago

But it looks like you somehow have your platform or cpu overridden in a way that causes the universal_binary rule to produce two same-cpu slices. I would look into fixing that if you require using the project from source.

because history reason, our project deps a custom rules_apple version, so we require using rules_xcodeproj from source. i want to know what cause the issue (platform or cpu overridden), would you help me?

brentleyjones commented 5 months ago

I would recommend creating a release archive for your rules_xcodeproj and use that instead of from source: https://github.com/MobileNativeFoundation/rules_xcodeproj?tab=readme-ov-file#installation

As for the cpu or platform issue, I would look at any overrides you are doing for those flags. It's just a guess based on seeing errors like that before.

315567599 commented 5 months ago

Thank you so much. I would like to know more about the detailed working principle of rule_xcodeproj. Can you recommend some? Like this https://www.youtube.com/watch?v=B__SHnz3K3c

brentleyjones commented 5 months ago

I'm not sure I understand what you are requesting.