Closed maxbelanger closed 9 months ago
I agree that it would be nice to not have this if you "know" you don't need it, but is there another problem from having the implicit dependency on rules_swift?
The main issue we found (so far) is the requirement for swiftc
to be on the PATH
.
are you building without xcode?
We're using Xcode. The problem is that we have a number of CI jobs that run on e.g. Linux (no Xcode) and run various bazel query
commands (they're not actually building anything). These all fail now, complaining of a missing swiftc
, which seems odd to me.
ah yea, I assume https://github.com/bazelbuild/rules_swift/blob/4ae4598024b1ff5c308a40df522bfca93e2de673/swift/internal/swift_autoconfiguration.bzl#L265-L267 is the error you see. I'm not sure if it's possible for us to make that lazier. It might be possible for you to register a no-op toolchain on Linux only instead, still not ideal
Would using toolchains fix this, perhaps? I noticed a TODO about that in https://github.com/bazelbuild/rules_swift/blob/4ae4598024b1ff5c308a40df522bfca93e2de673/swift/internal/swift_autoconfiguration.bzl#L425-L427
Yea that's a good question, my impression is that the toolchain repository rule will still be evaluated immediately "just in case", but I'm not sure
We found a better way to work around this than patching rules_apple
: we added our own repository rule named build_bazel_rules_swift_local_config
that defines "dummy" Swift toolchains. That seems to fix the issue, and allows analysis to proceed. This is similar to what is described in https://engineering.mercari.com/en/blog/entry/20211210-bazel-remote-execution-for-ios-builds-with-apple-silicon/ .
The proper solution to this does look like rules_swift
actually implementing toolchains, as in https://github.com/bazelbuild/rules_swift/issues/3.
In our setup, we share a
WORKSPACE
with a number of other targets. We noticed that when we started to use anapple_dynamic_framework_import
rule in our macOS application build, a requirement was created for the workspace to haverules_swift
:Our initial attempt to fix this was to actually configure
rules_swift
in our globalWORKSPACE
, but then this creates a requirement that all Bazel users haveswiftc
on the path, which isn't true of many CI runners (this was from aquery
, FWIW):We ended up fixing this temporarily by commenting out the references to
rules_swift
in the definition ofapple_dynamic_framework_import
, but that's not a great long-term solution: