javascriptreact-nativerubygemsgemfile

2 system have different ruby version in single React Native project, So how we can set it dynamically in GemFile


Questions: Two systems have different Ruby versions in a single React Native project. How can we set them dynamically in GemFile? One of your systems is using Ruby Version 2.7.5, and the other is 3.2.1.


Solution

  • Instead of using the different Ruby versions of different systems,

    like as One of your systems is using Ruby Version 2.7.5 and the other is 3.2.1

    So you can set it dynamically.

    GemFile

    source 'https://rubygems.org'
    
    # Check the Ruby version
    if RUBY_VERSION =~ /^2\.7/
        # Use gems for Ruby 2.7
        ruby '2.7.5'
      else
        # Use gems for other Ruby versions
        ruby '3.2.1'
      end
    
      gem 'cocoapods', '~> 1.11', '>= 1.11.2'
    

    or

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