React-native-permissions: IOS: Notifications permission pod is missing with use_frameworks!

Created on 2 Oct 2019  路  16Comments  路  Source: zoontek/react-native-permissions

Bug

Adding use_frameworks! to the Podfile generates the following error:

Notifications permission pod is missing

Also, checkNotifications() and requestNotifications() don't work.

Note

I've already added the podspec to my Podfile:

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"

Environment info

React native info output:

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 26.12 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.13.0 - ~/.nodenv/versions/10.13.0/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nodenv/versions/10.13.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 27.0.1, 27.0.3, 28.0.3
      System Images: android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.10.1 => 16.10.1 
    react-native: ^0.61.1 => 0.61.1

Library version: 2.0.0

Steps To Reproduce

  1. Add use_frameworks! to the Podfile
  2. cd ios && pod install
  3. run the app and call checkNotifications() and requestNotifications()
bug

Most helpful comment

I ran into this issue again after the patch, use_frameworks! needed to be removed for it to work.

All 16 comments

The same issue

I've fix this issue by change content of RNPermission.h as below:

typedef NS_ENUM(NSInteger, RNPermission) {
  RNPermissionUnknown = 0,
#if __has_include("RNPermissionHandlerBluetoothPeripheral.h")
  RNPermissionBluetoothPeripheral = 1,
#endif
#if __has_include("RNPermissionHandlerCalendars.h")
  RNPermissionCalendars = 2,
#endif
#if __has_include("RNPermissionHandlerCamera.h")
  RNPermissionCamera = 3,
#endif
#if __has_include("RNPermissionHandlerContacts.h")
  RNPermissionContacts = 4,
#endif
#if __has_include("RNPermissionHandlerFaceID.h")
  RNPermissionFaceID = 5,
#endif
#if __has_include("RNPermissionHandlerLocationAlways.h")
  RNPermissionLocationAlways = 6,
#endif
#if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  RNPermissionLocationWhenInUse = 7,
#endif
#if __has_include("RNPermissionHandlerMediaLibrary.h")
  RNPermissionMediaLibrary = 8,
#endif
#if __has_include("RNPermissionHandlerMicrophone.h")
  RNPermissionMicrophone = 9,
#endif
#if __has_include("RNPermissionHandlerMotion.h")
  RNPermissionMotion = 10,
#endif
#if __has_include("RNPermissionHandlerPhotoLibrary.h")
  RNPermissionPhotoLibrary = 11,
#endif
#if __has_include("RNPermissionHandlerReminders.h")
  RNPermissionReminders = 12,
#endif
#if __has_include("RNPermissionHandlerSiri.h")
  RNPermissionSiri = 13,
#endif
#if __has_include("RNPermissionHandlerSpeechRecognition.h")
  RNPermissionSpeechRecognition = 14,
#endif
#if __has_include("RNPermissionHandlerStoreKit.h")
  RNPermissionStoreKit = 15,
#endif
};

and this is my podfile:

pod 'RNPermissions', :path => '../node_modules/react-native-permissions'

  permissions_path = '../node_modules/react-native-permissions/ios'

  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
  pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
  pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
  pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
  pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"
  pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec"
  pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec"

hope will help you.

Same issue here

I've fix this issue by change content of RNPermission.h as below:

typedef NS_ENUM(NSInteger, RNPermission) {
  RNPermissionUnknown = 0,
#if __has_include("RNPermissionHandlerBluetoothPeripheral.h")
  RNPermissionBluetoothPeripheral = 1,
#endif
#if __has_include("RNPermissionHandlerCalendars.h")
  RNPermissionCalendars = 2,
#endif
#if __has_include("RNPermissionHandlerCamera.h")
  RNPermissionCamera = 3,
#endif
#if __has_include("RNPermissionHandlerContacts.h")
  RNPermissionContacts = 4,
#endif
#if __has_include("RNPermissionHandlerFaceID.h")
  RNPermissionFaceID = 5,
#endif
#if __has_include("RNPermissionHandlerLocationAlways.h")
  RNPermissionLocationAlways = 6,
#endif
#if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  RNPermissionLocationWhenInUse = 7,
#endif
#if __has_include("RNPermissionHandlerMediaLibrary.h")
  RNPermissionMediaLibrary = 8,
#endif
#if __has_include("RNPermissionHandlerMicrophone.h")
  RNPermissionMicrophone = 9,
#endif
#if __has_include("RNPermissionHandlerMotion.h")
  RNPermissionMotion = 10,
#endif
#if __has_include("RNPermissionHandlerPhotoLibrary.h")
  RNPermissionPhotoLibrary = 11,
#endif
#if __has_include("RNPermissionHandlerReminders.h")
  RNPermissionReminders = 12,
#endif
#if __has_include("RNPermissionHandlerSiri.h")
  RNPermissionSiri = 13,
#endif
#if __has_include("RNPermissionHandlerSpeechRecognition.h")
  RNPermissionSpeechRecognition = 14,
#endif
#if __has_include("RNPermissionHandlerStoreKit.h")
  RNPermissionStoreKit = 15,
#endif
};

and this is my podfile:

pod 'RNPermissions', :path => '../node_modules/react-native-permissions'

  permissions_path = '../node_modules/react-native-permissions/ios'

  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral.podspec"
  pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars.podspec"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts.podspec"
  pod 'Permission-FaceID', :path => "#{permissions_path}/FaceID.podspec"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
  pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary.podspec"
  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"
  pod 'Permission-Motion', :path => "#{permissions_path}/Motion.podspec"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications.podspec"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary.podspec"
  pod 'Permission-Reminders', :path => "#{permissions_path}/Reminders.podspec"
  pod 'Permission-Siri', :path => "#{permissions_path}/Siri.podspec"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition.podspec"
  pod 'Permission-StoreKit', :path => "#{permissions_path}/StoreKit.podspec"

hope will help you.

This seems to work...

It looks to be an issue related to auto-linking...

The following, which disables auto-linking for just this library, also works and does not require monkey-patching the library every time it's downloaded:

(1) Add the above referenced configuration to one's Podfile and then cd ios && pod install

(2) In project root, create a file named react-native.config.js and add the following:

module.exports = {
  dependencies: {
    'react-native-permissions': {
      platforms: {
        ios: null,
      },
    },
  },
};

(3) Profit

It looks to be an issue related to auto-linking...

The following, which disables auto-linking for just this library, also works and does not require monkey-patching the library every time it's downloaded:

(1) Add the above referenced configuration to one's Podfile and then cd ios && pod install

(2) In project root, create a file named react-native.config.js and add the following:

module.exports = {
  dependencies: {
    'react-native-permissions': {
      platforms: {
        ios: null,
      },
    },
  },
};

(3) Profit

This also worked for me, and it's definitely better than updating the original file.

Thanks!

I actually go the other way - much better to develop the fix for real, make a PR, then use patch-package to integrate it smoothly (including CI and everything) while the PR works through, that way the whole thing slowly moves forward instead of going back with auto-link disabling.

I understand that's not for everyone but as a process it is pretty quick actually, and non-blocking

Yeah, that's another alternative, I actually was using it with patch-package, which I use for other libraries. The thing is that, for me, it doesn't feel right to be editing node_modules files, even if it's an smooth process.

I agree about 99%! I only couple patch-package usage with an active PR, it's a key part of the process for me - that it will converge. I love getting the PRs merged and deleting the patch :-)

Lol, Yeah, it feels like a relief when I can delete a patch because a new version already fixes my "issue".

Hopefully @dungnguyen10989 creates the PR, since it was his solution, and we confirmed that it works. I can totally do it, but it's his credit.

@elkinjosetm I already pushed it yesterday evening: https://github.com/react-native-community/react-native-permissions/commit/ed00c89c5476267a4b7c14d56f15f1c4914bb2fc, will give credits to @dungnguyen10989 in the release changelog.

Awesome, thank you guys!

I ran into this issue again after the patch, use_frameworks! needed to be removed for it to work.

I get this issue if I run the app using npx react-native run-ios, but its working fine if I run it from xcode

Fixed by replacing use_frameworks! with use_modular_headers! as followed by the docs even after being on 2.0.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mtt87 picture mtt87  路  28Comments

bithavoc picture bithavoc  路  22Comments

rohitgoyal picture rohitgoyal  路  20Comments

al-shivani picture al-shivani  路  25Comments

MugeshM picture MugeshM  路  18Comments