Skip to content

cocoapods-bazel chokes on relative imports #34

@farcaller

Description

@farcaller

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"],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions