-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Add react-native setup-ios-permissions command #750
Conversation
Fascinating!! Very nice (as probably the creator of all the motivation for use_frameworks adoption in react-native 😅 ) |
I wonder about the name in package.json. |
@thymikee Good though! I updated the config key. |
35a61ff
to
ffebb54
Compare
* Add setup-ios-permissions command * Improve wording * Update description * Remove warning emoji * Update config key * Add support for .mm files (new architecture) * Remove mention of the workaround * Update documentation * Remove cache mention * Bump version number
@zoontek I appreciate the library and all the work you put in 🙏 just struggling a little to see how this makes it easier or more performant. Sometimes you just want to run For some projects im working on, they use expo, so this is a very common scenario where pods aren't needed when running Any way to have a solution where the pods are nicely structured but without the need for an setup script? (cc @mikehardy ;) ) |
@helenaford You actually don't have to run You can remove the |
@zoontek yeah sorry, that's what i meant, every time the node modules are removed, you have to run the setup script right? So for CI, we need the postinstall step? |
also, for local development, i'd say it's not great to have that manual step. I can see how that can easily get missed out each time the node modules are cleared |
@helenaford Yes. The CLI modify the podspec source paths, then you run the pod install. Not ideal, but unfortunately the best compromise we found yet 😕 |
@zoontek like i said above, i really appreciate how hard this is to do and what the intention is to try and make it as easy as possible, but in my opinion, the other way was better because you just configured it once per permission module. Rather than everytime the node modules are cleared. is there a way to have two methods to setup the library? |
@helenaford The other way is still possible (the podspecs per handler are still there), but will probably be removed in next major version as it creates way too much issues with Xcode caching. Maybe we could add a similar command for the Pod file? Something like |
@zoontek thank you that would be perfect if we could put something in the Podfile. thanks for looking into this! 😎 |
@helenaford Could you try it? I released a new version, yarn add react-native-permissions@next Then update your require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
+ require_relative '../node_modules/react-native-permissions/scripts/permissions_setup'
platform :ios, min_ios_version_supported
prepare_react_native_project!
+ prepare_react_native_permissions! And run PS: Don't forget to remove the If you are curious, this is the script: https://github.com/zoontek/react-native-permissions/blob/add-ruby-setup-script/scripts/permissions_setup.rb Basically a conversion of the react native CLI plugin to ruby. Thanks again for the insight! I'm not sure about the wording (the script file + function name) tho, it is subject to change before a release. Does it sounds good for you? @mikehardy @thymikee, do you have an opinion / some ideas for that? Note that putting everything in the require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
+ require_relative '../node_modules/react-native-permissions/scripts/permissions_setup'
platform :ios, min_ios_version_supported
prepare_react_native_project!
+ setup_permissions([
+ 'Camera',
+ 'LocationWhenInUse',
+ 'Microphone'
+ ]) |
I added a commit with it (could be rolled back): 51d97fa. This looks neat, if you ask me 😄. And as the user will have to update his EDIT: I published it as |
Hi folks 👋
Let's face it: the current iOS permission handlers setup is not that great. Having to deal with the
Podfile
file is a chore and not well understood by "non-native" developers.This pull request adds a new system based on a new
react-native
CLI command:setup-ios-permissions
. To use it, it's fairly easy!1️⃣ First declare the used iOS permissions in your
reactNativePermissionsIOS
config (the command usescosmiconfig
, so we can put that in our projectpackage.json
if we want):2️⃣ Then run the CLI command:
3️⃣ Don't forget to reinstall Pods:
4️⃣ And…it's done ✨
P.-S. Note that you can use a
postinstall
script to simplify this:P.-S. (2) Did I mention that this approach fixes the issue with
use_frameworks!
that need this ugly workaround? 👀 (As permissions handlers will now be parts of theRNPermissions
pod directly):