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

error loading package '': Every .bzl file must have a corresponding package, but '@rules_pods//BazelExtensions:workspace.bzl' #182

Open
daflecardoso opened this issue Aug 31, 2021 · 4 comments

Comments

@daflecardoso
Copy link

daflecardoso commented Aug 31, 2021

I trying to use PodToBUILD master latest version, but i got an error

WORKSPACE FILE

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

git_repository(
    name = "build_bazel_rules_apple",
    remote = "https://github.com/bazelbuild/rules_apple.git",
    tag = "0.31.3",
)

#git_repository(
#    name = "build_bazel_rules_swift",
#    remote = "https://github.com/bazelbuild/rules_swift.git",
#    tag = "0.18.0",
#)

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

http_archive(
    name = "build_bazel_rules_swift",
    sha256 = "d0e5f888b2ccce42c92e6d4686b5507b4230462627f965f9d39862e11ae9fb35",
    url = "https://github.com/bazelbuild/rules_swift/releases/download/0.18.0/rules_swift.0.18.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()

git_repository(
    name = "build_bazel_apple_support",
    remote = "https://github.com/bazelbuild/apple_support.git",
    tag = "0.11.0",
)

git_repository(
    name = "bazel_skylib",
    remote = "https://github.com/bazelbuild/bazel-skylib.git",
    tag = "1.0.3",
)

http_archive(
    name = "rules_pods",
    urls = ["https://github.com/pinterest/PodToBUILD/archive/refs/heads/master.zip"],
)

load("@rules_pods//BazelExtensions:workspace.bzl", "new_pod_repository")


Pods.WORKSPACE



new_pod_repository(
  name = "RxSwift",
  url = "https://github.com/ReactiveX/RxSwift/archive/5.0.0.zip",
)

new_pod_repository(
  name = "RxRelay",
  url = "https://github.com/ReactiveX/RxSwift/archive/5.0.0.zip",
)

new_pod_repository(
  name = "RxCocoa",
  url = "https://github.com/ReactiveX/RxSwift/archive/5.0.0.zip",
)

new_pod_repository(
  name = "Alamofire",
  url = "https://github.com/Alamofire/Alamofire/archive/5.4.0.zip",
)

BUILD file

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")

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

load("@rules_cc//cc:defs.bzl", "objc_library")

swift_library(
    name = "Source",
    srcs = glob([
        "*.swift",
    ]),
    data = [
        "Main.storyboard",
        "LaunchScreen.storyboard"
    ],
    deps = [
        "//ios-app/submodules/FeatureA",
        "//ios-app/submodules/FeatureB",
        "//ios-app/submodules/FeatureC",
        "//ios-app/submodules/FeatureD",
        "//Vendor/Alamofire:Alamofire",
        "//Vendor/RxSwift:RxSwift",
        "//Vendor/RxRelay:RxRelay",
        "//Vendor/RxCocoa:RxCocoa",
    ],
)

ios_application(
    name = "ios-app-swift",
    bundle_id = "br.com.example-app-swift",
    families = [
        "iphone",
        "ipad",
    ],
    minimum_os_version = "11.0",
    infoplists = [":Info.plist"],
    visibility = ["//visibility:public"],
    deps = [
        ":Source"
    ],
)

when run command bazel run @rules_pods//:update_pods -- --src_root $PWD

i got

error loading package '': Every .bzl file must have a corresponding package, but '@rules_pods//BazelExtensions:workspace.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.

This version works fine (install) update_pods command
https://github.com/pinterest/PodToBUILD/releases/download/3.4.1-ea20598f/PodToBUILD.zip

but is outdated, i got error when build the app, the BUILD.bazel file generated inside each pod is outdated generation

@mcfans
Copy link

mcfans commented Sep 1, 2021

It seems you have to use a release version of PodToBUILD. You could clone this repo and make it on you own, or use the one I just created https://github.com/iftechio/PodToBUILD/releases/download/3.4.3-c538dab/PodToBUILD.zip

@daflecardoso
Copy link
Author

daflecardoso commented Sep 1, 2021

@mcfans

I tried to use this version https://github.com/iftechio/PodToBUILD/releases/download/3.4.3-c538dab/PodToBUILD.zip

the dependencies have been installed

bazel run @rules_pods//:update_pods -- --src_root $PWD

INFO: Build completed successfully, 2 total actions
Updating pods in /Users/dafle/Desktop/project
Building PodToBUILD dependencies...
running: make release
skipping build..

Updating Pod RxSwift...
Updating Pod RxRelay...
Updating Pod RxCocoa...
Updating Pod Alamofire...

But when i tried to build the target app, using RxCocoa dependency

bazel build //ios-app:ios-app-swift

I got this error

 /Users/dafle/Desktop/project/Vendor/RxCocoa/BUILD.bazel:47:14: Compiling Swift module RxCocoa failed: (Exit 1): worker failed: error executing command bazel-out/host/bin/external/build_bazel_rules_swift/tools/worker/worker swiftc ... (remaining 1 argument(s) skipped)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../RxCocoa_umbrella_header.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:9: note: in file included from /private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:
#import "Vendor/RxCocoa/RxCocoa/RxCocoa.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/./Vendor/RxCocoa/RxCocoa/RxCocoa.h:10:9: error: '_RX.h' file not found
#import "_RX.h"
        ^
<unknown>:0: error: could not build Objective-C module 'RxCocoa'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../RxCocoa_umbrella_header.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:9: note: in file included from /private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:
#import "Vendor/RxCocoa/RxCocoa/RxCocoa.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/./Vendor/RxCocoa/RxCocoa/RxCocoa.h:10:9: error: '_RX.h' file not found
#import "_RX.h"
        ^
<unknown>:0: error: could not build Objective-C module 'RxCocoa'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../RxCocoa_umbrella_header.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:9: note: in file included from /private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:
#import "Vendor/RxCocoa/RxCocoa/RxCocoa.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/./Vendor/RxCocoa/RxCocoa/RxCocoa.h:10:9: error: '_RX.h' file not found
#import "_RX.h"
        ^
<unknown>:0: error: could not build Objective-C module 'RxCocoa'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../RxCocoa_umbrella_header.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:9: note: in file included from /private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:
#import "Vendor/RxCocoa/RxCocoa/RxCocoa.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/./Vendor/RxCocoa/RxCocoa/RxCocoa.h:10:9: error: '_RX.h' file not found
#import "_RX.h"
        ^
<unknown>:0: error: could not build Objective-C module 'RxCocoa'
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "../RxCocoa_umbrella_header.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:9: note: in file included from /private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/bazel-out/ios-x86_64-min11.0-applebin_ios-ios_x86_64-fastbuild-ST-1665503f7bef/bin/Vendor/RxCocoa/RxCocoa_module_map/../RxCocoa_umbrella_header.h:19:
#import "Vendor/RxCocoa/RxCocoa/RxCocoa.h"
        ^
/private/var/tmp/_bazel_dafle/95ebb7f9aadb563e67eff2a44c6579b0/execroot/__main__/./Vendor/RxCocoa/RxCocoa/RxCocoa.h:10:9: error: '_RX.h' file not found
#import "_RX.h"
        ^
<unknown>:0: error: could not build Objective-C module 'RxCocoa'
Target //ios-app:ios-app-swift failed to build
Use --verbose_failures to see the command lines of failed build steps.

I guess that, BUILD file isn't generated correct in this version of PodToBUILD, in some libraries that use swift with objc

RxCoca, Moya, Realm....

@mcfans
Copy link

mcfans commented Sep 1, 2021

Yeah, I met this problem too. Swift library in generated BUILD file missed some include path, so we got this error in swift-objc mixed pod because swift compiler can't find the objc headers. I am trying to solve this, but not too soon

@daflecardoso
Copy link
Author

@mcfans

inside BUILD file generated RxCocoa I replaced the line 124 by 125, and it works fine.

00E31CBA-F14B-43E3-ADB9-E81D66E7080F

looks like the problem is relative to
header_visibility attribute.

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

No branches or pull requests

2 participants