bazelbuild / tulsi

An Xcode Project Generator For Bazel
http://tulsi.bazel.build
Apache License 2.0
548 stars 123 forks source link

"Failed to resolve labels" error when generating project #397

Closed joetam closed 1 year ago

joetam commented 1 year ago

Hi, not sure why I'm getting a "failed to resolve labels" error when generating the project. Would appreciate any pointers, thanks!

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
TULSI_COMMIT_HASH = "518f18da4948192c72074e07fa1dfe15858d40f4"

http_archive(
    name = "tulsi",
    url = "https://github.com/bazelbuild/tulsi/archive/{0}.tar.gz".format(TULSI_COMMIT_HASH),
    strip_prefix = "tulsi-{0}".format(TULSI_COMMIT_HASH),
    sha256 = "92c89fcabfefc313dafea1cbc96c9f68d6f2025f2436ee11f7a4e4eb640fa151",
)

http_archive(
    name = "build_bazel_rules_apple",
    sha256 = "43737f28a578d8d8d7ab7df2fb80225a6b23b9af9655fcdc66ae38eb2abcf2ed",
    url = "https://github.com/bazelbuild/rules_apple/releases/download/2.0.0/rules_apple.2.0.0.tar.gz",
)

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
    "@build_bazel_apple_support//lib:repositories.bzl",
    "apple_support_dependencies",
)

apple_support_dependencies()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "build_bazel_rules_swift",
    sha256 = "32f95dbe6a88eb298aaa790f05065434f32a662c65ec0a6aabdaf6881e4f169f",
    url = "https://github.com/bazelbuild/rules_swift/releases/download/1.5.0/rules_swift.1.5.0.tar.gz",
)

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "build_bazel_rules_ios",
    remote = "https://github.com/bazel-ios/rules_ios.git",
    branch = "master",
)

load(
    "@build_bazel_rules_ios//rules:repositories.bzl",
    "rules_ios_dependencies"
)

rules_ios_dependencies()

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_apple_support//lib:repositories.bzl",
    "apple_support_dependencies",
)

apple_support_dependencies()

load(
    "@com_google_protobuf//:protobuf_deps.bzl",
    "protobuf_deps",
)

protobuf_deps()

BUILD

load("@build_bazel_rules_apple//apple:apple.bzl", "apple_xcframework")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

apple_xcframework(
    name = "TestFramework",
    bundle_id = "com.test.TestFramework",
    deps = [
        ":TestSwiftLib",
    ],
    families_required = {"ios":  ["iphone", "ipad"]},
    infoplists = [":Info.plist"],
    minimum_os_versions = {"iOS": "10.0"},
    visibility = ["//visibility:public"],
    ios = {"simulator": ["x86_64", "arm64"], "device": ["arm64"]},
)

swift_library(
    name = "TestSwiftLib",
    alwayslink = True,
    generates_header = True,
    module_name = "TestFramework",
    srcs = ['CustomButton.swift'],
    visibility = ["//visibility:public"],
)
Screenshot 2023-01-27 at 1 09 05 AM
SergLam commented 1 year ago

@joetam I'm getting the same error for regular iOS app (ios_application + ios_unit_test + ios_ui_test top-level targets).

Any ideas about fix?

xinzhengzhang commented 1 year ago

@joetam I'm getting the same error for regular iOS app (ios_application + ios_unit_test + ios_ui_test top-level targets).

Any ideas about fix?

I have the same error after upgrade bazel to 6.x and you can add @ in the front of the label like @//:TestSwiftLib in configuration of tulsi for workaround

SergLam commented 1 year ago

@xinzhengzhang Thanks for a hint!

I have added @ symbol to build targets (see sample below) and everything work now!

"buildTargets" : [
    "@//ImageLoaderConsumer:ImageLoaderConsumer",
    "@//ImageLoaderConsumerTests:ImageLoaderConsumerTests",
    "@//ImageLoaderConsumerUITests:ImageLoaderConsumerUITests"
  ],
keith commented 1 year ago

Thanks for submitting this issue but this tool is being deprecated. Please checkout rules_xcodeproj for a more complete and maintained Xcode integration.