react-native-community / discussions-and-proposals

Discussions and proposal related to the main React Native project
https://facebook.github.io/react-native/
1.66k stars 125 forks source link

Is there a reason to keep Gemfile in root folder ? #551

Open kkaplinski opened 1 year ago

kkaplinski commented 1 year ago

Introduction

Keeping Gemfile inside ios folder.

Details

Recently I implemented fastlane into my React Native app. To keep everything clean I created separate fastlane folder structure for ios and android with one Gemfile inside each one. Then I was thinking what should I do with my Gemfile in root ? Should I move everything to ios folder and add fastlane and cocoapods dependencies into one Gemfile? For sure I want to keep my fastlane separated for each platform.

Discussion points

Is there a reason to keep Gemfile in root folder ?

liamjones commented 1 year ago

Don't know if it works for you but we just import the fastlane one into the root one dynamically via eval_gemfile:

source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.5'

gem 'cocoapods', '~> 1.11', '>= 1.11.2'

eval_gemfile('packages/apps/_common/fastlane/Pluginfile')

One potential annoyance you might hit is if fastlane and the root both want the same gem you'll get warnings about repeat entries.

radko93 commented 1 year ago

What's the benefit of keeping separate installations of fastlane? You can have multiple lanes in Fastlane that run different things

kkaplinski commented 1 year ago

@radko93 fastlane init triggered in ios and android directory behave differently and generate different files for both platforms. If we try to run fastlane init in root folder we finished with error and suggestion to move into right directory. Ofcourse I can manually set up everything in root directory, but fastlane init provides intuitive interface for that and thats why a lot of people use it separately in android and ios directory. In fact in the fastlane docs we can find links to react native tutorials where this method is suggested.