When I try to build my iOS app (which includes a share extension) I'm getting this error:
โ [...]/node_modules/react-native/React/Modules/RCTTiming.m:150:49: 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
_backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"rct.timing.gb.task" expirationHandler:^{
[...]
My Podfile looks like this:
platform :ios, '10.3'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
def common_pods
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
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 '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'
use_native_modules!
end
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
# Pods for MyApp
pod 'Hakawai', '6.0.1'
common_pods
end
target 'ShareExtension' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
# Pods for ShareExtension
common_pods
end
target 'NotificationService' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
# Pods for NotificationService
# pod 'Sodium', :git => 'https://github.com/jedisct1/swift-sodium.git'
pod 'Sodium', '0.8.0'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if ['Sodium'].include? target.name
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
end
end
React Native version:
System:
OS: macOS 10.15
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 1.17 GB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.10.0 - /var/folders/r4/pdxxhfbj3cqg_0n5th1p2t400000gn/T/yarn--1571217098131-0.37052803821248426/node
Yarn: 1.19.0 - /var/folders/r4/pdxxhfbj3cqg_0n5th1p2t400000gn/T/yarn--1571217098131-0.37052803821248426/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v12.10.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
Now I guess one could simply replace the sharedApplication call with RCTSharedApplication() as a quick fix (I've done it but then it fails somewhere further in DevSupport-RCTDevLoadingView) but I'm wondering if it's the best approach or if there are pods that can simply be excluded from the extension target?
@alexisbronchart I had add some lines in my Podfile which fixed the issue (for now).
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end
@kevinetore it builds, thanks! Did you get a build on the app store without any problem?
@alexisbronchart I only released a version to Testflight with the 61.2 upgrades, no problems there.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
Most helpful comment
@alexisbronchart I had add some lines in my
Podfilewhich fixed the issue (for now).