ld: library not found for -lReact-RCTVibration - ios

I am able to build and run the app in a simulator. However, whenever I want to archive it (selecting any ios devices) to release the app into the AppStore, I am getting this error.
ld: warning: directory not found for option '-L/Users/bigyankarki/Library/Developer/Xcode/DerivedData/Neex-dnesybikpygafkfxhimxsgrjawis/Build/Intermediates.noindex/ArchiveIntermediates/Neex/BuildProductsPath/Release-iphoneos/React-RCTVibration'
ld: warning: directory not found for option '-L/Users/bigyankarki/Library/Developer/Xcode/DerivedData/Neex-dnesybikpygafkfxhimxsgrjawis/Build/Intermediates.noindex/ArchiveIntermediates/Neex/BuildProductsPath/Release-iphoneos/react-native-safe-area-context'
ld: library not found for -lReact-RCTVibration
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have followed this, and other multiple solutions with the same library not found error, but to no avail. I even included it to podfile,
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
target 'Neex' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'RNCAsyncStorage', :path => '../node_modules/#react-native-async-storage/async-storage'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
pod 'RNSVG', :path => '../node_modules/react-native-svg'
target 'NeexTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
and even linked it in buildphase, but none works.

I solved the problem by setting 'Build setting architectures only' to Yes for both release and debug. After that, the problem seems to be resolved and I was able to archive the app.

Related

React-Native: Could not build module 'Darwin' after upgrading react & react-native

After upgrading react-native package from 0.63.4 to 0.64.4 I got following errors in Xcode (on MacBook Pro M1) while building and running the app on simulator and device:
I tried to it with and without using flipper, but nothing helped.
Also added CoreFoundation and Foundation Framework manually to the project and ran Xcode with and without Rosetta enabled.
This is my current PodFile:
source 'https://github.com/CocoaPods/Specs.git'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.0'
target 'MyApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'react-native-netinfo', :path => '../node_modules/#react-native-community/netinfo'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
My working solution for this is to create a new, clean project with the version you want to upgrade to.
Afterwards do following steps:
Open both .xcworkspace files in Xcode
Head over to your Targets Build Settings
Search for "Header Search Paths"
Copy all Header Search Paths from new Project to your project you want to upgrade
Remove DerivedData, Clean Build and Run again
Run pod install. Maybe you need to upgrade some packages
Additionally a nice npm script for rebuilding .xcworkspace (Replace "[PRJECT_NAME]" with your .xcworkspace name):
"renew-pods-m1": "cd ios; rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf [PROJECT_NAME].xcworkspace; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; arch -x86_64 pod install;"
Note: Have a look at your PodFile. Maybe you need to change the use_react_native implementation and add the post_install script
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
At the end of the PodFile
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
For me it was Flipper. I wasn't using it in my old project, and it was automatically enabled in my new one. Just comment out the line in your Podfile if your project doesn't require it.
# :flipper_configuration => FlipperConfiguration.enabled,

Symbol(s) not found for architecture x86_64 in Xcode 13

Currently I'm working on integrating the firebase cloud messaging service to a react native mobile application. I followed their documentation on firebase integration and edited the pod file to use frameworks.
When using the frameworks. I got an error about transitive dependencies. that's why I had to add pre install do and $static_framework.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
$RNFirebaseAsStaticFramework = true
target 'P2PMobileApp' do
use_frameworks!
$static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly', 'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion', 'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit', 'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method,:verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name)
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
target 'P2PMobileAppTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Now I'm having following error when I try to run app with react-native run-ios
Undefined symbols for architecture x84_64:
"google::LogMessage::LogMessage(char const*, int, int)", referenced from:
__react_native_log_default in react_native_log.o
"google::LogMessageFatal::LogMessageFatal()", referenced from:
__react_native_log_default in react_native_log.o
...
Note: I have done my pod installation with arch -x86_64 pod install because I'm working on a mac mini with an M1 chip.
I tried to resolve that issue with the following solutions. But none of them worked out
Link binaries with xcode
Changing the architecture
Change the architecture for pod installation (Then I get the same issue related to arm64)
Removing glog from $static_framwork variable (Then the same Undefined symbols for architecture x84_64: issue arises for double conversion module)
Still I,m stuck with build fails. Any help on this will be highly appreciated.
If you are using M1 chip then it can be resolved with below steps:
Go to application > right click on Xcode > Get info > select Open using Rosetta
Restart the system
The other solution can be adding library
You can add it by:
Clicking on your project in the upper left of the left pane (the blue
icon).
In the middle pane, click on the Build Phases tab.
Under "Link Binary With Libraries", click on the plus button.
Find YOUR_FRAMEFOERK.framework from the list and hit Add.

React Native builds work in simulators but not on ios device?

I have my build working fine on ios simulators, but when I plug in my iphone and run react-native run-ios --device "Max’s Iphone 12 Mini", the build fails. Error Below from rn cli below.
The following build commands failed:
Ld /Users/maxmandia/Library/Developer/Xcode/DerivedData/musicplace_ios-aaznfqkkkkeeldftonqjsqawrhgr/Build/Products/Debug-iphoneos/RCT-Folly/folly.framework/folly normal (in target 'RCT-Folly' from project 'Pods')
When I try to run the app in xcode, I get another error:
ld: -U and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
Here is my pod file
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
target 'musicplace_ios' do
use_frameworks!
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'musicplace_iosTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Any help would be great! I tried disabling bitcode and it still showed ENABLE_BITCODE=YES in the error message - cleaned my build folder too. Really out of idea right now.

ARC Semantic issue: No known class method for selector 'componentsWithLink:domain:'

I am stuck with an issue since past 5+ hours, I am working on a react native project of version 0.59.0, it is a 1.5 years old project and it is working fine on android, but when building it for iOS, I was facing many issues one of which was:
ld: library not found for -lFirebaseCore
So to make it work, I included arm64 in excluded architecture and my build started working on simulator but my IPA was not working on a real device, again after removing arm64 and resolving multiple issues, I am stuck with the following issue which is coming in RNFirebaseLinks.m file as :
ARC Semantic Issue Group: No known class method for selector 'componentsWithLink:domain:'
Also sharing my device specifications:
macos: Macbook pro(11.0.1), chip: Apple M1,
Xcode version: 12.4
PodFile content:
**# Uncomment the next line to define a global platform for your project**
platform :ios, '10.0'
target 'PropertiesPublisherNew' do
**# Uncomment the next line if you're using Swift or would like to use dynamic frameworks**
#use_frameworks!
**# Pods for PropertiesPublisherNew**
pod 'Firebase/Core', '6.3.0'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'Firebase/Database'
**# pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'**
**# pod 'RNScreens', :path => '../node_modules/react-native-screens'**
**# pod 'react-native-netinfo', :path => '../node_modules/#react-native-community/netinfo'**
#pod 'react-native-webview', :path => '../node_modules/react-native-webview'
target 'PropertiesPublisherNewTests' do
inherit! :search_paths
**# Pods for testing**
end
end
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
target 'PropertiesPublisherNew-tvOS' do
**# Uncomment the next line if you're using Swift or would like to use dynamic frameworks**
**# use_frameworks!**
**# Pods for PropertiesPublisherNew-tvOS**
target 'PropertiesPublisherNew-tvOSTests' do
inherit! :search_paths
**# Pods for testing**
end
end
Can anyone please help me out with this?
Add pod 'Firebase/Core', '~> 5.15.0' in PodFile inside IOS Folder

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.

Resources