Upgrade JS only react-native library to RN 0.60 - ios

I have a react-native component library, which only contains javascript code. I don't have ios/android directory (in library). I want to make it compatible with react-native 0.60. My library has some dependencies which which needs linking. Until this point I was just asking consumers to link these dependencies manually.
Now for autolinking (in RN 0.60) to work, I will need to a podspec for my project. But I don't really have any ios code (or directory) in my library. So I can't create podspec. So in this case, only way I can see is to ask consumers of my library to manually install all the NPM dependencies of my libraries and then pod install. Is there some other way that I can configure it in my library, that will let cocoapods know to install the dependencies of my library as well?
P.S. I am not really much familiar with ios or cocoapods. So if this question sounds a bit silly, please pardon me.

You can try to run following command to generate ios/android directories:
react-native upgrade --legacy true
Then you can run following command to install iOS dependencies when the directories generated:
cd ios
pod install

I don't think this is possible at least with version 0.60, Because of breaking changes in this version, If you are on the version before 0.60 and wanted to upgrade on 0.60 you have to face native issues and breaking changes in the native libraries as well because for now most of the libraries have two different versions one for above 0.60 and other for below 0.60.
When you will try to upgrade on 0.60 this version also have native changes and also auto linking is been introduced so some native libraries can also cause problem due to this.
My Recommendation is to use Upgrade helper tool and get an idea about the changes that you need on every version.
https://facebook.github.io/react-native/docs/upgrading

Related

Upgrading React Native plugin to support autolinking and React Native versions 0.6>=

I am fairly new to React Native but am helping manage a React Native plugin and would like some guidance for upgrading it so that it is compatible with auto linking and React Native versions 0.60 and up in iOS.
Our plugin currently only works with React Native up to and including 0.59.x through the react-native link command and sometimes involves manually dragging our xcodeproj and .a binary inside Xcode.
When trying to instrument our plugin with a blank hello world React Native app of version 0.60.5, after react-native link and dragging in Xcode, we get an error saying rctbridgemodule.h not found and have to add React.xcodeproj too. This however doesn’t work on some apps we’ve tried. Furthermore the issue is in newer versions of React eg 0.61.4, the React.xcodeproj file is no longer in the React folder in node_modules. 

I’ve had a look at the What do I need to have in my package to make it work? Section in this link: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
But to me its not very clear how we should be configuring a pod spec in the root of our repo. Our package is scoped also. I’m assuming that there shouldn’t need to be any changes to the actual code of our plugin but rather just some modifications to our pod spec and package configuration. Any guidance in how this works and how to upgrade our plugin to support versions 0.6 and above would be greatly appreciated. Thanks!

Exact steps needed to migrate a react native android app to iOS

I've written a react-native app and compiled it for android.
Now I wish to compile my app for iOS.
I've searched the internet and found a lot of documentation about adding react-native components to an existing iOS app project, but couldn't find a concrete guide/explanation on how to take an existing react-native project(with many components, packages installed etc) and add the relevant iOS configuration.
I guess that I somehow should create an iOS project through xCode,then probably copy some project files into my ios folder of my project, create a podfile corresponding to my packages in package.json, install the required stuff using pod install and then maybe I can run it using the react-native run-ios command, but I'm really not sure whether I'm correct and to do these steps.
If someone can clarify to me what are the required steps I'll be grateful! (And I think other people might find it useful as well)

React Native project version upgrade error: v0.56 to v0.60, iOS fails

I'm currently upgrading one of my projects built in React Native v0.56 to latest v0.60. Created a new project with version v0.60 and updated all the packages used in previous version of app, but now facing weird errors.
I've already tried all the possible solutions mentioned in Git and Stack overflow. None of them worked for me. I've also tried to remove plugins one by one and then adding them but not able to find cause of the error.
iOS:
In iOS, all the packages by default autolinks as per v0.60, but I got error of linking in very first package, I've tried manual linking too, not working.
After manual linking do cd ios and then pod install. This will not be done by autolinking and you have to do it yourself. On iOS on my project i had to manual link on iOS almost every library and almost all of them needed a pod install
use upgrade helper from react native community Upgrade Helper

MuPDF Cocoapods Installation Error

After researching on what library to use in one of my projects for epub reader, I decided to use MuPDF. I integrated it using Cocoapods, but when I build the app, it gives me a couple of errors on _math.h_ file on lines 36 and 73. I have attached the screenshots for reference. It would be of great help if anyone here can help me build the app after integrating MuPDF without any error. line 36
I think you are being hit by a not-backwards-compatible change that took place in CocoaPods 0.39 ( https://github.com/CocoaPods/CocoaPods/pull/4057 ).
Can you upgrade your CocoaPod to 0.39? (gem update cocoa pods) If you do so and then run pod install that should fix it.
If you can't upgrade to 0.39, you could use the 1.7 podspec mupdf, which is compatible with CocoaPod 0.38.
There's an example project that uses the MuPDF pod spec here:
https://github.com/jogu/MuPDF-example
(To try and prevent this problem in the future I just pushed a new pod, 1.8.2, that has a cocoapods_version >= 0.39 restriction in the podspec.)

React Native using Cocoapods

Is it possible to use cocoapods when using React Native?
If so, How can I require in JavaScript the pods projects?
Thanks in advance!
Yes. It's possible. React Native project is pretty much normal iOS application (In terms of XCode required to build it and quite a lot of React Native internal code is well... Native Obj-C). Since React Native project is already run via xcworkspace, so it's perfectly possible to add Obj-C pods to the ReactNative project.
Since a lot of dependencies used by RN apps are pure javascript rather than Obj-C code, it's more than convenient to keep both dependency systems - Cocoapods (for Obj-C dependencies) and npm (for javascript). Pods are kept in "Pods" directory and npm under "node-modules" and they are not clashing with each other. And it's pretty convenient actually to have different types of dependencies run by different dependency management systems.
UPDATE: by default ReactNative project is .xcodeproj based, but it's easy to convert it to .xcodeworkspace.
I even tried to add React Native itself as Cocoapods dependency and it was sort of working (but some dependencies expected React in the "node-modules" dir so I abandoned it).

Resources