Skip to content

Instantly share code, notes, and snippets.

@thibmaek
Created January 21, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thibmaek/87b217991c22536e2daa06e14959a685 to your computer and use it in GitHub Desktop.
Save thibmaek/87b217991c22536e2daa06e14959a685 to your computer and use it in GitHub Desktop.
Agnostic pod install! Source this to pod install wherever in your project
#!/usr/bin/env bash
function find_podfile_dir() {
podFile=$(find "$PWD" -type f -not -path "*/node_modules/*" -name "Podfile")
if [ -f "$podFile" ]; then
echo "${podFile//Podfile/}"
else
echo "Unable to find Podfile"
exit 1
fi
}
function install_bundler() {
echo "Installing from Podfile in dir $1 via bundler"
bundle exec pod install --project-directory="$1"
}
function install_pod_cli() {
echo "Installing from Podfile in dir $1 via Cocoapods CLI"
pod install --project-directory="$1"
}
function pod_install() {
podfileDir=$(find_podfile_dir)
if command -v bundler >/dev/null 2>&1; then
if find "$PWD" -type f -not -path "*/node_modules/*" -name "Gemfile" >/dev/null 2>&1; then
install_bundler "$podfileDir"
else
install_pod_cli "$podfileDir"
fi
else
install_pod_cli "$podfileDir"
fi
}
pod_install "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment