bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.21k stars 4.06k forks source link

using VisionOS SDK for objc_library #21865

Closed junlinp closed 7 months ago

junlinp commented 7 months ago

Description of the bug:

I want to build a static library for visionos in a M1 macbook.I found objc_library always use the MacOS SDK instread of visionos SDK.is there any solution?

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Build a obj-c file included a header file "ARKit/ARKit.h"

Which operating system are you running Bazel on?

MacOS 14.3.1 (23D60)

What is the output of bazel info release?

release 7.1.1-homebrew

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 HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

ObjcCompile command (cd /private/var/tmp/_bazel_dm-mac/5371362d7d37b79420f931ccb30dd502/sandbox/darwin-sandbox/24/execroot/_main && \ exec env - \ APPLE_SDK_PLATFORM=MacOSX \ APPLE_SDK_VERSION_OVERRIDE=14.4 \ DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \ PATH=/Applications/Unity/Hub/Editor/2022.3.16f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools:/opt/homebrew/opt/openjdk@11/bin:/opt/homebrew/opt/openjdk/bin:/Applications/Unity/Hub/Editor/2022.3.16f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools:/opt/homebrew/opt/openjdk@11/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Unity/Hub/Editor/2022.3.16f1/PlaybackEngines/AndroidPlayer/SDK/platform-tools:/opt/homebrew/opt/openjdk@11/bin:/opt/homebrew/opt/openjdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin \ SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk \ TMPDIR=/var/folders/nc/hnhbt_bs3xv2g4gz3kddc1jc0000gn/T/ \ XCODE_VERSION_OVERRIDE=15.3.0.15E204a \ ZERO_AR_DATE=1 \ /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_dm-mac/5371362d7d37b79420f931ccb30dd502/sandbox/darwin-sandbox/24/sandbox.sb /var/tmp/_bazel_dm-mac/install/79a8adbc010ff6cca11c16dd4820b668/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_dm-mac/5371362d7d37b79420f931ccb30dd502/sandbox/darwin-sandbox/24/stats.out' external/local_config_apple_cc/wrapped_clang -target arm64-apple-macosx14.4 '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-fdebug-prefix-map=BAZEL_EXECUTION_ROOT=.' '-fdebug-prefix-map=BAZEL_XCODE_DEVELOPER_DIR=/PLACEHOLDER_DEVELOPER_DIR' '-Werror=incompatible-sysroot' -Wshorten-64-to-32 -Wbool-conversion -Wconstant-conversion -Wduplicate-method-match -Wempty-body -Wenum-conversion -Wint-conversion -Wunreachable-code -Wmismatched-return-types -Wundeclared-selector -Wuninitialized -Wunused-function -Wunused-variable -iquote . -iquote bazel-out/darwin_arm64-fastbuild/bin -MD -MF bazel-out/darwin_arm64-fastbuild/bin/platform/iOS/_objs/hand_gesture_system/arc/hand_gesture_system.d -DOS_MACOSX -fno-autolink -isysroot BAZEL_XCODE_SDKROOT -FBAZEL_XCODE_SDKROOT/System/Library/Frameworks -FBAZEL_XCODE_DEVELOPER_DIR/Platforms/XROS.platform/Developer/Library/Frameworks -fobjc-arc '-fdiagnostics-color=always' -target arm64-apple-xros1.1 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk -DOS_XROS -I/Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/Metal.framework/Headers/ -O0 '-DDEBUG=1' -c platform/iOS/hand_gesture_system.m -o bazel-out/darwin_arm64-fastbuild/bin/platform/iOS/_objs/hand_gesture_system/arc/hand_gesture_system.o) In file included from platform/iOS/hand_gesture_system.m:1: In file included from ./platform/iOS/hand_gesture_system.h:4: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/ARKit.framework/Headers/ARKit.h:38: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/ARKit.framework/Headers/plane_detection.h:15: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS1.1.sdk/System/Library/Frameworks/ARKit.framework/Headers/scene_reconstruction.h:13: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:10: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLBlitCommandEncoder.h:12: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLResourceStateCommandEncoder.h:12: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLTexture.h:15: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurface.h:13: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h:13:10: fatal error: 'xpc/xpc.h' file not found

include <xpc/xpc.h>

     ^~~~~~~~~~~
keith commented 7 months ago

objc_library is platform independent. To build for visionOS you use objc_library as normal, but then you wrap it in a visionOS specific rule, you can find those here https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-visionos.md