Build fail when using use_frameworks! react-native - react-native

I'm developing an app using React-native 0.59.1. But I've got an issue that I can not link a static library. In Podfile I am installing both frameworks and library using Cocapods.
Xcode will throw an error the library is not linked yet when Podfile contains the keyword use_framework!, but is successful if I remove this keyword.
Can you help me to fix it?
platform :ios, '10.0'
target 'Test_RN_0_59_1' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
rn_path = '../node_modules/react-native'
pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"
pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/GLog.podspec"
pod 'React', path: rn_path, subspecs: [
'Core',
'CxxBridge',
'RCTAnimation',
'RCTActionSheet',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
'RCTPushNotification',
'RCTCameraRoll',
'RCTSettings',
'RCTBlob',
'RCTGeolocation',
'DevSupport'
]
pod 'rn-juicy-score', :path => '../node_modules/rn-juicy-score'
Capture

If you want to use static library with use_framework! in React Native, you can use the following solution:
...
pod 'rn-juicy-score', :path => '../node_modules/rn-juicy-score'
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('rn-juicy-score')
def pod.build_type
Pod::BuildType.static_library
end
end
end
end
Adding a condition in pre_install block would make sure your specified pod is built using static library and the rest are built using dynamic framework. This will allow you to use both build systems and configure according to requirement.

If you are using react native > 0.68.x, you need use use_frameworks!, you must to add in your Podfile this code:
$static_framework = ['Flipper-Boost-iOSX', 'Flipper-RSocket', 'glog', 'Yoga', 'YogaKit', 'React-logger', 'Flipper-Fmt', 'RCT-Folly', 'Flipper-Folly', 'React-jsi', 'FlipperKit', 'Flipper', 'Flipper-Glog', 'Flipper-PeerTalk', 'React-cxxreact', 'React-jsiexecutor', 'React-Core', 'React-RCTText', 'RCTTypeSafety', 'ReactCommon', 'React-Codegen', 'React-RCTVibration', 'React-RCTSettings', 'React-RCTNetwork', 'React-RCTLinking', 'React-RCTAnimation', 'React-RCTBlob', 'React-RCTImage', 'React-CoreModules']
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
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:production => production,
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
#:flipper_configuration => FlipperConfiguration.enabled,
:flipper_configuration => FlipperConfiguration.enabled(["Release", "Debug"], { 'Flipper' => '0.127.0' }),
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
After that run pod install to update the changes. I tested this in Intel & M1 mac's.

Related

React Native Maps not working with React Native Firebase with use_framework

I know its a common question as React Native maps does not support use_frameworks! but all the solutions in the web not working for me (may be those are too complicated). May anyone please help me how to make React Native maps work with use_frameworks! :linkage => :static as React native Firebase demands it. I am ready for my all available bounty :(
React native version: 0.70.6
React Native Maps: 1.3.2
I had to add google maps and firebase both so needed to avoid use_framwork. This is what has worked from me after two days got wasted on it.
solution is to use firebase pods like this.
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'FirebaseStorageInternal', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'FirebaseMessagingInterop', :modular_headers => true
pod 'GTMSessionFetcher', :modular_headers => true
pod 'FirebaseAppCheckInterop', :modular_headers => true
pod 'FirebaseAuthInterop', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
as explained on this link. give that person a thumbs up as well.
https://dev.to/matthewzruiz/firebase-the-following-swift-pods-cannot-yet-be-integrated-as-static-libraries-b59
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, '13.0'
install! 'cocoapods', :deterministic_uuids => false
target 'ReactNativeBoilerPlate' do
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
config = use_native_modules!
# React Native Maps dependencies
# 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}/.."
)
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'RNPermissions', :path => '../node_modules/react-native-permissions'
target 'ReactNativeBoilerPlateTests' 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)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
end
end
end
end

React has been deprecated - React Native

I am creating an app using React Native and am trying to install cocoa pods for iOS but when I enter pod install into the terminal I get the following warning.
Then when I try to run my app in an iOS emulator it crashes and won't run.
Here is the Xcode error.
I am running react native 0.63.2.
Here is my pod file
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
target 'Example' do
# Comment the next line if you don't want to use dynamic frameworks
#use_frameworks!
# Pods for Example
# pod 'React', :path => '../node_modules/react-native'
pod 'RNSound', :path => '../node_modules/react-native-sound'
pod 'RNCAsyncStorage', :path => '../node_modules/#react-native-community/async-storage'
pod 'RNCMaskedView', :path => '../node_modules/#react-native-community/masked-view'
pod 'RNCPushNotificationIOS', :path => '../node_modules/#react-native-community/push-notification-ios'
pod 'react-native-slider', :path => '../node_modules/#react-native-community/slider'
pod 'RNFBApp', :path => '../node_modules/#react-native-firebase/app'
pod 'RNFBAuth', :path => '../node_modules/#react-native-firebase/auth'
pod 'RNFBMessaging', :path => '../node_modules/#react-native-firebase/messaging'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
pod 'react-native-safe-area-context', :path => '../node_modules/react-native-safe-area-context'
pod 'RNScreens', :path => '../node_modules/react-native-screens'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
target 'Example-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'ExampleTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'Example-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Example-tvOS
end
The issue is that you don't install pod for the correctly target.
This is strange if this is a new RN project because it should take the correct target.
In you recently image added seems like you have another target called AntrimElimChurch so if you want to install pod for that target you should change it in PodFile as well
am running react native 0.63.2.
Here is my pod file
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
target 'AntrimElimChurch' do
# Comment the next line if you don't want to use dynamic frameworks
#use_frameworks!
# Pods for Example
# pod 'React', :path => '../node_modules/react-native'
pod 'RNSound', :path => '../node_modules/react-native-sound'
pod 'RNCAsyncStorage', :path => '../node_modules/#react-native-community/async-storage'
pod 'RNCMaskedView', :path => '../node_modules/#react-native-community/masked-view'
pod 'RNCPushNotificationIOS', :path => '../node_modules/#react-native-community/push-notification-ios'
pod 'react-native-slider', :path => '../node_modules/#react-native-community/slider'
pod 'RNFBApp', :path => '../node_modules/#react-native-firebase/app'
pod 'RNFBAuth', :path => '../node_modules/#react-native-firebase/auth'
pod 'RNFBMessaging', :path => '../node_modules/#react-native-firebase/messaging'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
pod 'RNReanimated', :path => '../node_modules/react-native-reanimated'
pod 'react-native-safe-area-context', :path => '../node_modules/react-native-safe-area-context'
pod 'RNScreens', :path => '../node_modules/react-native-screens'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
target 'Example-tvOSTests' do
inherit! :search_paths
# Pods for testing
pod 'react-native-notifications', :path => '../node_modules/react-native-notifications'
end
target 'ExampleTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'Example-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for Example-tvOS
end
After this change run again pod install and it should build

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found

App get crashed with the above message. Unable to view my app screen.
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'DevSettings' could not be found. Verify that a module by this name is registered in the na..., stack:
platform :ios, '9.0'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
target 'App' do
# Pods for App
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
#pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
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 'react-native-cameraroll', :path => '../node_modules/#react-native-community/cameraroll'
target 'AppTests' do
inherit! :search_paths
# Pods for testing
end
use_native_modules!
end
target 'App-tvOS' do
# Pods for App-tvOS
target 'App-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
I had the same error and the problem was that I built the app in Release mode but the main.jsbundle was dev mode.
Using react-native#0.61.5
I stopped the Metro process and run again
react-native run-ios --configuration Release --device --scheme="MyTargetScheme"
For us the issue was that we were (manually) building the RN bundle for our production app without setting the dev value in the react-native CLI.
When testing on simulator or device with a debug configuration in Xcode, this was not a problem. But since we archive for the App Store with a release config, we were seeing this crash in production.
The react-native bundle command has the --dev switch set to true by default. So the solution was simply to add --dev false to the bundle command.
In my case, my issue is resolved by node -v changes.
Initially I have used node 9.4.0 and then I have changed the node to 12.
Due to this version change the above error occurs.
So I have changed to node 9.4.0 and rebuild the app in release mode. It works fine
Any one know why the node version changes failed to bundle the app in release mode
In my specific situation, I was using a deprecated version of expo/ex-navigation , in RN 0.64.2 we had one problem, because RN doesn't understood the #2x.android or similars casts to choose the right image for an Icon. The problem is Described here : #31348.
I sold my conflicts locally inside node_modules and make Android work fine (then I forked and create a correction under my control), but when I came back to work in my IoS problems, I forgot to use this correction.
So, my problem was occurring in one lib i had in my node_modules, and as I extensively searched, this problems use to happen in this kind of situation.
So if #takameyer solution doesn't work as it doesn't to me, I suggest taker a look in your node_modules dependencies...
probably trying to build your bundle thought react-native-cli will give you an better log then building this in xcode, since in my case xcode build worked but give-me a run-time error(Release).
I hope it help someone in the future.
This crash reason is when your Target is Release Mode and your bundle is Development Mode.
So my iOS target was set to Release
And my bundle was build to Development, with this command :
react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --platform='ios' --assets-dest='./ios'
So to fix this, i build again my bundle with this command.
react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'
And works.
Thanks #sumizome and #strdr4605 i made this with your answers.

'React/RCTEventEmitter.h' file not found (CocoaPods)

I'm going back to a React Native project and getting the following build error:
'React/RCTEventEmitter.h' file not found
The project uses CocoaPods to bring in React and its dependencies. The error seems to be to do with a missing header in one of my custom modules. The specific line with the import error is at https://github.com/adamski/react-native-couchbase/blob/8bc089a1e4cfdf62599b1f156072aa12a3823b30/ios/RCTCouchBase/RCTCouchBase/RCTCouchBase.h#L8
The error only started to appear after adding a new node module and running pod install.
I've have tried various things to fix it such as:
Upgrading RN (from 0.51 to 0.55 and back again)
Deleting and reinstalling node_modules
Adding various paths to Header Search Paths. e.g. ${PODS_ROOT}/Headers/Public/React
Deleting Build folder
If I change the import to #import "RCTEventEmitter" it then falls over on:
'React/RCTBridge.h' file not found from RCTEventEmitter.h.
Anything else that could be going wrong here?
I recently had to upgrade to Xcode 10 for another project, perhaps that is an issue?
Podfile:
react_native_path = '../../node_modules/react-native'
install! 'cocoapods', :deterministic_uuids => false
platform :ios, '8.0'
target 'MyApp - App' do
pod 'HockeySDK', '~> 4.1.3'
pod 'React', :path => '../../node_modules/react-native', :subspecs => [
'ART',
'Core',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTText',
'RCTWebSocket',
'RCTAnimation',
'DevSupport',
'BatchedBridge',
# Add any other subspecs you want to use in your project
]
# To use CocoaPods with React Native, you need to add this specific Yoga spec as well
pod 'yoga', :path => react_native_path + '/ReactCommon/yoga'
pod 'couchbase-lite-ios', '~> 1.4.0'
pod 'couchbase-lite-ios/ForestDB', '~> 1.4.0'
pod 'mp3lame-for-ios'
pod 'ReactNativeCouchbase', :path => '../../node_modules/react-native-couchbase'
pod 'ReactNativeNavigation', :path => '../../node_modules/react-native-navigation'
pod 'RNVectorIcons', :path => '../../node_modules/react-native-vector-icons'
pod 'RNSVG', :path => '../../node_modules/react-native-svg'
pod 'RNDeviceInfo', :path => '../../node_modules/react-native-device-info'
pod 'react-native-in-app-utils', :path => '../../node_modules/react-native-in-app-utils'
pod 'react-native-mail', :path => '../../node_modules/react-native-mail'
pod 'BVLinearGradient', :path => '../../node_modules/react-native-linear-gradient'
pod 'RNSound', :path => '../../node_modules/react-native-sound'
pod 'react-native-youtube', :path => '../../node_modules/react-native-youtube'
pod 'RNStoreReview', :path => '../../node_modules/react-native-store-review/ios'
end

No podspec found for `React` in `../node_modules/react-native`

No podspec found for React in ../node_modules/react-native
I am getting above error when i do pod install after successful npm install
NPM Version : 5.6.0
Below is the pod file text
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
react_native_path = '../node_modules/react-native'
pod 'Yoga', :path => "#{react_native_path}/ReactCommon/yoga"
pod 'React', :path => react_native_path, :subspecs => [
'Core',
'RCTText',
'RCTImage',
'DevSupport',
'BatchedBridge',
'RCTLinkingIOS',
'RCTAnimation',
'RCTActionSheet',
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]
end
Check that file ../node_modules/react-native/React.podspec is really exists relative to Podfile. If not, check that you package.json really contain react-native as dependency.
For standard RN project directory structure, Podfile should be placed in <projectRoot>/ios/Podfile, and looks like:
platform :ios, '9.0'
target 'CGUI' do
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
'RCTAnimation',
'RCTBlob',
'RCTText',
'RCTNetwork',
'RCTWebSocket',
'RCTImage',
'RCTLinkingIOS',
'DevSupport',
]
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 'RNDeviceInfo', :path => '../node_modules/react-native-device-info'
pod 'RNFS', :path => '../node_modules/react-native-fs'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
end
This is for RN 0.51.0
after successful npm install,
delete the file podfile.lock in your project root dir,
then pod install in your project root dir.
this works for me.
Go to your project directory
in IOS write command in terminal to open Xcode
open ios/[projectname].xcworkspace
and open Pods folder from the left navigation bar and open Profile file
after that remove the line,
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
and rebuild project.