github zoontek/react-native-permissions 3.7.0

latest releases: 4.1.5, 4.1.4, 4.1.3...
16 months ago

The new react-native setup-ios-permissions command

This release come with a new permission handler linkage system for iOS: the react-native setup-ios-permissions command. No need to update your Podfile file anymore, everything is now handled by your package.json.

The benefits from this solution are many, but the main ones are that it should fixes Xcode cache issues and the well-known use_frameworks issue (no more workaround needed! 🎉)

📌 The "old way" will continue to work until the next major update, but it has been removed from the latest documentation since this is not the preferred way anymore.

To migrate, remove all the extra code from your Podfile (and the use_frameworks workaround if you used it):

- # Convert all permission pods into static libraries
- pre_install do |installer|
-   Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
-   installer.pod_targets.each do |pod|
-     if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
-       def pod.build_type;
-         # Uncomment the line corresponding to your CocoaPods version
-         # Pod::BuildType.static_library # >= 1.9
-         # Pod::Target::BuildType.static_library # < 1.9
-       end
-     end
-   end
- end

target 'MyAwesomeApp' do

    # …

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

-  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
-  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
-  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
-  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"

Add a reactNativePermissionsIOS config in your package.json:

{
  "reactNativePermissionsIOS": [
    "Camera",
    "LocationWhenInUse",
    "Notifications",
    "SpeechRecognition"
  ]
}

Then run react-native setup-ios-permissions and pod install. That's all! ✨


P.-S. As these commands must be run each tome each time you update this config, delete your node_modules directory or update this library, I highly recommand to use a postinstall script to simplify this:

{
  "reactNativePermissionsIOS": [
    "Camera",
    "LocationWhenInUse",
    "Notifications",
    "SpeechRecognition"
  ],
  "devDependencies": {
    "pod-install": "0.1.38"
  },
  "scripts": {
    "postinstall": "react-native setup-ios-permissions && pod-install"
  }
}

Also in this release:

  • Update project dependencies to React Native 0.71 in order to prepare new architecture support.
  • Update the example app UI (with react-native-paper v5):

Don't miss a new react-native-permissions release

NewReleases is sending notifications on new releases.