Skip to content

feat: iOS Bundler support #5177

@saschpe

Description

@saschpe

Feature Request

Description

The current implementation relies on the CocoaPods 'pod' binary to be installed as a system-wide Ruby gem. Similarly, all other gems needed during build (and thus specified in Podfile) to be available there too. Bundler provides a way to declare per-project RubyGems dependencies similar to how node_modules works. It is used by many iOS projects to isolate from the host OS (different developers using different CocoaPods versions). Sometimes, a specific CocoaPods version has to be pinned, i.e. when a newer version had a regression (happened more than once in the past).

Platform(s)

  • iOS

Preferred Solution

Thus, checkCocoaPods should run bundle first and see if

  1. Bundler is installed
    • Could be done with which bundler but the version has to match as well. Simply running bundle and checking for errors catches both cases.
  2. The project has a Gemfile

If so, invoke bundle exec pod install. Otherwise, continue as before by looking for CocoaPods binary installed elsewhere (e.g. system-wide or on a custom path).

Alternatives

Bundler is recommended by CocoaPods.org in such situations.

Additional Context

A typical Gemfile is situated at the repository root and might look like this:

source 'https://rubygems.org'

## iOS Development
# DEVELOPER: You now need to prepend calls to rubygems with "bundle exec "
# e.g. instead of calling "pod install" you now call "bundle exec pod install"
gem 'cocoapods', '1.11.2'
gem 'cocoapods-art', '1.1.0'  # Cocoapods Artifactory plugin used to access private Artifactory server
gem 'xcpretty', '0.3.0'       # For prettier `xcodebuild` invocations on the console

## Documentation
gem 'asciidoctor', '2.0.16'
gem 'asciidoctor-diagram', '2.2.1'

This project fetches iOS dependencies from a private Artifactory instance (NPM and CocoaPods mirror plus proprietary stuff). It's Podfile looks like this (stripped for brevity):

platform :ios, '12.0'
use_frameworks!

plugin 'cocoapods-art', :sources => [ 'cocoapods.github.com.proxy', ]

def capacitor_pods
  pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
  pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/iOS'
  ....

Without Bundler support, every developer (and the CI scripting) has to install plenty of gems with a matching version. That would have to be documented in the README.md. By using Bundler, this is simplified. The iOS project would be bootstrapped like this:

gem install bundler
bundle exec pod install
xcodebuild ...

By the way, Bundler puts all it's dependencies in a folder called .bundler next to the Gemfile. This is perfect for caching during subsequent CI runs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions