How to install a pod in a custom react native library? - react-native

I'm trying to link a custom react native library which has a pod installed. When I install the pod in the custom library, xcworkspace is generated and I need to use the workspace there after, and I'm able to access the pods there. But, this custom library is linked as a xcodeproj to the ios project. So, it is unable to recognize the pod headers when it is linked.
Is there a way to link this custom library which has pods installed?

Related

How to properly include 'Firebase/Auth' pod for iOS or react-native project?

Goal: In a react-native project, I'm using react-native-firebase v5.6 and because im using Firebase's authentication, I need to include "Firebase/Auth" in the pod file so react-native-firebase's bindings can use it.
Problem: Once pod "Firebase/Auth" is added and saved to podfile, and pod install is successfully run, the project build fails when compiling RNFirebaseAuth.m. I haven't added any auth related code, just simply installed the pod and clean&ran build. Sidenote, other react-native-firebase setup/integration has been successful to this point.
Failing Error:
/path/to/project/node_modules/react-native-firebase/ios/RNFirebase/auth/RNFirebaseAuth.m:1184:36: error: no known class method for selector 'credentialWithProviderID:IDToken:rawNonce:'
credential = [FIROAuthProvider credentialWithProviderID:#"apple.com" IDToken:authToken rawNonce:authTokenSecret];
Have I just missed an installation step or what? How do I fix build?
According to mikehardy on GitHub, react-native-firebase v5.6 has a minor breaking change that enforces the use of firebase pods with at least version 6.13.
I ran pod update and that was all that was needed to fix the build

Linking API on React Native 0.61: openUrl is not a function

I'm trying to make sense of the Docs for the enabling the Linking API in React Native 0.61.5 on iOS.
https://facebook.github.io/react-native/docs/linking
The docs say that the library needs to be manually linked by following these steps:
https://facebook.github.io/react-native/docs/linking-libraries-ios#manual-linking
But there's no .xcodeproj for Linking, under node_modules/react-native/Library/Linking or node_modules/react-native/Library/LinkingIOS, thus I have not manually linked the Library. Are there alternative instructions on manually linking the library?
When I try to call Linking.openUrl from my App right now, I get the following error:
TypeError: _reactNative.Linking.openUrl is not a function.
also, in my Podfile, I see this line:
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
Any help is greatly appreciated!
In case anyone is as unobservant as I am, it's openURL, not openUrl.
Just lost an hour on this.
For 0.60+, you don't need to do the manual-linking stuff. It uses cocoapods to do the linkings automatically.
Install Cocoapods: sudo gem install cocoapods
Then just go to /ios folder and do a pod install

react-native link and installing native dependencies

I'm building a React Native module which itself has native iOS dependencies, that I don't own.
It's unclear to me how I can refer to and get installed these third-party deps though without making the user just go through Cocoapods directly instead.
i.e. With them having to create a Podfile then add the dependencies to the Podfile and doing pod install
In which case, why use react-native link at all?
So an example project is structured like this:
SomeApp
/iOS
SomeApp.xcodeproj
Podfile
/node_modules
/my_module
/ios
my_module.xcodeproj
my_module.podspec
my_module.h
my_module.h then has specified in it:
#import <SomeFramework/SomeFramework.h>
#import "RCTBridgeModule.h"
and my_module.podspec has
s.dependency 'SomeFramework', '~> 3.0'
react-native link will link my library but doesn't trigger the install of any dependencies, nor does it add any of those dependencies to the app Podfile.
According to what information I can find, react-native link does look for podspec files so it seems like it's only doing half the job?
Is there something I need to add to my_module/package.json to make react-native link add the dependencies to the main Podfile?
So the answer is that your podspec has to be in the top level of your node module folder.
If you nest your podspec within an iOS folder, react-native link will not find it and will not add it the app's Podfile automatically.

Init IOS project with pods using react-native init command

Is there any way to create the IOS project with pods using react-native init command?
Currently there is different installation instruction for react native libraries.
Example: Some of them install using react-native link command while other requires to setup using cocoapods. Missing both will leads to lots of compilation errors.
Could anyone suggest what is best way to create project using react-native.
Thanks
On the official react native documentation, there are 2 ways to start up your project, which is using 'CRNA' or 'Build With Native Code'.
For CRNA, it is the fastest and easiest way to start up your project.
It really easy to run your React Native app on a physical device without setting up a development environment. If you want to run your app on the iOS Simulator or an Android Virtual Device, please refer to the instructions for building projects with native code to learn how to install Xcode and set up your Android development environment.
The react native link is used if you want to link your library through the terminal. But in some cases, there are several problem occurred related to library compatibility. I rather suggest use pods or manually link your library through XCode.
Pods is a dependency manager for native code that we use on our native code project. It will automatically generate and link the library.
If you want to have pods on your ios project. After you install cocoapods, you could follow these steps :
1. Open terminal and direct to your project (cd YOUR_PROJECT/ios
2. pod init
3. And then Podfile will be generated within the ios project.
And from now on, you should use YOUR_PROJECT.xcworkspace if you want to manage the project. Thats because Pods should be placed and included same with your project but '.xcodeproj' does not include your Pods.

How to integrate react-native-video when using Podfiles to integrate react-native?

In the installation instructions for iOS, it says to run
react-native link
After completion I see:
However, compiling immediately fails with the error React/RCTViewManager.h not found:
When looking at the integration instructions on Facebook's website, it has us using a Podfile. When you use a Podfile, your project looks like this:
Comparing this to the react native sample project, I can see that in fact, it does not appear to use a Podfile to integrate react native at all; instead all React components are included as libraries:
Thus, I suspect that the integration instructions for react-native-video are not compatible with the integration instructions found here.
Can anyone suggest how to integrate react-native-video when using Podfiles to integrate react-native?
What version of react native are you using? This looks like it's due to the breaking change for RN version >0.40.
The short fix for this issue is if you see #import React/$(filename) in the native code, replace it with #import "$(filename)", but if you can update to RN >0.40 that would be preferable.
To answer your question about pods, you should be able to add something like pod 'react-native-video', :path => '../node_modules/react-native-video' to your podfile and run pod install (if the relative path from your Podfile to the library root is incorrect replace it with the correct one). Looking at the github page for react-native-video, it does have a podspec so it probably supports cocoapods installation