Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): Add Bundler support #5205

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

saschpe
Copy link
Contributor

@saschpe saschpe commented Nov 4, 2021

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
Copy link
Contributor Author

saschpe commented Nov 4, 2021

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 saschpe force-pushed the ios-bundler-support branch 3 times, most recently from 9471caf to 1a600e1 Compare November 10, 2021 10:28
@saschpe
Copy link
Contributor Author

saschpe commented Nov 10, 2021

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

@saschpe saschpe force-pushed the ios-bundler-support branch 2 times, most recently from fdc46a3 to 5b3f441 Compare November 19, 2021 09:47
@saschpe saschpe force-pushed the ios-bundler-support branch from 5b3f441 to c9a3c3c Compare December 7, 2021 08:08
@saschpe saschpe force-pushed the ios-bundler-support branch from c9a3c3c to b7ac582 Compare December 14, 2021 11:21
@saschpe
Copy link
Contributor Author

saschpe commented Jan 6, 2022

Any remarks or comments?

@saschpe saschpe force-pushed the ios-bundler-support branch from b7ac582 to 4dae0fe Compare January 6, 2022 13:02
@saschpe
Copy link
Contributor Author

saschpe commented Mar 4, 2022

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

@saschpe
Copy link
Contributor Author

saschpe commented Jun 20, 2022

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

@fxsalazar
Copy link

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

@saschpe saschpe force-pushed the ios-bundler-support branch from 4dae0fe to 2184698 Compare March 13, 2023 12:57
@ffluk3
Copy link

ffluk3 commented Mar 22, 2023

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

@markemer markemer self-assigned this Mar 22, 2023
@markemer
Copy link
Member

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

@markemer
Copy link
Member

markemer commented Mar 22, 2023

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.

@saschpe saschpe force-pushed the ios-bundler-support branch from 2184698 to 3fbb292 Compare March 24, 2023 07:55
@saschpe
Copy link
Contributor Author

saschpe commented Mar 24, 2023

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

@saschpe
Copy link
Contributor Author

saschpe commented Mar 24, 2023

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

@markemer
Copy link
Member

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

cli/src/ios/common.ts Outdated Show resolved Hide resolved
Copy link
Member

@markemer markemer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, only thing we might want to pull is the CTA about installing Bundler - but I'll have to ask the team.

@saschpe
Copy link
Contributor Author

saschpe commented Mar 24, 2023

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

@markemer
Copy link
Member

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

@saschpe
Copy link
Contributor Author

saschpe commented Mar 28, 2023

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

@saschpe saschpe force-pushed the ios-bundler-support branch from 3fbb292 to 69d109f Compare March 28, 2023 07:07
@ffluk3
Copy link

ffluk3 commented Mar 28, 2023

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

@markemer
Copy link
Member

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.

@IT-MikeS
Copy link
Contributor

IT-MikeS commented Apr 3, 2023

Please see my new comment:

#5205 (comment)

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:
   1. If Bundler is outdated, update first by executing
      `gem install bundler`
   2. If RubyGems bundle is outdated, update first by executing
      `bundle install`
   3. Install CocoaPods and other gems by executing
      `bundle exec pod install`

Or, just like before, if:

 4. CocoaPods is available on PATH, execute `pod install`
 5. Neither global CocoaPods nor Gemfile are found
    Skip CocoaPods install entirely

Implements ionic-team#5177
@saschpe saschpe force-pushed the ios-bundler-support branch from 19dfb8f to 08b2666 Compare April 4, 2023 06:17
@markemer markemer merged commit f21c6d0 into ionic-team:main Apr 4, 2023
@saschpe saschpe deleted the ios-bundler-support branch April 5, 2023 10:49
markemer pushed a commit that referenced this pull request Apr 17, 2023
@jskrepnek
Copy link

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
Copy link

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

@saschpe
Copy link
Contributor Author

saschpe commented Sep 13, 2023

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

@toxaq
Copy link

toxaq commented Jan 12, 2024

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?

@saschpe
Copy link
Contributor Author

saschpe commented Jan 12, 2024

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.

@toxaq
Copy link

toxaq commented Jan 12, 2024

You’re using bundled to install cocoa pods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants