Some projects may chose to not install pod globally, but locally via bundle. In this case, pod is normally not in the $PATH. However, it would be accessible via bundle exec pod.
Because cap expects pod to be accessible from the $PATH, any command using pod would fail with that setup.
Currently we work around this in our project by generating a binstub for pod (bundle binstubs cocoapods) and adding it to the $PATH using an .envrc file like this:
# Add the gem binstubs directory to `PATH`.
export PATH="$PWD/bin:$PATH"
macOS / iOS
Not entirely sure.
It would be nice, if the command for pod could be configured or alternatively the path to the bin could be configured explicitly. Both solutions could be supported simultaneously. I would not put this in the capacitor.config.json, but rather add a capacitor key to the package.json:
{
"capacitor": {
"pod": "bundle exec pod"
// or alternatively:
"pod": "./bin/pod"
}
}
Just curious, where is your Gemfile in your project?
We use a monorepo setup that looks like this: (irrelevant files & directories omitted)
.
โโโ .bundle
โ โโโ config
โโโ bin
| | # These binstubs were generated via
| | # `bundle binstubs cocoapods`
| | # and are checked into the repo.
โ โโโ pod
โ โโโ sandbox-pod
โโโ gems
โ โโโ ruby/
| # Contains the `Gemfile` dependencies. Created by
| # `bundle install`
| # Not checked into the repository.
| # See further down this comment for the contents.
โโโ packages
โ โโโ capacitor-app/
โ ...
โ โโโ plugin.auth/
โ โโโ plugin.pdf/
โ โโโ scripts/
โโโ .envrc
โโโ .gitignore
โโโ .ruby-version
โโโ Brewfile
โโโ Gemfile
โโโ Gemfile.lock
โโโ lerna.json
โโโ package.json
โโโ README.md
โโโ yarn.lock
For our tool chain version management we have (among others) these entries in our Brewfile:
brew "direnv"
brew "volta"
brew "rbenv"
brew "openjdk@11"
And this .envrc:
# Add the gem binstubs directory and the JDK@11 to the `PATH`.
export PATH="$(dirname "$0")/bin:$(brew --prefix openjdk@11)/bin:$PATH"
And this .bundle/config:
---
BUNDLE_PATH: "./gems"
BUNDLE_FROZEN: "true"
And here's the contents created by bundle install:
./gems/ruby/2.7.0
โโโ bin
โ โโโ bin-proxy
โ โโโ dotenv
โ โโโ fastlane
โ โโโ fuzzy_match
โ โโโ generate-api
โ โโโ httpclient
โ โโโ pod
โ โโโ rake
โ โโโ rougify
โ โโโ sandbox-pod
โ โโโ terminal-notifier
โ โโโ ww
โ โโโ xcodeproj
โ โโโ xcpretty
โ โโโ xcpretty-travis-formatter
โโโ build_info
โโโ cache
โ โโโ activesupport-4.2.11.3.gem
โ ...
โ โโโ xcpretty-travis-formatter-1.0.0.gem
โโโ doc
โโโ extensions
โ โโโ x86_64-darwin-19
โโโ gems
โ โโโ activesupport-4.2.11.3
โ ...
โ โโโ xcpretty-travis-formatter-1.0.0
โโโ specifications
โโโ activesupport-4.2.11.3.gemspec
...
โโโ xcpretty-travis-formatter-1.0.0.gemspec
Our Gemfile looks like this:
source "https://rubygems.org"
gem "fastlane"
gem "cocoapods"
# ...
fastlane_plugins_path = File.join(
File.dirname(__FILE__),
'packages',
'capacitor-app',
'ios',
'App',
'fastlane',
'Pluginfile'
)
eval_gemfile(fastlane_plugins_path) if File.exist?(fastlane_plugins_path)
And the Pluginfile:
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!
gem 'fastlane-plugin-sentry'
@buschtoens Take a look at https://github.com/ionic-team/capacitor/pull/3811--this should be the feature you're looking for (coming in Capacitor 3). For system/environment configuration, we would prefer to use environment variables rather than a file that gets checked into source control. This feature is most similar to the environment variable we added for configuring the path of Android Studio: https://github.com/ionic-team/capacitor/pull/3755
@dwieeb this is perfect! Thank you.
FWIW for anyone following along at home or future Googlers: direnv is a fantastic tool to automatically set env vars when entering a directory, e.g. your repo.
Forgot to mention, the environment variable will only work for file paths, e.g: export CAPACITOR_COCOAPODS_PATH="./bin/pod"
(You can't do CAPACITOR_COCOAPODS_PATH="bundle exec pod")
Thanks for mentioning. That'd be fine as well though. If users for some reason cannot use binstubs, they could create an executable (chmod +x) shell script instead:
#!/usr/bin/env sh
bundle exec pod $@
export CAPACITOR_COCOAPODS_PATH="./bin/custom-pod"
Most helpful comment
Thanks for mentioning. That'd be fine as well though. If users for some reason cannot use binstubs, they could create an executable (
chmod +x) shell script instead: