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

cocoapods-bazel chokes on relative imports #34

Open
farcaller opened this issue Mar 14, 2021 · 3 comments
Open

cocoapods-bazel chokes on relative imports #34

farcaller opened this issue Mar 14, 2021 · 3 comments

Comments

@farcaller
Copy link

I took a basic react-native template for a ride, which has the following podfile:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'ReactNativeBazel' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  target 'ReactNativeBazelTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
  end
end

plugin 'cocoapods-bazel', {
  rules: {
    'apple_framework' => { load: '@build_bazel_rules_ios//rules:framework.bzl', rule: 'apple_framework' }.freeze,
    'ios_application' => { load: '@build_bazel_rules_ios//rules:app.bzl', rule: 'ios_application' }.freeze,
    'ios_unit_test' => { load: '@build_bazel_rules_ios//rules:test.bzl', rule: 'ios_unit_test' }.freeze
  }.freeze,
}

The podfile resides at ./ios/Podfile from the project's WORKSPACE. When I run pod install it generates the BUILD files everywhere, including the top-level node_modules/, but the labels in those are broken, e.g.:

ERROR: /Users/farcaller/src/rn-bazel/ReactNativeBazel/node_modules/react-native/Libraries/ActionSheetIOS/BUILD.bazel:3:16: //node_modules/react-native/Libraries/ActionSheetIOS:React-RCTActionSheet_objc: invalid label '//../node_modules/react-native:React-Core' in element 0 of attribute 'deps' in 'objc_library' rule: invalid package name '../node_modules/react-native': package name component contains only '.' characters

via

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

apple_framework(
    name = "React-RCTActionSheet",
    srcs = glob(["*.m"]),
    module_name = "RCTActionSheet",
    platforms = {"ios": "10.0"},
    visibility = ["//visibility:public"],
    deps = ["//../node_modules/react-native:React-Core"],
)
@segiddins
Copy link
Member

Right now, the plug-in assumes the workspace and the podfile are in the same directory, and no local pods are referenced outside of the workspace

@shzhng
Copy link

shzhng commented Apr 1, 2021

Right now, the plug-in assumes the workspace and the podfile are in the same directory, and no local pods are referenced outside of the workspace

@segiddins would this work if the workspace was actually the parent directory?

@segiddins
Copy link
Member

im not sure!

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

3 participants