Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rules_ios fails to build using rules_swift 2.x #875

Closed
tymurmustafaiev opened this issue Jun 12, 2024 · 2 comments · Fixed by #879
Closed

rules_ios fails to build using rules_swift 2.x #875

tymurmustafaiev opened this issue Jun 12, 2024 · 2 comments · Fixed by #879
Assignees

Comments

@tymurmustafaiev
Copy link
Contributor

tymurmustafaiev commented Jun 12, 2024

In my project I need to use latest changes from rules_swift. I'm trying to build framework using apple_framework rule for this target from test samples folder:

apple_framework(
    name = "SwiftIntentConsumer",
    srcs = [
        "Intents.intentdefinition",
        "SwiftIntent.swift",
    ],
    platforms = {"ios": "12.0"},
    visibility = ["//visibility:public"],
)

When I try to build it - I got this error: 👇 ❌

ERROR: /Users/timur.mustafaev/Documents/Projects/rules_ios/tests/ios/frameworks/intentdefinition/BUILD.bazel:13:16: Compiling Swift module //tests/ios/frameworks/intentdefinition:SwiftIntentConsumer_swift failed: (Exit 1): worker failed: error executing SwiftCompile command (from target //tests/ios/frameworks/intentdefinition:SwiftIntentConsumer_swift) 
  (cd /private/var/tmp/_bazel_timur.mustafaev/c9dc236d29c4f9c416201cbfa4d380ce/execroot/build_bazel_rules_ios && \
  exec env - \
    APPLE_SDK_PLATFORM=iPhoneSimulator \
    APPLE_SDK_VERSION_OVERRIDE=17.2 \
    PATH='/Users/timur.mustafaev/Library/Caches/bazelisk/downloads/sha256/fb5e7bc62fc3c8f2511e3b64d795296444129b26f13d8dece4d4cee1845b758f/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:/Users/timur.mustafaev/Library/Application Support/JetBrains/Toolbox/scripts' \
    SWIFT_AVOID_WARNING_USING_OLD_DRIVER=1 \
    XCODE_VERSION_OVERRIDE=15.2.0.15C500b \
  bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc @bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min12.0-applebin_ios-ST-2d34d443f7fd/bin/tests/ios/frameworks/intentdefinition/SwiftIntentConsumer.swiftmodule-0.params)
# Configuration: 591135ff330ad16e507f1e10a984f2fc9bcd492427ee403ea58d45b278d056e3
# Execution platform: @@local_config_platform//:host
error: emit-module command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: cannot open file '/private/var/tmp/_bazel_timur.mustafaev/c9dc236d29c4f9c416201cbfa4d380ce/execroot/build_bazel_rules_ios/bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min12.0-applebin_ios-ST-2d34d443f7fd/bin/tests/ios/frameworks/intentdefinition/SwiftIntentConsumer_swift_vfs.yaml' (No such file or directory)
<unknown>:0: error: cannot open file '/private/var/tmp/_bazel_timur.mustafaev/c9dc236d29c4f9c416201cbfa4d380ce/execroot/build_bazel_rules_ios/bazel-out/ios_sim_arm64-dbg-ios-sim_arm64-min12.0-applebin_ios-ST-2d34d443f7fd/bin/tests/ios/frameworks/intentdefinition/SwiftIntentConsumer_swift_vfs.yaml' (No such file or directory)
error: fatalError
Target //tests/ios/frameworks/intentdefinition:SwiftIntentConsumer failed to build

However, building mixed language framework works fine ✅

apple_framework(
    name = "MixedIntentConsumer",
    srcs = [
        "Intents.intentdefinition",
        "MixedIntent.m",
        "SwiftIntent.swift",
    ],
    platforms = {"ios": "12.0"},
    visibility = ["//visibility:public"],
)

How to reproduce

  1. Disable bzlmod in .bazelrc file: common --noenable_bzlmod
  2. Use latest commit from bazel_rules_swift repo:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

maybe(
        git_repository,
        name = "build_bazel_rules_swift",
        commit = "8c144a2c28af3af7b78b5fd679550e6783a19194",
        remote = "https://github.com/bazelbuild/rules_swift.git",
        shallow_since = "1716513695 -0700",
)
  1. Run bazelisk build //tests/ios/frameworks/intentdefinition:SwiftIntentConsumer

I've iterated commits one by one and this one seems to be the breaking commit

@tymurmustafaiev tymurmustafaiev changed the title rules_ios is failing to build pure swift framework with latest rules_swift version rules_ios is failing to build pure swift framework with latest changes from rules_swift Jun 12, 2024
@luispadron luispadron changed the title rules_ios is failing to build pure swift framework with latest changes from rules_swift rules_ios fails to build using rules_swift 2.x Jun 18, 2024
@luispadron luispadron self-assigned this Jun 18, 2024
@luispadron
Copy link
Collaborator

luispadron commented Jun 18, 2024

We dont support rules_swift at master yet (it will be a major version bump soon). I'll start working on fixing rules_ios to be compatible with it

@luispadron
Copy link
Collaborator

Running a bisect shows this rules_swift commit as being first bad commit:

d68b21471e4e9d922b75e2b0621082b8ce017d11 is the first bad commit
commit d68b21471e4e9d922b75e2b0621082b8ce017d11 (HEAD, refs/bisect/bad)
Author: Tony Allevato <allevato@google.com>
Date:   Mon Jan 24 08:30:10 2022 -0800

    Copy `strict_includes` into `SwiftInfo` provider's Clang module descriptor in `swift_clang_module_aspect`.

    This makes it so that the `apple_common.Objc` provider no longer needs to be handled separately for compilation by Swift build APIs. (It is still used for linking until that is migrated entirely onto `CcInfo`.)

    PiperOrigin-RevId: 423822059
    (cherry picked from commit 8ce95959d19334ce53963c6cbce3ac6eb40cd28c)

 doc/api.md                                   |  33 ++++++++-------------------------
 swift/internal/compiling.bzl                 | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------
 swift/internal/providers.bzl                 |  34 ++++++++++++----------------------
 swift/internal/swift_clang_module_aspect.bzl |  27 ++++++++++++++++++++++-----
 swift/internal/utils.bzl                     |  31 +++++++++++++++++--------------
 5 files changed, 120 insertions(+), 158 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants