React-Native (0.64.1) & Notification Extension - react-native

I am trying to integrate a Notification Extension in my react-native app using the Batch SDK. However I have the following error:
‘sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
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, '10.0'
abstract_target 'BrandName' 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
)
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
target 'BrandNameApp' do
#Production-specific pods
target 'BrandNameAppTests' do
inherit! :complete
# Pods for testing
end
end
target 'BrandNameAppDevelopment' do
#Development-specific pods
end
target 'BrandNameAppStage' do
#Stage-specific pods
end
target 'RichNotificationsExtension' do
#Extension-specific pods
pod 'BatchExtension-ObjC'
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
If I try to put my target 'RichNotificationsExtension', else where in my podfile, the module will not be found by the extension file.
I have try to set the "Require Only App-extension-safe API" to "NO" as I have seen in some answers but Xcode won't allow me to build anymore and if I force it in my pod file, the module will not be found either.
Does anyone have a functioning podfile in react-native working with an extension ?
Thanks in advance

Related

Unable to find a specification for `React-Core`

trying to install "react-native-camera" to my project.
I'm following those steps: https://github.com/react-native-camera/react-native-camera/blob/master/docs/installation.md#requirements
But at "Additional installation steps" when I use "pod install" It returns;
[!] Unable to find a specification for `React-Core` depended upon by `react-native-camera/BarcodeDetectorMLKit`
You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
My Podfile below:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'blabla' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]
# Pods for blabla
target 'blablaTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'blabla-tvOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for blabla-tvOS
target 'blabla-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
React native version is 62.0.
React-native-camera version is 3.40.0
What could be problem?
add manually to your Podfile the pod missing:
pod 'React-Core', :path => '../node_modules/react-native/React'

CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker":

I just updated to RN v0.62 and running app on iOS gives me following error
!] CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker":
In snapshot (Podfile.lock):
ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
In Podfile:
ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)
None of your spec sources contain a spec satisfying the dependency: `ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)`.
I deleted all node_modules and did npm i. I also did pod install in iOS directory but the issue persists. I also did pod repo update.
For React native 0.62 version
So I figure it out
Replace following line in your Podfile
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
with
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
Edit:
If you have updated to React Native version 0.63
Delete Podfile.lock from iOS folder.
Do npm i
Open podfile from iOS folder
Delete everything and copy below contents
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'
platform :ios, '10.0'
target 'RNTodo' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'RNTodoTests' 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 these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'RNTodo-tvOS' do
# Pods for RNTodo-tvOS
target 'RNTodo-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Replace RNTodo with your own project name, cd to iOS folder in the terminal and do pod install and everything should work
Also RN 0.63 has dropped support for iOS 9
I solved this issue (version 0.63) by changing the line in the Podfile from
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
to
pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
I think jscallinvoker version is deprecated try to replacing
jscallinvoker
to
callinvoker
RN 0.63 has dropped support for iOS 9
So in pod file
replace
platform :ios, '9.0'*
platform :ios, '10.0'*
and
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
go to the ios folder in the terminal run
pod install
run react-native run-ios
On Upgrade to React Native 0.63.0
This issue happens to my project after upgrading React Native to version 0.63.0 so for the solution I just remove the Podfile.lock and delete whole the Podfile and add the new content from a fresh install React Native project on the latest version and it means its content should be:
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native/scripts/react_native_pods'
platform :ios, '10.0'
target '[YourProjectName]' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target '[YourProjectName]Tests' 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 these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target '[YourProjectName]-tvOS' do
# Pods for [YourProjectName]-tvOS
target '[YourProjectName]-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Note: it is obvious you should replace your project name with [YourProjectName].
After it, run npx pod-install command on the root of your project and everything will back on track.
In case anyone is still having issues with React Native Version 0.63.0 then this worked for me
Updating the callinvoker pod as follows
pod 'React-callinvoker', :path => "#{rnPrefix}/ReactCommon/callinvoker"
In RN 0.63.0 you can remove all RN pods from you podfile and just include the following lines inside the target.
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
Also this line needs to be added after the platform line at the beginning of the podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
After this, delete the Pods directory, Podfile.lock and the workspace file. Then just pod install.
React-Native is now configuring pods dynamically, so you don't need to list each one anymore;
use_react_native!(:path => config["reactNativePath"])
This is what you get from a 63.1 base 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, '10.0'
target 'test' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'testTests' do
inherit! :complete
end
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'test-tvOS' do
target 'test-tvOSTests' do
inherit! :search_paths
end
end
Making manual adjustments according to https://react-native-community.github.io/upgrade-helper/?from=0.62.2&to=0.63.2 might help.
You will then have to run the command cd ios && pod install.
platform :ios, '11.0'
I solved this issue (version 0.63.4) by changing as below
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
# Maybe someone is
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
↓
pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
In case you already had callinvoker but you still have an error. This manipulation helped me :
react-native start --reset-cache
rm -rf node_modules/
rm -rf package-lock.json
cd ios
pod deintegrate
cd ..
rm -rf ios/Podfile.lock
npm install
npm audit fix
react-native link
cd ios
pod install
cd ..
react-native run-ios
Faced this issue while upgrading Expo bare workflow 0.38 (RN 0.62) to 0.39 (has RN 0.63). Edited answer of #Pritish did work, But it says this error
[!] Unable to find a target named `RNTodo-tvOS` in project `RNTodo.xcodeproj`, did find `RNTodo`.
And
[!] Unable to find a target named `RNTodoTests` in project `RNTodo.xcodeproj`, did find `RNTodo`.
Got workaround by changing Podfile like below
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'daytodiary' do
use_unimodules!
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
What changed?
ADD unimodules at top
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
ADD use_unimodules! before config = use_native_modules!.
REMOVE
target '[YourProjectName]Tests' do
inherit! :complete
# Pods for testing
end
REMOVE
target 'RNTodo-tvOS' do
# Pods for RNTodo-tvOS
target 'RNTodo-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
For Android (If you are getting errors after upgrading)
In android/build.gradle
Change
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
To
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
}
if you have upgraded react native to 0.65+,
you need to do a change in podfile
platform :ios, '10.0'
to
platform :ios, '11.0'

React missing in Product (Edit Scheme) after react-native upgrad

After upgrade to latest react-native Product -> Edit scheme is missing in Xcode.
My Podfile is like below
#Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
pod 'Fabric'
pod 'Crashlytics'
target 'Helloworld' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for Helloworld
target 'Helloworld-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'HelloworldTests' do
inherit! :search_paths
# Pods for testing
end
end

React Native 0.57 + CocoaPods - Failure to locate linked libraries only in CI Environment

I am hitting a brick wall at the moment trying to get my app to build in VS AppCenter. It's a react-native project, with some dependencies brought in via cocoapods.
Everything builds locally fine (clean clone on clean vm)
In the CI Environment in AppCenter though I get the following errors:
ld: warning: directory not found for option '-L/Users/vsts/Library/Developer/Xcode/DerivedData/projectname-adroxiklvgljuicvfqowylcdxjrt/Build/Intermediates.noindex/ArchiveIntermediates/unisafe/BuildProductsPath/Release-iphoneos/BVLinearGradient'
ld: library not found for -lGoogle-Maps-iOS-Utils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Archive Failed
I get the first warning a number of times for each pod.
Here is my Podfile
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
project './projectname.xcproj'
target 'projectname' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for projectname
pod 'AppCenter/Push', '~> 1.10.0'
pod 'AppCenter/Crashes', '~> 1.10.0'
pod 'AppCenter/Analytics', '~> 1.10.0'
pod 'AppCenterReactNativeShared'
rn_path = '../node_modules/react-native'
rn_maps_path = '../node_modules/react-native-maps'
pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec"
pod 'React', path: rn_path, subspecs: [
'ART',
'Core',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
]
pod 'react-native-maps', path: rn_maps_path
pod 'react-native-google-maps', path: rn_maps_path # Remove this line if you don't want to support Google Maps on iOS
pod 'GoogleMaps' # Remove this line if you don't want to support Google Maps on iOS
pod 'Google-Maps-iOS-Utils' # Remove this line if you don't want to support GoogleMaps on iOS
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'react-native-background-timer', :path => '../node_modules/react-native-background-timer'
pod 'ReactNativePermissions', :path => '../node_modules/react-native-permissions'
pod 'lottie-ios', :path => '../node_modules/lottie-ios'
pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
pod 'TouchID', :path => '../node_modules/react-native-touch-id'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
platform :ios, '11.0'
# target 'projectnameTests' do
# inherit! :search_paths
# # Pods for testing
# end
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
In my library search paths i have:
$(inherited)
$(BUILD_DIR)/${CONFIGURATION}$(EFFECTIVE_PLATFORM_NAME)
"${PODS_ROOT}"
Any ideas would be greatly appreciated. Thanks.
Not a perfect solution...but resolved this by removing and re-adding everything under 'Linked Frameworks and Libraries' in XCode build settings.
I'll close this, but if anyone else has this issue, reply here or PM - happy to help.

How to Add a "Target" to a pod file? (such as HockeyApp)

I'm reading React Native Cookbook by Crysfel Villa, Stan Bershadskiy
I'm at a chapter on using hockeyapp and not sure how to setup the podfile. These are the directions:
How to do it...
First we need to install the react-native-hockeyapp
module in our application. Open the Terminal, go to your application's
root project directory and enter the following command: $ npm install
react-native-hockeyapp --save Go into your ios/ directory and
initialize your Podfile: $ pod init Open your Podfile and add pod
"HockeySDK" to your target. Back in the Terminal, install the Podfile:
$ pod install
I am not 100% sure about "add pod HockeySDK to your target"
My podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for MyApp
target 'MyApp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'MyApp-tvOS' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for MyApp-tvOS
target 'MyApp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Any idea on how to modify the pod file correctly here?
If you want to include HockeySDK module in MyApp target (which is the app that you are builidng) you just need to add pod 'HockeySDK' line like this:
target 'MyApp' do
(...)
pod 'HokeySDK'
(...)
end
Then after running pod install open .xcworkspace file instead of .xcproj. You can find more information in official CocoaPods guide.