I'm try to build a library using swift_library and I'm getting a linking issue with libtool.
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "Valet",
srcs = glob(["Pods/Valet/*.swift"]),
)
MAC OS Catalina 10.5.6
bazel info release?bazel 3.5.0
No
ERROR: /Users/me/workspace/project/iOS/BUILD:4:14: Linking libValet.a failed (Exit 1): libtool failed: error executing command
(cd /private/var/tmp/_bazel_me/48adbf0c831f3ae216f4c0cd02649425/sandbox/darwin-sandbox/1/execroot/__main__ && \
exec env - \
APPLE_SDK_PLATFORM=MacOSX \
APPLE_SDK_VERSION_OVERRIDE=10.15 \
XCODE_VERSION_OVERRIDE=11.5.0.11E608c \
external/local_config_cc/libtool -no_warning_for_no_symbols -static -o bazel-out/darwin-fastbuild/bin/libValet.a -filelist bazel-out/darwin-fastbuild/bin/libValet.a-0.params)
Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox libtool failed: error executing command
(cd /private/var/tmp/_bazel_me/48adbf0c831f3ae216f4c0cd02649425/sandbox/darwin-sandbox/1/execroot/__main__ && \
exec env - \
APPLE_SDK_PLATFORM=MacOSX \
APPLE_SDK_VERSION_OVERRIDE=10.15 \
XCODE_VERSION_OVERRIDE=11.5.0.11E608c \
external/local_config_cc/libtool -no_warning_for_no_symbols -static -o bazel-out/darwin-fastbuild/bin/libValet.a -filelist bazel-out/darwin-fastbuild/bin/libValet.a-0.params)
Execution platform: @local_config_platform//:host
Use --sandbox_debug to see verbose messages from the sandbox
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file list file: bazel-out/darwin-fastbuild/bin/libValet.a-0.params_hashes.objlist is empty
Target //:Valet failed to build
I believe this happens when your glob doesn't match anything, can you verify some sources are actually being compiled here? You can probably change your glob to glob(["Pods/Valet/*.swift"], allow_empty=False) to error sooner
Thank you very much @keith , I just changed the rule to navigate sub-levels. The source code was actually in a source subfolder.
swift_library(
name = "Valet",
srcs = glob(["Pods/Valet/**/*.swift"]),
)
No problem! Sounds like should close this then?
Closing-- thanks @keith!