I have been trying for the last days now to get React-Native (tried 0.49-0.53) to work with several native Modules/Packages like react-native-image-resizer, react-native-orientation, react-native-splash-screen, HockeySDK etc.
When I install the packages according to the package Maintainer/git repo README, there is always a link error - some file missing unless I also install Pods:
$pod install
This leads to installing the packages Podfiles, but also the React Pod is installed, unfortunately an outdated version (0.11).
To install a current version, I followed this React Native tutorial https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#configuring-cocoapods-dependencies .
Also I need to change the Xcode-Project from .xcodeproject to .xcworkspace (According to several github issues, please write if you are interested, I can regoogle the links).
This helps with the errors before but leads to this error:
ld: 21 duplicate symbols for architecture arm64
So the problem is that 2 versions of React are deployed simultaneously?
So wrapping it up:
Packages with native implementation need to be linked (react-native link)
Linking them installs Pods which in turn reinstalls/links React as Pod
This leads to a * duplicate symbols* error
Any idea?
I re-initialized a new project not installing pods at all!
Also be careful, most npm-packages require either normal installation or pods, just don't use pods!
The problem is just it will link a whole extra react-native as a pod, sometimes even a different version, which in the end leads to duplicate symbols. Maybe one could reference the react native libs to the already installed (in node_modules), but 1. I don't know how and 2. found the above way.
Related
I've been struggling to solve a problem.
I'm building a cross platform app (iOS and Android) using Kotlin Multiplatform (KMP) where I need a library from Google (https://github.com/google/libphonenumber).
For Android, I can point to a Maven repo (https://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/8.12.6/).
For iOS, I can use a ObjC port of libPhonenumber via Cocoapods.(https://cocoapods.org/pods/libPhoneNumber-ios).
But, I can't use Kotlin's (cocoapod plugin) to properly recognize the Pod. The plugin appears to fail to build.
Here's the details of my setup:
Xcode v11.5
IntelliJ IDEA v2020.1.2
Cocoapods v1.9.1
Gradle 6.0.1
Sample repo (https://github.com/touchlab/kotlin-native)
NOTE: Within the repo, I'm using ./samples/cocoapods
modify ./samples/cocoapods/kotlin-library/build.gradle.kts
commented out AFNetworking, remove AFNetworking pod
pod("AFNetworking", "~> 3.2.0")
add a new pod
pod("libPhoneNumber-iOS")
modify ./samples/cocoapods/kotlin-library/gradle.properties
change this line:
kotlin.native.home=../../../dist
to this:
#kotlin.native.home=../../../dist
in Terminal in this folder: ./samples/cocoapods/kotlin-library/
./gradlew podspec
This creates a podspec file (libPhoneNumber-iOS.def) in ./samples/cocoapods/kotlin-library/build/cocoapods/defs/
cd from kotlin-library to ios-app folder
cd ../ios-app/
Pod install using the command:
pod install
You'll see something like:
Downloading dependencies
Installing kotlin_library (1.0)
Installing libPhoneNumber-iOS (0.9.15)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
When I build the sample 'ios-app' target: simulator in Xcode, I get the error:
fatal error: module 'libPhoneNumber' not found
I have tried other libPhoneNumber pods, such as:
libPhoneNumberSwift
LTPhoneNumberField
Both fail to build using Kotlin's cocoapods plugin, but work as a Pod without Kotlin's cocoapod plugin.
What am I missing?
This particular problem seems to be caused by the dash in the pod's name. There was already an issue reported on GitHub. For now, it's recommended to workaround this problem by re-naming the module. Changing your kotlin-library/build.gradle.kts like
pod("libPhoneNumber-iOS", moduleName = "libPhoneNumber_iOS")
should help. Please give it a try and tell here or on GH if it works.
I have obtained excellent results by adding the unchanged Javascript version of libphonenumber using JavaScriptCore in IOS. The only part of the library not available yet in Javascript is the geocoder.
I used the concept explained here: https://www.appcoda.com/javascriptcore-swift .
Performance is great and there is no porting involved. Always the latest version available.
So I've been facing a really weird problem with React Native.
I installed a library via Cocoapods for picking images from the camera roll/photo Library and cropping the image as well, it is a silver bullet for this kind of usage. But then, it installs alongside React Native version 11, but this version of React Native was not what I wanted so I had to install React Native via Cocoapods as well so I can have the React Native version I'm using.
Now all installed well and if I try to build in my Dev environment everything works fine but when I try to archive, I get the error for duplicate symbols for WebSocket, Image (the library requires you to add RCTImage as a subspec in Cocoapods for React Native), RCTText, etc. basically all the subspecs you're required to add if installing React Native via Cocoapods according to the React Native docs.
So I figured I'll need to remove the manually linked libraries from my project, so I did that, but that only resulted in me now having another error when building for dev saying WebSocket, Linking, Network, etc are missing. Basically all the subspecs you're adding via Cocoapods, so I don't understand, if I install React Native and all its subspecs via Cocoapods (I'm also running in the workspace) shouldn't my project use the installed pods and not the linked libraries?
I've been on this for like 3 weeks now.
Here is my pods list.
Here is my linked binaries list.
Please, what do I do? I've been stuck for 3 weeks now, have tried almost any solution online but nothing has changed.
Thanks in advance.
I have solved the problem, only thing is I think you should use this carefully because I don't fully understand what it does. So within the docs, there is this Cocoapods code snippet that when you add to the Pods file after your target ends resolves this problem. Here is the code snippet.
# very important to have, unless you removed React dependencies for Libraries
# and you rely on Cocoapods to manage it
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "React"
target.remove_from_project
end
end
end
If you know exactly what this does please post another answer with this code snippet and an explanation so I can make the answer to the question, or better yet, edit the answer with the explanation, or leave a comment below so I can update my answer. From the looks of the above code snippet, though I'd say this is removing React and it's Subspecs from the installed pods, right after installation, I might be wrong.
Now when you're done with the installation, you'll get another error when you try to build saying react-native or React could not be resolved because it is in multiple locations and that you should delete one of them, to resolve this new error, simply go to the Pods directory and delete the React folder, that is [project-root]/ios/Pods/React once you do this, your application will build for development and also archive for production.
This problem I faced stands as a result of not properly reading installation guides, there may be small discrepancies between how it's usually done and how it's done for the library you're installing, so try and give a little more attention to detail.
For me,
delete all Link Binary With Libraries (From Build Phase)
delete Podfile.lock
run pod install
Wait for Indexing In Xcode
command+shift+k (Clear the project)
build again and fix it.
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
React Native Firebase won’t install on iOS React Native project. It works fine on Android.
I followed this instruction.
https://rnfirebase.io/docs/v5.x.x/installation/initial-setup
I set up Firebase, added the downloaded plist file via XCode, installed and set up Cocoapod.
The moment I add the following line to my App.js, the simulator returns an error message.
import firebase from 'react-native-firebase';
The error message: “RNFirebase core module was not found natively on iOS”
I’ve tried a few things I picked up from this forum:
https://github.com/invertase/react-native-firebase/issues/614
I commented out following lines from Podfile
use_frameworks!
And then pod install, pod update
on Xcode, checked the Build Phases/ Link Binary with Libraries section. I checked libRNFirebase.a was already there.
I've been trying this for a few months now on and off. And I haven't found a way to make React Native Firebase install on iOS project. Any pointer would be much appreciated.
I'm currently maintaining the react-native-firebase v5 branch (current stable) and we do have a problem with the header search paths right now for some reason.
I don't have a definitive fix, but I constructed a demo that goes from react-native init, then installs react-native-firebase, and does all the things necessary such that the project builds and runs on iOS and even archives in release mode.
You may see it here: https://github.com/mikehardy/rnfbdemo
The only thing that is important at the moment is that you need to put one non-documented thing in your Podfile after following all the install instructions, as the last line before the final end
system("mkdir -p Pods/Headers/Public/FirebaseCore && cp Pods/FirebaseCore/Firebase/Core/Public/* Pods/Headers/Public/FirebaseCore/")
I have recently updated to the newer version of Xcode and React Native and I'm having issues with duplicate symbols for my Xcode React Native build. I have tried to remove -ObjC from other Linker flags, changed No Common Blocks to No, and made sure no libraries were linked twice in 'Link Binary with Libraries'. None of those solutions suggested previously have helped; so, any other ideas would be appreciated.
You probably have some third-party libraries that you have added with both pods and react-native link at the same time. Just check your projects Project/Libraries folder and Pods/Products folder to see if there are any duplicates.
Typing the following in a terminal window solved the problem in my case:
cd <project folder>/ios
rm -rf Pods
pod install
I ran into the same issue.
I had to go in "edit scheme" > "builds" > "+" (and add React).
Then you drag and drop React in the list at first position.
Clean & build (successfully, I hope).
I had this issue. The problem for me was that I was using expo v44, and also unimodules which were deprecated and replaced by expo. So, I removed the unimodules package from my package.json, and it was working fine for me. Then, I made sure that I updated my packages which used unimodules, and updated them to a version that uses expo.