Closed
Description
Ask your Question
We're working on a hybrid native/RN app being managed separately, thus, we're using a non-standard folder structure. Other than using an older version of platform-ios
, is there another way for us to perform autolinking with the RN project in a separate directory?
Details
Prior to #768, we were able to pass a custom root to be able to use able to use autolinking. However, the pull request changed the way autolinking is being handled, and the custom root is no longer being respected, resulting in the following message:
$ pod install
Command `config` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.
[!] Invalid `Podfile` file: A JSON text must at least contain two octets!.
# from /Users/xx/Desktop/Projects/my-ios-app/Podfile:44
# -------------------------------------------
#
> use_native_modules!($rn_path)
# end
# -------------------------------------------
[!] Passing custom root to use_native_modules! is deprecated.
- CLI detects root of the project automatically. The "../my-react-native"
argument was ignored.
Our podfile on the native side looks like this:
# We need to use_frameworks! because Swift pods (esp. Alamofire)
use_frameworks!
# ignore all warnings from all pods
inhibit_all_warnings!
# Define react native path and node_modules
$rn_path = ENV['REACT_NATIVE_PATH'] || '../my-react-native'
$node_modules = "#{$rn_path}/node_modules"
# get the new autolinking feature
require_relative "#{$node_modules}/@react-native-community/cli-platform-ios/native_modules"
def react_native_pods
pod 'FBLazyVector', :path => "#{$node_modules}/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "#{$node_modules}/react-native/Libraries/FBReactNativeSpec"
# all of React's base pods...
use_native_modules!($rn_path)
end
def native_pods
pod 'Siren', '~>3.4.0'
pod 'Alamofire', '~> 4.5'
# other non-React pods...
end
target '...' do
react_native_pods
native_pods
end