Skip to content

Instantly share code, notes, and snippets.

@icanswiftabit
Last active April 6, 2024 14:54
Show Gist options
  • Save icanswiftabit/29f58bcd39c33ae005b1c8a67eeb437a to your computer and use it in GitHub Desktop.
Save icanswiftabit/29f58bcd39c33ae005b1c8a67eeb437a to your computer and use it in GitHub Desktop.
How to use bundler with iOS projects

#How to use Bundler with iOS projects

You probably stuck with situation when after finishing for example bundle install && bundle exec pod install Bundler couldn't access gems which he just download. Some of you may think "RVM is the answer!" and yes it is, but what if it is not?

##Don't use macOS's gems. Just DON'T.

  1. Establish that you will don't use macOS's gems and RVM.

  2. Go to your_app_dir

  3. Make sure you have Gemfile if not create one

    example Gemfile

    source 'https://rubygems.org'
    
    gem 'cocoapods'
    gem 'cocoapods-keys'
    gem 'redcarpet'
    gem 'rswift-ios'
    
  4. Now there are two scenarios:

    1. you have BUNDLE_PATH defined in your_app_dir/.bundle/config.

      example your_app_dir/.bundle/config

      ---
      BUNDLE_PATH: ".gems"
      BUNDLE_DISABLE_SHARED_GEMS: "true"
      

      So then you just type bundle install which will install gems from Gemfile to `your_app_dir/.gems'

    2. you don't have BUNDLE_PATH defined in your_app_dir/.bundle/config. This is most likely situation. Then instead of regular bundle install you have to type bundle install --path .gems. This will define BUNDLE_PATH in your_app_dir/.bundle/config and install missing gems.

  5. Now bundle will use .gems (or other dir) by default and will not interfere with system gems.

@alexspurlock25
Copy link

They recommend to use bundle config set path '.gems', following by bundle install. --path will be deprecated soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment