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

Add documentation on what the npx react-native setup-ios-permissions actually does #799

Closed
david-gettins opened this issue Aug 25, 2023 · 10 comments
Assignees
Labels
feature request New feature or request

Comments

@david-gettins
Copy link

david-gettins commented Aug 25, 2023

Why it is needed?

For projects that do not follow the standard React Native project structure e.g. nx/react-native it is not clear how to successfully set up for, and run the command.

I managed to figure this as described here where someone else had faced the same issue as me.

The command doesn't allow you to use arguments to specify the node_modules folder location.

Possible implementation

Include documentation for deeply nested ios folders.

OR

Add command arguments to the npx react-native setup-ios-permissions to allow consumers to specify folder locations.

Code sample

Unfortunately, I'm not sure how to make the command changes myself. But the documentation could read something like - maybe a little better than - how I described to someone on Stack Overflow.

@david-gettins david-gettins added the feature request New feature or request label Aug 25, 2023
@david-gettins
Copy link
Author

Might be worth noting that nx/react-native symlinks the node_modules folder from the repository root into an app folder that could be many levels deep e.g. apps/mobile or apps/consumer/mobile and so on.

The command seems to follow it okay when you run it from the app folder.

@zoontek
Copy link
Owner

zoontek commented Aug 25, 2023

@david-gettins I published a beta with an alternative already. Instead of relying on a react native CLI command, you can call a ruby function in your Podfile, it achieves the same (updating the podspec source_files to include additional handlers), but it's IMHO a better fit (as it makes sense to run pod install when you update your Podfile, less when you update a reactNativePermissionsIOS config). I think it should also fix your issue (as there's no need to locate a reactNativePermissionsIOS.json / package.json, it's a function call arg now):

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'
+ ])

More infos here: #750 (comment)

To try it:

yarn add react-native-permissions@next

@zoontek
Copy link
Owner

zoontek commented Aug 26, 2023

@david-gettins Published a new beta with an update to latest version of react native for the example app + documentation now mention hoisting support: https://github.com/zoontek/react-native-permissions/tree/add-ruby-setup-script#ios

If you confirm that it works correctly with nx, I will publish 3.9.0 🙂

@david-gettins
Copy link
Author

@david-gettins Published a new beta with an update to latest version of react native for the example app + documentation now mention hoisting support: https://github.com/zoontek/react-native-permissions/tree/add-ruby-setup-script#ios

If you confirm that it works correctly with nx, I will publish 3.9.0 🙂

Thank you. I'll give it a try on Monday and get back to you.

@zoontek
Copy link
Owner

zoontek commented Aug 31, 2023

@david-gettins Did you tried?

@david-gettins
Copy link
Author

@david-gettins Did you tried?

Hi, sorry I had a busy few days. I'm on it this evening, though.

@david-gettins
Copy link
Author

david-gettins commented Sep 1, 2023

Given this a try and all seems to work well. Thank you for looking into this. I agree that this feels like a better way to do this as you mentioned in an earlier comment. I have added a pod install step to my npm prepare script to ensure this is set up correctly on new repo clones and node_modules changes.

I have added a comment to an answer I provided on StackOverflow to someone with a similar issue pointing to this conversation.

@zoontek will you be putting this in the next stable release and updating the docs for it?

@zoontek
Copy link
Owner

zoontek commented Sep 1, 2023

@david-gettins Yes, it will be in the next release (with a solution for #710 too)

@david-gettins
Copy link
Author

Excellent, thank you for making this change! I'll close the issue.

@zoontek
Copy link
Owner

zoontek commented Sep 1, 2023

It's published: https://github.com/zoontek/react-native-permissions/releases/tag/3.9.0

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

No branches or pull requests

2 participants