question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'sharedApplication' is unavailable: not available on iOS (App Extension)

See original GitHub issue

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

Steps To Reproduce

  1. Just build a dummy iOS app having a share extension target will trigger this

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

7reactions
kevinetorecommented, Oct 18, 2019

@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
0reactions
stale[bot]commented, Jan 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'sharedApplication' is unavailable… | Apple Developer Forums
My app has been running good 20mins ago. But when I build it again just after I removed and updated some pods, my...
Read more >
'sharedApplication' is unavailable: not available on iOS (App ...
Description: I'm trying to configure OneSignal for iOS however I'm getting an error saying "'sharedApplication' is unavailable: not ...
Read more >
not available on iOS (App Extension) - Stack Overflow
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
Read more >
'sharedApplication' is unavailable: not available on iOS (App ...
'sharedApplication' is unavailable: not available on iOS (App Extension). This error may occur when we try to build some third-party pods ...
Read more >
not available on iOS (App Extension) - Use view controller ...
Coding example for the question 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found