Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid RNPermission 'ios.permission.LOCATION_WHEN_IN_USE'. should be one of: ( ) #326

Closed
mtt87 opened this issue Sep 30, 2019 · 28 comments
Closed

Comments

@mtt87
Copy link

mtt87 commented Sep 30, 2019

Bug

Invalid RNPermission 'ios.permission.LOCATION_WHEN_IN_USE'. should be one of: (
)

Environment info

System:
    OS: macOS 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Memory: 161.37 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.9.0 - ~/.nvm/versions/node/v12.9.0/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v12.9.0/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v12.9.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: 25, 26, 27, 28
      Build Tools: 23.0.1, 26.0.1, 26.0.2, 27.0.0, 27.0.3, 28.0.3, 29.0.0
      System Images: android-28 | Google APIs Intel x86 Atom_64
  IDEs:
    Android Studio: 3.3 AI-182.5107.16.33.5314842
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.1 => 0.61.1 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Library version: 2.0.0

Steps To Reproduce

  1. Added to Podfile
permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse.podspec"
  1. pod install
  2. Added the permission message to info.plist
  3. Rebuild the app
const locationPermission = Platform.select({
  ios: PERMISSIONS.IOS.LOCATION_WHEN_IN_USE,
  android: PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION
});

const permission = await check(LOCATION_PERMISSION);
@zoontek
Copy link
Owner

zoontek commented Sep 30, 2019

Hi @mtt87 ! I created a small repo to reproduce the issue, and it does not happen: https://github.com/zoontek/react-native-permissions-issue-326
It's probably a missing step and we could improve the documentation!

I did:

$ npx react-native init HelloPermissions
$ cd HelloPermissions
$ yarn add react-native-permissions
# Edit the `Podfile`, run `pod install`
# Edit the JS
$ open ./ios/HelloPermissions.xcworkspace

And compile (NSLocationWhenInUseUsageDescription is already existing on new projects). Everything went well.

Can you check that you followed the same steps? Check that your project looks like this? (RNPermissions + Permission-LocationWhenInUse pods)

Screenshot 2019-09-30 at 16 28 58

@mtt87
Copy link
Author

mtt87 commented Sep 30, 2019

I tried again from scratch with

rm -rf node_modules
yarn
cd ios
pod update
pod install

and now it worked fine 🤔
I'm quite sure I did that this morning as well a few times....

Thanks for looking into it @zoontek really appreciate, I'm gonna close the issue then.

@mtt87 mtt87 closed this as completed Sep 30, 2019
@zoontek
Copy link
Owner

zoontek commented Sep 30, 2019

@mtt87 It might be Xcode build cache. A neat trick is Option ⌥ + Click on the Product Menu -> Clean Build Folder

Screenshot 2019-09-30 at 19 28 33

@mikehardy
Copy link

mikehardy commented Sep 30, 2019

Even that clean isn't good enough. I have been bitten by stale DerivedData state a few times as well. I only use the react-native-clean-project 'wipe iOS build' option now (and I've PRd to it a couple times, including to clean DerivedData). Good luck :-)

@Under-Warz
Copy link

Under-Warz commented Oct 1, 2019

hi,

Nothing works for me. I tried to clean up project, delete derived data, reinstall packages and pods, I've always got the error. Everything seems to be fine in my Xcode project architecture in Pods.

image

I'm using RN 0.61 with RN Permissions 2.0

@zoontek
Copy link
Owner

zoontek commented Oct 1, 2019

@Under-Warz Can you provides more details? Cocoapods version, Xcode version, iOS version?

@Under-Warz
Copy link

@zoontek of course.

System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 223.01 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.5.0 - ~/.nvm/versions/node/v12.5.0/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v12.5.0/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v12.5.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
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5791312
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.1 => 0.61.1 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Cocoapods : 1.7.5
Simulator iOS : 12.2

@kkusanagi
Copy link

Same error here on React native 0.60.5 and Cocoapods 1.7.5. Seems like the array for checking the permission is empty.

Error is around here.

RNPermissions.h

typedef NS_ENUM(NSInteger, RNPermission) {
  RNPermissionUnknown = 0,
#if __has_include("RNPermissionHandlerBluetoothPeripheral.h")
  RNPermissionBluetoothPeripheral,
#endif
#if __has_include("RNPermissionHandlerCalendars.h")
  RNPermissionCalendars,
#endif
#if __has_include("RNPermissionHandlerCamera.h")
  RNPermissionCamera,
#endif
#if __has_include("RNPermissionHandlerContacts.h")
  RNPermissionContacts,
#endif
#if __has_include("RNPermissionHandlerFaceID.h")
  RNPermissionFaceID,
#endif
#if __has_include("RNPermissionHandlerLocationAlways.h")
  RNPermissionLocationAlways,
#endif
#if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  RNPermissionLocationWhenInUse,
#endif
#if __has_include("RNPermissionHandlerMediaLibrary.h")
  RNPermissionMediaLibrary,
#endif
#if __has_include("RNPermissionHandlerMicrophone.h")
  RNPermissionMicrophone,
#endif
#if __has_include("RNPermissionHandlerMotion.h")
  RNPermissionMotion,
#endif
#if __has_include("RNPermissionHandlerPhotoLibrary.h")
  RNPermissionPhotoLibrary,
#endif
#if __has_include("RNPermissionHandlerReminders.h")
  RNPermissionReminders,
#endif
#if __has_include("RNPermissionHandlerSiri.h")
  RNPermissionSiri,
#endif
#if __has_include("RNPermissionHandlerSpeechRecognition.h")
  RNPermissionSpeechRecognition,
#endif
#if __has_include("RNPermissionHandlerStoreKit.h")
  RNPermissionStoreKit,
#endif
};

OR

RNPermissions.m

RCT_ENUM_CONVERTER(RNPermission, (@{
#if __has_include("RNPermissionHandlerBluetoothPeripheral.h")
  [RNPermissionHandlerBluetoothPeripheral handlerUniqueId]: @(RNPermissionBluetoothPeripheral),
#endif
#if __has_include("RNPermissionHandlerCalendars.h")
  [RNPermissionHandlerCalendars handlerUniqueId]: @(RNPermissionCalendars),
#endif
#if __has_include("RNPermissionHandlerCamera.h")
  [RNPermissionHandlerCamera handlerUniqueId]: @(RNPermissionCamera),
#endif
#if __has_include("RNPermissionHandlerContacts.h")
  [RNPermissionHandlerContacts handlerUniqueId]: @(RNPermissionContacts),
#endif
#if __has_include("RNPermissionHandlerFaceID.h")
  [RNPermissionHandlerFaceID handlerUniqueId]: @(RNPermissionFaceID),
#endif
#if __has_include("RNPermissionHandlerLocationAlways.h")
  [RNPermissionHandlerLocationAlways handlerUniqueId]: @(RNPermissionLocationAlways),
#endif
#if __has_include("RNPermissionHandlerLocationWhenInUse.h")
  [RNPermissionHandlerLocationWhenInUse handlerUniqueId]: @(RNPermissionLocationWhenInUse),
#endif
#if __has_include("RNPermissionHandlerMediaLibrary.h")
  [RNPermissionHandlerMediaLibrary handlerUniqueId]: @(RNPermissionMediaLibrary),
#endif
#if __has_include("RNPermissionHandlerMicrophone.h")
  [RNPermissionHandlerMicrophone handlerUniqueId]: @(RNPermissionMicrophone),
#endif
#if __has_include("RNPermissionHandlerMotion.h")
  [RNPermissionHandlerMotion handlerUniqueId]: @(RNPermissionMotion),
#endif
#if __has_include("RNPermissionHandlerPhotoLibrary.h")
  [RNPermissionHandlerPhotoLibrary handlerUniqueId]: @(RNPermissionPhotoLibrary),
#endif
#if __has_include("RNPermissionHandlerReminders.h")
  [RNPermissionHandlerReminders handlerUniqueId]: @(RNPermissionReminders),
#endif
#if __has_include("RNPermissionHandlerSiri.h")
  [RNPermissionHandlerSiri handlerUniqueId]: @(RNPermissionSiri),
#endif
#if __has_include("RNPermissionHandlerSpeechRecognition.h")
  [RNPermissionHandlerSpeechRecognition handlerUniqueId]: @(RNPermissionSpeechRecognition),
#endif
#if __has_include("RNPermissionHandlerStoreKit.h")
  [RNPermissionHandlerStoreKit handlerUniqueId]: @(RNPermissionStoreKit),
#endif
}), RNPermissionUnknown, integerValue);

@zoontek
Copy link
Owner

zoontek commented Oct 2, 2019

@Under-Warz @kkusanagi Could you check that CocoaPods is properly integrated in your project and add Headers search paths automatically?

Screenshot 2019-10-02 at 14 48 21

(This is what CocoaPods does normally by default)

Also, try:

$ pod deintegrate
$ rm -rf *.xcworkspace
$ pod install

And open the new xcworkspace file, compile.

@kkusanagi
Copy link

hahaha i fix it my self. Seems there is invalid data while creating a list.

I changed the code as below. And it is fixed.

RNPermissions.h

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
};

@Under-Warz
Copy link

Under-Warz commented Oct 2, 2019

@zoontek I can't find any headers about RNPermission and permissions itself (pod update && pod install has been made)

image

@zoontek
Copy link
Owner

zoontek commented Oct 2, 2019

@kkusanagi I will made a minor release tomorrow with the fix, thanks!

@Under-Warz Do you use use_frameworks! ? I think it's linked.

EDIT: It does not seems to solve all cases (use_frameworks! ones). Related issues: #331 facebook/react-native#26333

@timmywil
Copy link

timmywil commented Oct 7, 2019

This is still an issue when using use_frameworks!, correct? I've tried the solutions mentioned and still get this error. Also, facebook/react-native#26333 is fixed in 0.61.1 and #331 is not an issue for me. Is there perhaps a workaround, such as manual Framework Search Header path entries?

@zoontek
Copy link
Owner

zoontek commented Oct 8, 2019

@timmywil If none of the solutions worked for you, can you open a new issue with some infos on your setup (RN version, CocoaPods version, your Podfile?). It will be easier to help you 🙂

@fmorau
Copy link

fmorau commented Oct 11, 2019

@zoontek I have the same issue. RNPermissions does not see RNPermissionHandlerX.
Also, to check, I tried to import it manually RNPermissions, and I could not...
But I can do it from:
#import "PhotoLibrary/RNPermissionHandlerPhotoLibrary.m"
This is interesting

@fmorau
Copy link

fmorau commented Oct 11, 2019

I had to add "${PODS_CONFIGURATION_BUILD_DIR}/Permission-X" to RNPermissions "Framework Search Paths" to make it works :)
@Under-Warz thank you for your suggestion 👍

@fmorau
Copy link

fmorau commented Oct 11, 2019

@Under-Warz but in this way, I should always add it manually.
How can I achieve "automated" linking.
I'm playing with postinstall script in Podfile now.

@Under-Warz
Copy link

@chelovekdrakon I didn't suggest anything but you're welcome if it's helped you ^^

For now I'm stop using this lib for my dev but I'll back on it later.

@zoontek sry for the delay, yes I'm also using use_frameworks! with an iOS native project already developed

@kkusanagi
Copy link

I'm not sure this may be cause. Starting on react-native 0.61 above, the react native developer had removed the react.xproject (something) from the library. and this may cause a lot of trouble for other library that use this library. I'm meet this issue with realm. so i need to downgrade to 0.60.5 with fresh setup.

If you downgrade from 0.61, you need to add back the react.xproject back to ios library.

@erdong0604
Copy link

I tried again from scratch with

rm -rf node_modules
yarn
cd ios
pod update
pod install

and now it worked fine 🤔
I'm quite sure I did that this morning as well a few times....

Thanks for looking into it @zoontek really appreciate, I'm gonna close the issue then.

rm -rf node_modules
yarn
cd ios
pod update
pod install
react-native run-ios
I'm as good as you. I don't know how many times I repeat the operation。

@menesh2
Copy link

menesh2 commented Dec 4, 2019

this is happening to me as well,
seems like the permission handlers imports are not valid (for example if i try to import RNPermissionHandlerLocationWhenInUse.h, the xcode gives error message saying it does not finds the files), hence, the enum gets translated to an empty enum.
how can we fix that?

@kkusanagi
Copy link

@menesh2 what version you are using for react-native-permissions and React Native?
I'm using react-native-permissions:2.0.2 and react-native: 0.60.5

it work just fined.

@menesh2
Copy link

menesh2 commented Dec 5, 2019

@kkusanagi
React Native: 0.61.4,
react-native-permissions: 2.0.4

@ozgurchn
Copy link

ozgurchn commented Dec 6, 2019

I had the same issue but I realized that I forgot to add a permission handler in the Podfile ^^
Add one of the handlers you want to check then everything should work again.

pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways.podspec"
pod install

@menesh2
Copy link

menesh2 commented Dec 6, 2019

@ozgurchn i have those handlers in my podfile:

image

do you have another idea?

@thijs-qv
Copy link

I had to add "${PODS_CONFIGURATION_BUILD_DIR}/Permission-X" to RNPermissions "Framework Search Paths" to make it works :)
@Under-Warz thank you for your suggestion 👍

After adding the pods to the Podfile, this ended up fixing the issue for me. Thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests