bazel-ios / cocoapods-bazel

A Cocoapods plugin for automatically generating Bazel BUILD files
Apache License 2.0
110 stars 21 forks source link

[Tutorial Question]BUILD file not found in any of the following directories #43

Closed cdoky closed 3 years ago

cdoky commented 3 years ago

run: bazel build //ios-app:ios-app

ERROR: /tutorial/ios-app/BUILD:14:16: no such package 'Pods/AgoraAudio_iOS': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /tutorial/Pods/AgoraAudio_iOS and referenced by '//ios-app:ios-app_objc'
ERROR: Analysis of target '//ios-app:ios-app' failed; build aborted: Analysis failed
INFO: Elapsed time: 22.698s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (36 packages loaded, 128 targets configured)
    currently loading: @local_config_cc//
├── README.md
├── WORKSPACE
├── appengine.BUILD
├── backend
├── bazel-bin -> /private/var/tmp/_bazel_cc/fe3145c93c0cfda8271c29935d89fd9a/execroot/__main__/bazel-out/darwin-fastbuild/bin
├── bazel-out -> /private/var/tmp/_bazel_cc/fe3145c93c0cfda8271c29935d89fd9a/execroot/__main__/bazel-out
├── bazel-testlogs -> /private/var/tmp/_bazel_cc/fe3145c93c0cfda8271c29935d89fd9a/execroot/__main__/bazel-out/darwin-fastbuild/testlogs
├── bazel-tutorial -> /private/var/tmp/_bazel_cc/fe3145c93c0cfda8271c29935d89fd9a/execroot/__main__
└── ios-app
    ├── BUILD
    ├── Pods
    │   └── AgoraAudio_iOS
    │       ├── AgoraAIDenoiseExtension.framework
    │       ├── AgoraCore.framework
    │       ├── AgoraRtcKit.framework
    │       ├── AgoraSoundTouch.framework
    │       ├── Agorafdkaac.framework
    │       └── BUILD.bazel
    └── UrlGet
        ├── AppDelegate.h
        ├── AppDelegate.m
        ├── UrlGet-Info.plist
        ├── UrlGetViewController.h
        ├── UrlGetViewController.m
        ├── UrlGetViewController.xib
        └── main.m

objc_library( name = "UrlGetClasses", srcs = [ "UrlGet/AppDelegate.m", "UrlGet/UrlGetViewController.m", "UrlGet/main.m", ], hdrs = glob(["UrlGet/*.h"]), data = ["UrlGet/UrlGetViewController.xib"], )

ios_application( name = "ios-app", bundle_id = "Google.UrlGet", families = [ "iphone", "ipad", ], minimum_os_version = "9.0", infoplists = [":UrlGet/UrlGet-Info.plist"], visibility = ["//visibility:public"], deps = [ ":UrlGetClasses", "//Pods/AgoraAudio_iOS" ], )


- Pods/AgoraAudio_iOS/BUILD
```shell
load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")

apple_framework(
    name = "AgoraAudio_iOS",
    platforms = {"ios": "8.0"},
    vendored_dynamic_frameworks = [
        "AgoraAIDenoiseExtension.framework",
        "AgoraCore.framework",
        "AgoraRtcKit.framework",
        "AgoraSoundTouch.framework",
        "Agorafdkaac.framework",
    ],
    visibility = ["//visibility:public"],
)
cdoky commented 3 years ago

If i move WORKSPACE to ios-app run bazel build :ios-app in ios-app

ERROR: /ios-app/Pods/AgoraAudio_iOS/BUILD.bazel:3:16: every rule of type apple_framework_packaging implicitly depends upon the target '@build_bazel_rules_ios//rules/framework:framework_packaging', but this target could not be found because of: error loading package '@build_bazel_rules_ios//rules/framework': Unable to find package for @rules_python//python:defs.bzl: The repository '@rules_python' could not be resolved.
ERROR: Analysis of target '//:ios-app' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.173s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (2 packages loaded, 2 targets configured)

apple_framework( name = "AgoraAudio_iOS", platforms = {"ios": "8.0"}, vendored_dynamic_frameworks = [ "AgoraAIDenoiseExtension.framework", "AgoraCore.framework", "AgoraRtcKit.framework", "AgoraSoundTouch.framework", "Agorafdkaac.framework", ], visibility = ["//visibility:public"], )

thiagohmcruz commented 3 years ago

Can you link to what tutorial exactly you are following? This doesn't seem to be related to cocoapods-bazel but a general iOS bazel problem.

That said, noticed this in the error msg:

- /tutorial/Pods/AgoraAudio_iOS and referenced by '//ios-app:ios-app_objc'

and that path doesn't exist in the folder structure you shared above, maybe your deps should look like this instead?

    deps = [
        ":UrlGetClasses",
        "//ios-app/Pods/AgoraAudio_iOS"
        ],

Also, the WORKSPACE file should always be at the root

cdoky commented 3 years ago

@thiagohmcruz Hi, tutorial from https://docs.bazel.build/versions/main/tutorial/ios-app.html

deps = [
        ":UrlGetClasses",
# Can't change it like that, because this library might depend on other libraries
        "//ios-app/Pods/AgoraAudio_iOS"
        ],

like generated BUILD by cocoapods-bazel

load("@build_bazel_rules_ios//rules:framework.bzl", "apple_framework")

apple_framework(
    name = "Bagel",
    srcs = glob([
        "iOS/Source/*.h",
        "iOS/Source/*.m",
    ]),
    platforms = {"ios": "8.0"},
    public_headers = [
        "iOS/Source/Bagel.h",
        "iOS/Source/BagelBaseModel.h",
        "iOS/Source/BagelBrowser.h",
        "iOS/Source/BagelCarrierDelegate.h",
        "iOS/Source/BagelConfiguration.h",
        "iOS/Source/BagelController.h",
        "iOS/Source/BagelDeviceModel.h",
        "iOS/Source/BagelProjectModel.h",
        "iOS/Source/BagelRequestCarrier.h",
        "iOS/Source/BagelRequestInfo.h",
        "iOS/Source/BagelRequestPacket.h",
        "iOS/Source/BagelURLConnectionInjector.h",
        "iOS/Source/BagelURLSessionInjector.h",
        "iOS/Source/BagelUtility.h",
    ],
    visibility = ["//visibility:public"],
    deps = ["//Pods/CocoaAsyncSocket"],
)

May be need move WORKSPACE to ios-app/

but, there is an error:

ERROR: //ios-app/Pods/AgoraAudio_iOS/BUILD.bazel:3:16: every rule of type apple_framework_packaging implicitly depends upon the target '@build_bazel_rules_ios//rules/framework:framework_packaging', but this target could not be found because of: error loading package '@build_bazel_rules_ios//rules/framework': Unable to find package for @rules_python//python:defs.bzl: The repository '@rules_python' could not be resolved.
ERROR: Analysis of target '//Pods/AgoraAudio_iOS:AgoraAudio_iOS' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.144s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
cdoky commented 3 years ago

fixed by import rules_python and move the WORKSPACE to ios-app/

git_repository(
    name = "rules_python",
    remote = "https://github.com/bazelbuild/rules_python.git",
    tag = "0.3.0",
)
justinseanmartin commented 3 years ago

Closing, sounds like the issue is resolved, doesn't appear related to this repo.