I want to use React Native Pods into one of my iOS Apps which is built using Swift. I have bundled my React Native components into ios-main.jsbundle
. I am consuming the routes as shown below:
class ContentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func loadView() {
loadReactNativeView()
}
func loadReactNativeView() {
let jsCodeLocation = Bundle.main.url(forResource: "main-ios", withExtension: "jsbundle")!
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "YourApp",
initialProperties: nil,
launchOptions: nil
)
self.view = rootView
}
}
and in order to use React, I have done pod installation with my podFile something like as shown below:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '13.0'
target 'yourreactnativeapp' do
use_react_native!
end
This works fine but here's the problem, my ios file is a root git directory and so I can't go one level up... again to perform pod installation, even if I place the files into my ios directory that would mean uploading entire node modules, which doesn't seem like a good solution, is there a way that I could use something other than require_relative
to install React Native
pod dependencies remotely from somewhere? I am okay with uploading node modules into another git repo and then fetching it from there.