dyld: Library not loaded: React native - ios

I have developed the “SampleApp iOS framework” with swift development and using the below dependencies in our app:
pod 'Alamofire', '4.9.1'
pod 'JGProgressHUD', '2.0.3'
pod 'FirebaseCore', '6.4.0'
pod 'FirebaseMessaging', '4.1.10'
We can able to integrate the my “SampleApp framework” in the native swift application and it’s working file. But while integrated and run the same framework in the react native project. I am getting the below error
dyld: Library not loaded: #rpath/Alamofire.framework/Alamofire
  Referenced from: /private/var/containers/Bundle/Application/F50D-C62F291D4-8E6B-07B23BA0D-C6-B2E9-91AE/MyFirstApp.app/Frameworks/SampleApp.framework/SampleApp
  Reason: image not found
Steps to be followed for integrating SDK in reaction native is below:
1.Installed and run the node
2.sudo chown -R $USER /usr/local/lib/node_modules
3.react-native init MyFirstApp
iOS and android folders are generated.
5.I have opened the sample app framework and added my dependencies in pod install then run the pod install command.
6.Run the app in the Xcode Run option. App gets opened and getting the above alamo fire error
target 'FirstApp' do
# Pods for FirstApp
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'Alamofire', '4.9.1'
pod 'JGProgressHUD', '2.0.3'
pod 'FirebaseCore', '6.4.0'
pod 'FirebaseMessaging', '4.1.10'
Note: I have not used the Visual studio, I just open the iOS folder and do all changes same as native app. Is any other things needs to be added for react native project?
I just wanted to compile the sample app without error.

To install a library in react native we have to follow this process.
suppose you want to install keyboard library,
npm i react-simple-keyboard
so we have to run to this command, it will add react-simple-keyboard dependencies in package.json which react-native app will use as a reference, next you need to install your pods
pod install

Have you tried adding "use_frameworks!" in the Podfile to allow importing the framework dependencies ?

Related

Why is React(missing) in xcode scheme build targets list?

I'm trying to run my first React-Native app on an ios device using xcode and keep getting this error:
ld: warning: directory not found for option '-L/Users/XXXX/Library/Developer/Xcode/DerivedData/nigh-hktjvygosupgnoaafsvgyowhzsqi/Build/Products/Debug-iphoneos/React'
ld: library not found for -lReact
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm assuming the cause is related to the fact that React is missing in my Scheme's build targets list. React is first on the list with all the boxes checked, but it says React(missing) instead of just React:
Screenshot of build targets list
If I click the '+' button React is not an option. Here is my podfile:
platform :ios, '10.0'
require_relative '../node_modules/react-native-unimodules/cocoapods'
target 'nigh' do
# Pods for nigh
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
'DevSupport',
'RCTActionSheet',
'RCTAnimation',
'RCTBlob',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
]
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'RNGestureHandler', :podspec => '../node_modules/react-native-gesture-handler/RNGestureHandler.podspec'
pod 'RNReanimated', :podspec => '../node_modules/react-native-reanimated/RNReanimated.podspec'
pod 'react-native-google-maps', path: '../node_modules/react-native-maps' # Uncomment this line if you want to support GoogleMaps on iOS
pod 'GoogleMaps' # Uncomment this line if you want to support GoogleMaps on iOS
pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS
use_unimodules!
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'react-native-maps', :path => '../node_modules/react-native-maps'
pod 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
pod 'react-native-slider', :path => '../node_modules/#react-native-community/slider'
pod 'react-native-notifications', :path => '../node_modules/react-native-notifications'
pod 'react-native-cameraroll', :path => '../node_modules/#react-native-community/cameraroll'
pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
pod 'RNFS', :path => '../node_modules/react-native-fs'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
if target.name == "React"
target.remove_from_project
end
end
end
I've tried removing the if target.name == "React" block and still get the same error. I'm also opening xcode from .xcworkspace instead of .xcodeproject since I am using cocoapods. I've tried removing everything from the DerivedData folder and cleaning the build, and have also tried building using the Legacy Build System. The Legacy Build system shows warnings on nearly every library that read "Missing dependency target 'React'".
I needed to change my bundle name from org.reactjs.native.example.nigh to org.reactjs.native.name.nigh, so could that be responsible? I know that at some point React was not missing in the targets list. Despite React missing the app still runs fine on the xcode iphone emulator.
Also in the Pods/Products file libReact.a does not have an icon like the other .a files do
Can anyone tell me why this is happening and/or how to fix/work around it?
I fixed this issue by going System Preferences -> Security & Privacy. Under the privacy tab I allowed Xcode to access my files and folders.
What actually happened was that I upgraded my OS to Catalina. Somehow the access to files and folder is not granted to Xcode, hence xcode is not able to read the file and so you get this issue.

ld: library not found for -lDoubleConversion React Native 0.59

I have this error
❌ ld: library not found for -lDoubleConversion
❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening App.xcworkspace
** BUILD FAILED **
The following build commands failed:
Ld /Users/mohamedelmi/workspace/elmi/food-frontend/ios/build/App/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App normal x86_64
(1 failure)
here is what i did
I clean and rebuild still have the error
rm -f ~/Library/Developer/Xcode/DerivedData/ModuleCach
First of all, make sure that Libraries -> React.xcodeproj -> ThirdParty -> double-conversion exists and a static library is being produced from it, like this:
Then, if are you're using cocoapods, make sure to add DoubleConversion to your Podfile:
target 'MyApp' do
pod 'React', :path => "../node_modules/react-native", :subspecs => [
'Core',
'CxxBridge',
'DevSupport',
# the following ones are the ones taken from "Libraries" in Xcode:
'RCTAnimation',
'RCTActionSheet',
'RCTBlob',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
pod 'yoga', :path => "../node_modules/react-native/ReactCommon/yoga"
# Here it goes
pod 'DoubleConversion', :podspec => "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "../node_modules/react-native/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "../node_modules/react-native/third-party-podspecs/Folly.podspec"
end
And finally, if none of this worked so far, there's a script you can manually run
in order to resolve React's third-party dependencies.
Just go to node_modules/react-native and type:
$ ./scripts/ios-install-third-party.sh
Important: Always run it inside node_modules/react-native. Because, as far as I know, the script uses relative paths in order to store third-party's source code and react native will always look for it at node_modules/react-native/third-party. So just make sure to run it in the right place.
Note: This script is, probably, already running as a build phase on your project.
I followed the answers on Why linker link static libraries with errors? iOS but nothing worked for me since I was combining the answers.
I got it to work by ONLY doing the "create new Swift-file"-trick. So remove everything, do a fresh install and only add a new Swift-file that will create the Bridging Header (dont delete the Swift-file).
This is what finally worked for me.
pod deintegrate
pod install
Open project in X-Code
Remove Resources folder from left sidebar
Build your project from New Build System.
This is what finally worked for me. (Before proceeding, make sure pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' is included in your podfiles
1. cd ios
2. Delete Podfile.lock
3. pod deintegrate
4. pod install
5. cd ..
6. rm -rf node_modules && yarn
7. Add use_frameworks! to your Podfile
Run react-native-run-ios or Build with Xcode by opening the xcworkspace file in your ios directory.

Firebase ambiguous reference "FIRMessagingAPNSTokenType... is ambiguous"

After upgrading the Firebase Pods the project have ambiguous reference problems, any suggestions?
when I use the Pods with Version 4.10.0 it works perfectly, but if I use the latest version (5.0.0) I get the error.
My Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'AppName' do
pod 'OpenSSL-Universal'
pod 'Firebase/Core', '4.10.0'
pod 'Firebase/Messaging', '4.10.0'
pod 'GoogleToolboxForMac/Logger'
pod 'AppCenter'
end
target 'AppName DEV' do
pod 'OpenSSL-Universal'
pod 'Firebase/Core', '4.10.0'
pod 'Firebase/Messaging', '4.10.0'
pod 'GoogleToolboxForMac/Logger'
pod 'AppCenter'
end`
Thaks and advance!!
This usually happens if you have the same class in 2 different frameworks. Can it be that you reference both 4 and 5 at the same time?
Try to comment out "BRy-Autenticador DEV" section and build only the 'BRy-Autenticador' target.
Check your Podfile.lock after running "pod install". It should contain only one version of Firebase frameworks.
I solved this problem writing...
[FIRMessaging messaging].APNSToken = deviceToken;
instead...
On didRegisterForRemoteNotificationsWithDeviceToken method.
Thanks!!

Quickblox: Undefined symbols for architecture x86_64: error

I used following pods but I'm getting Error
Undefined symbols for architecture x86_64:
platform :ios, "8.0" use_frameworks!
target 'CSocial' do
#
pod 'Alamofire', '~> 3.0'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'FlickrKit'
pod 'MONActivityIndicatorView'
Chat Integration
pod 'QuickBlox'
#Production pod
#pod 'QMCVDevelopment', :git => 'git#github.com:QuickBlox/QMChatViewController-ios.git', :commit => '7244eaf609797a5dc5ec6d28dc2b284633b03a1f'
#For development pods
pod 'QMCVDevelopment', :git => 'https://github.com/QuickBlox/QMChatViewController-ios.git'
#Production pod
#pod 'QMServicesDevelopment', :git => 'git#github.com:QuickBlox/q-municate-services-ios.git', :commit => 'ab56ac143bb770e76409a027bfb38de582d728aa'
#For development pods
pod 'QMServicesDevelopment', :git => 'https://github.com/QuickBlox/q-municate-services-ios.git'
end
Go through the below steps and your problem will be solved:
1) Tap on "Pods.xcodeproj" in your project
2) Select all the pods / any of one in which you are facing the issue.
3)Tap on "Build Settings" and change "Build Active Architecture Only" to "NO"
4) Now try to build to build the project and your problem will be solved.
Hope this helps!
If you are using swift you have to link these libraries in the build settings of the project
search for the Framework search path and add the path for the libraries
I hope you have added all the frameworks mentioned by the Quickblox website ,
Add -lxml2, -ObjC flags to Other Linker Flags section in project settings
Official doc link including bolts if it's not already added by pods
For QMCV and QMService i am also facing some issue recently but after some setting is worked

Pods library is linked twice with first target, as libPods.a and libPods-<targetname>.a

I have the project, that contains two targets one for iOS and one for OSX.
Here's how the Podfile looks like.
# Pods
xcodeproj 'ipolypus.xcodeproj'
pod 'BlocksKit'
pod 'Reachability'
pod 'MKStoreKit'
# Objective C
pod 'libextobjc'
pod 'LinqToObjectiveC'
target :ipolypus, :exclusive => false do
platform :ios, '5.1.1'
pod 'CocoaLumberjack'
pod 'EGOTableViewPullRefresh'
pod 'SVProgressHUD'
pod 'FlurrySDK'
# AdMob SDK and AdMob mediation adapter
pod 'AdMob'
pod 'AdMobMediationAdapterIAd'
end
target :ipolypusTests, :exclusive => true do
pod 'CocoaLumberjack'
end
target :'ipolypus-osx', :exclusive => false do
platform :osx
pod 'CocoaLumberjack'
end
After running pod install I can see that two Pods libraries are linked against the first target (ipolypus).
libPods.a and libPods-ipolypus.a
If I try to build the project right away, I will get strange link errors, like missing FlurrySDK symbols.
To fix it, I have to remove libPods.a and libPods-ipolypus.a from the list of libraries to link with the target, run pod install again, then manually remove libPods.a for the first target and then it will build and link.
There must be something wrong with the way I make that Podfile. I checked related posts, couldn't find similar problem.
Update
Here's the link error
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Flurry", referenced from:
objc-class-ref in IOSAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
After I do the steps described above, I will have successful builds until next pod install or pod update.
I should also mention, that the project had single target for quite a while, then I added OSX target and modified Podfile for that, and that's when the problems started.
But I tried to remove Podfile.lock and to wipe Pods folder, still the problem occurs.
And I had another type of error, where linker failed because the same symbol was already defined, but I don't see that one anymore.
I got to the cause of "double-linking" problem.
It's caused by the structure of the Podfile, as expected.
Since I wanted to have some common pods available both for OSX and iOS targets, I put them all in the beginning.
xcodeproj 'ipolypus.xcodeproj'
pod 'BlocksKit'
pod 'Reachability'
pod 'MKStoreKit'
# Objective C
pod 'libextobjc'
pod 'LinqToObjectiveC'
These common pods will be in libPods.a library, also, CocoaPods can't stand the fact that some pods library is not linked against a target, so it will link libPods.a against default project target, in my example it's ipolypus.
Then there's libPods-ipolypus.a generated for ipolypus iOS target. Since this target is not exclusive, things like FlurrySDK will be included into both libPods.a and libPods-ipolypus.a, resulting into duplicated symbols while linking.
After trying to figure out the proper way to use exclusive/non-exclusive target configs, I ended up with separate list of pods for each target. Might be a bit longer than I would want, but does the job as expected.
# Pods
xcodeproj 'ipolypus.xcodeproj'
target :ios, :exclusive => true do
platform :ios, '6.0'
link_with 'ipolypus'
# shared
pod 'CocoaLumberjack'
pod 'Reachability'
pod 'MKStoreKit'
pod 'LinqToObjectiveC'
# pod 'EGOTableViewPullRefresh'
# platform
pod 'SVProgressHUD'
pod 'FlurrySDK'
# AdMob SDK and AdMob mediation adapter
pod 'Google-Mobile-Ads-SDK'
pod 'AdMobMediationAdapterIAd'
end
target :iosTests, :exclusive => true do
platform :ios, '6.0'
link_with 'ipolypusTests'
pod 'OCMock'
end
target :osx, :exclusive => false do
platform :osx, '10.7'
link_with 'ipolypus-osx'
# shared
pod 'CocoaLumberjack'
pod 'Reachability'
pod 'LinqToObjectiveC'
end
target :osxTests, :exclusive => true do
platform :osx, '10.7'
link_with 'ipolypus-osxTests'
pod 'OCMock'
end

Resources