capacitor
capacitor copied to clipboard
feat(ios): Add Bundler support
Bundler isolates RubGems dependencies from the host operating system and creates a consistent environment. Gem dependencies can be pinned to exact versions by using a Gemfile
. CocoaPods is modeled after Bundler.
This ensures all developers and CI machines use the same CocoaPods version. It's also conveniently used to install CocoaPods plugins, e.g. cocoapods-art
, or additional iOS development tools, such as xcpretty
.
Multiple cases are now handled correctly. If a Gemfile
is found:
- At the Git repository root, in case of a multi-app project
- At or below the app directory, in case of a single-app project
Then:
- Use Bundler to install RubyGems, including CocoaPods:
- If Bundler is outdated, update first by executing
gem install bundler
- If RubyGems bundle is outdated, update first by executing
bundle install
- Install CocoaPods and other gems by executing
bundle exec pod install
Or, just like before, if:
- CocoaPods is available on PATH, execute
pod install
- Neither global CocoaPods nor Gemfile are found Skip CocoaPods install entirely
Implements #5177
Remarks
The following screenshots demonstrate the CLI output and actions that now occur (in reverse order but with increasing coolness):
Case 5

Case 4

Case 1.2 and 1.3

Case 1.1 and 1.3

I didn't dare to touch the iOS project template just yet. Once this change is accepted, it might make sense to do that as well to better isolate iOS builds from the host machine used.
I addressed the eslint issues but now need a workflow approval / re-run. TIA.
Any remarks or comments?
Once again, any news, decisions or comments on the matter?
It would be nice if this could get some feedback, I just rebased onto most recent main
changes.
This is awesome 👍🏽 hope this can be merged as fast as possible.
Hey, bump on this one, does the Ionic team see any value in bringing this into the project?
Let me take a look - I do know that bundler is popular along side cocoapods - I know I used it.
Hey, please update this with the latest from main as well. As best as you can anyway - I know we're coming fast and furious with commits - but I don't like to update other peoples forks unless I'm about to merge any minute.
And so I keep it current even though I already gave up hope that contributing to CapacitorJS is a thing at all.
Now that some attention is on this one, may I shamelessly point you guys to https://github.com/ionic-team/capacitor/pull/5195 as well? It's equally important when trying to use latest Android SDK versions
Now that some attention is on this one, may I shamelessly point you guys to #5195 as well? It's equally important when trying to use latest Android SDK versions
Sure - but I'm more iOS leaning so I'll have to pull in some help - we are bumping the target to 33 in Cap5 (now in alpha!)
Let's see wait they say. I'd be happy to adjust the default project template afterwards.
@saschpe You have a conflict here since I removed the deletion of the Podfile.lock
as that was done a while back to work around a bug. Should be an easy fix. I can even fix it if you like.
I'm currently rebasing all my open pull requests...
@saschpe @markemer Thank you so much for driving this forward by the way, appreciate it!
I haven't forgotten about this - I'm going to see if we can get this into the 5-rc or if not that, the next point release.
Please see my new comment:
https://github.com/ionic-team/capacitor/pull/5205#discussion_r1156179404
Is there a way to tell Capacitor 5 to ignore or opt-out of the bundler integration? We have a Gemfile for automation purposes, but don't want it used for development at all (at least not yet).
@markemer @IT-MikeS
I'm trying to figure out if I'm seeing an issue with this change.
Running capacitor sync ios
I see the logs:
[capacitor] [info] Using Gemfile: RubyGems bundle installed
...
[capacitor] [warn] Skipping pod install because CocoaPods is not installed
[capacitor] ✔ Updating iOS native dependencies with pod install in 1.27s
The update code appears to confusingly think that it's not using bundler, despite the earlier message.
Tracing down further, I think the issue is that it's using single quotes in the test to determine if Cocoapods is referenced in the Gemfile, but it's valid to use double quotes here and our file does.
Double quoted strings allow interpolation which is a bit unusual in the case of gem names. They're rather fixed. Then again, Ruby has another string literal variant, percent strings like %q{hello}
.
While it's straightforward to expand the test to check for double-quoted strings, I am not sure we'd want to support percent strings as well. I can already see someone who is using regex strings :-)
Yes, how do I opt out of this? We have a Gemfile for fastlane but this is trying to install bundler on xcode cloud build?
Yes, how do I opt out of this? We have a Gemfile for fastlane but this is trying to install bundler on xcode cloud build?
You're using Fastlane and Xcode Cloud? There aren't many reasons left these days to still use Fastlane. Almost everything can be achieved with xcodebuild
. But if you want to avoid Bundler, you could simply rm Gemfile
in the Xcode Cloud build phase.
You’re using bundled to install cocoa pods?