Context: https://github.com/material-foundation/material-text-accessibility-ios/pull/28/files
I am attempting to build an iOS repository with a mixture of Swift and Objective-C libraries. It seems to break when I try to build a swift_library, while objc_library targets seem to build fine.
git clone https://github.com/jverkoey/material-text-accessibility-ios.git
cd material-text-accessibility-ios
git checkout upgrade
bazel test //... --apple_platform_type=ios --ios_minimum_os=9.0
# Output:
INFO: Writing tracer profile to '/private/var/tmp/_bazel_featherless/47449ac432b212324a64889579370bdd/command.profile.gz'
ERROR: /private/var/tmp/_bazel_featherless/47449ac432b212324a64889579370bdd/external/com_google_protobuf/BUILD:148:1: no such package '@zlib//': The repository '@zlib' could not be resolved and referenced by '@com_google_protobuf//:protobuf'
ERROR: Analysis of target '//:UnitTestsSwiftLib' failed; build aborted: no such package '@zlib//': The repository '@zlib' could not be resolved
INFO: Elapsed time: 0.115s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
Note that the following does succeed:
bazel build //:MDFTextAccessibility --apple_platform_type=ios --ios_minimum_os=9.0
But the following fails:
bazel build //:UnitTestsSwiftLib --apple_platform_type=ios --ios_minimum_os=9.0
INFO: Writing tracer profile to '/private/var/tmp/_bazel_featherless/47449ac432b212324a64889579370bdd/command.profile.gz'
ERROR: /private/var/tmp/_bazel_featherless/47449ac432b212324a64889579370bdd/external/com_google_protobuf/BUILD:148:1: no such package '@zlib//': The repository '@zlib' could not be resolved and referenced by '@com_google_protobuf//:protobuf'
ERROR: Analysis of target '//:UnitTestsSwiftLib' failed; build aborted: no such package '@zlib//': The repository '@zlib' could not be resolved
INFO: Elapsed time: 0.096s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
macOS Mojave 10.14.6
bazel info release?release 1.0.0
git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?[email protected]:material-foundation/material-text-accessibility-ios.git
218532c3702affc711473096a277664889c64162
b9d0fe36162a4e8e133dd7ef8da892041bbbce23
This is an infrastructure issue and we're working on it. It should only affect Googlers and Bazel's CI.
Thank you!
Is this resolved?
Yes! Thank you.
I'm still running into this locally. Is there anything I need to do to get the fix?
bazel version output:
Build label: 2.0.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 19 12:33:30 2019 (1576758810)
Build timestamp: 1576758810
Build timestamp as int: 1576758810
> bazel test --ios_sdk_version=13.2 --apple_platform_type=ios //...
ERROR: /private/var/tmp/_bazel_featherless/3b6682438fd07dd4083ef63da58b9a2a/external/com_google_protobuf/BUILD:148:1: no such package '@zlib//': The repository '@zlib' could not be resolved and referenced by '@com_google_protobuf//:protobuf'
ERROR: Analysis of target '//:SwiftUnitTestsLib' failed; build aborted: no such package '@zlib//': The repository '@zlib' could not be resolved
INFO: Elapsed time: 10.749s
INFO: 0 processes.
I got past this error by adding the following to my WORKSPACE (copied from the rules_closure commit linked to above):
http_archive(
name = "zlib",
build_file = "@com_google_protobuf//:third_party/zlib.BUILD",
sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
strip_prefix = "zlib-1.2.11",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz",
"https://zlib.net/zlib-1.2.11.tar.gz",
],
)
But now I get the following error:
2019-12-27 19:57:09,328 Created new simulator DD9E8A65-87AC-47D4-BDFD-8F8B2D359964.
2019-12-27 14:57:09.528 xctest[71014:2549797] The bundle “UnitTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2019-12-27 14:57:09.528 xctest[71014:2549797] (dlopen_preflight(/var/folders/nf/gl8gqkdd6fg98rjd9rgzkt70002gv0/T/test_runner_work_dir.GuxkjJ/UnitTests/UnitTests.xctest/UnitTests): Library not loaded: @rpath/libswiftFoundation.dylib
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib
Reason: no suitable image found. Did find:
/usr/lib/swift/libswiftFoundation.dylib: mach-o, but not built for iOS simulator
/usr/lib/swift/libswiftFoundation.dylib: mach-o, but not built for iOS simulator)
2019-12-27 19:57:09,534 Deleting simulator DD9E8A65-87AC-47D4-BDFD-8F8B2D359964 asynchronously.
2019-12-27 19:57:09,538 Done.
Digging in...
I changed my test target to be a suite with the following configuration:
ios_test_runner(
name = "IPAD_PRO_12_9_IN_9_3",
device_type = "iPad Pro (12.9-inch)",
os_version = "9.3",
)
ios_test_runner(
name = "IPHONE_7_PLUS_IN_10_3",
device_type = "iPhone 7 Plus",
os_version = "10.3",
)
ios_test_runner(
name = "IPHONE_X_IN_11_4",
device_type = "iPhone X",
os_version = "11.4",
)
ios_test_runner(
name = "IPHONE_XS_MAX_IN_12_2",
device_type = "iPhone Xs Max",
os_version = "12.2",
)
ios_unit_test_suite(
name = "UnitTests",
deps = [
":SwiftUnitTestsLib",
],
minimum_os_version = "9.0",
timeout = "short",
runners = [
":IPAD_PRO_12_9_IN_9_3",
":IPHONE_7_PLUS_IN_10_3",
":IPHONE_X_IN_11_4",
":IPHONE_XS_MAX_IN_12_2",
],
)
With the following output:
//:UnitTests_IPHONE_XS_MAX_IN_12_2 PASSED in 3.6s
//:UnitTests_IPAD_PRO_12_9_IN_9_3 FAILED in 2.8s
/private/var/tmp/_bazel_featherless/3b6682438fd07dd4083ef63da58b9a2a/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/UnitTests_IPAD_PRO_12_9_IN_9_3/test.log
//:UnitTests_IPHONE_7_PLUS_IN_10_3 FAILED in 2.8s
/private/var/tmp/_bazel_featherless/3b6682438fd07dd4083ef63da58b9a2a/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/UnitTests_IPHONE_7_PLUS_IN_10_3/test.log
//:UnitTests_IPHONE_X_IN_11_4 FAILED in 3.4s
/private/var/tmp/_bazel_featherless/3b6682438fd07dd4083ef63da58b9a2a/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/UnitTests_IPHONE_X_IN_11_4/test.log
The iOS version that includes Swift builds and tests fine, as expected, while the other iOS versions all fail with the missing Swift error. I'll likely have to move this discussion over to https://github.com/bazelbuild/rules_apple
Is this issue solved? I'm still getting com_google_protobuf/BUILD:148:1: no such package '@zlib//': The repository '@zlib'
I got past this error by adding the following to my WORKSPACE (copied from the rules_closure commit linked to above):
http_archive( name = "zlib", build_file = "@com_google_protobuf//:third_party/zlib.BUILD", sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", strip_prefix = "zlib-1.2.11", urls = [ "https://mirror.bazel.build/zlib.net/zlib-1.2.11.tar.gz", "https://zlib.net/zlib-1.2.11.tar.gz", ], )
Consider using the above ^ it resolves this error for me.
Most helpful comment
Consider using the above ^ it resolves this error for me.