capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

feat(ios): Add Bundler support

Open saschpe opened this issue 2 years ago • 6 comments

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:

  1. Use Bundler to install RubyGems, including CocoaPods:
  2. If Bundler is outdated, update first by executing gem install bundler
  3. If RubyGems bundle is outdated, update first by executing bundle install
  4. Install CocoaPods and other gems by executing bundle exec pod install

Or, just like before, if:

  1. CocoaPods is available on PATH, execute pod install
  2. 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

Screenshot 2021-11-04 at 10 25 04

Case 4

Screenshot 2021-11-04 at 10 25 53

Case 1.2 and 1.3

Screenshot 2021-11-04 at 10 24 32

Case 1.1 and 1.3

Screenshot 2021-11-04 at 09 40 26

saschpe avatar Nov 04 '21 09:11 saschpe

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.

saschpe avatar Nov 04 '21 10:11 saschpe

I addressed the eslint issues but now need a workflow approval / re-run. TIA.

saschpe avatar Nov 10 '21 10:11 saschpe

Any remarks or comments?

saschpe avatar Jan 06 '22 12:01 saschpe

Once again, any news, decisions or comments on the matter?

saschpe avatar Mar 04 '22 14:03 saschpe

It would be nice if this could get some feedback, I just rebased onto most recent main changes.

saschpe avatar Jun 20 '22 07:06 saschpe

This is awesome 👍🏽 hope this can be merged as fast as possible.

fxsalazar avatar Sep 08 '22 14:09 fxsalazar

Hey, bump on this one, does the Ionic team see any value in bringing this into the project?

ffluk3 avatar Mar 22 '23 20:03 ffluk3

Let me take a look - I do know that bundler is popular along side cocoapods - I know I used it.

markemer avatar Mar 22 '23 20:03 markemer

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.

markemer avatar Mar 22 '23 20:03 markemer

And so I keep it current even though I already gave up hope that contributing to CapacitorJS is a thing at all.

saschpe avatar Mar 24 '23 07:03 saschpe

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

saschpe avatar Mar 24 '23 08:03 saschpe

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!)

markemer avatar Mar 24 '23 17:03 markemer

Let's see wait they say. I'd be happy to adjust the default project template afterwards.

saschpe avatar Mar 24 '23 18:03 saschpe

@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.

markemer avatar Mar 27 '23 18:03 markemer

I'm currently rebasing all my open pull requests...

saschpe avatar Mar 28 '23 07:03 saschpe

@saschpe @markemer Thank you so much for driving this forward by the way, appreciate it!

ffluk3 avatar Mar 28 '23 17:03 ffluk3

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.

markemer avatar Mar 30 '23 19:03 markemer

Please see my new comment:

https://github.com/ionic-team/capacitor/pull/5205#discussion_r1156179404

IT-MikeS avatar Apr 03 '23 16:04 IT-MikeS

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).

jskrepnek avatar Aug 11 '23 14:08 jskrepnek

@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.

jskrepnek avatar Aug 31 '23 18:08 jskrepnek

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 :-)

saschpe avatar Sep 13 '23 15:09 saschpe

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?

toxaq avatar Jan 12 '24 05:01 toxaq

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.

saschpe avatar Jan 12 '24 07:01 saschpe

You’re using bundled to install cocoa pods?

toxaq avatar Jan 12 '24 09:01 toxaq