Created
January 21, 2021 17:04
-
-
Save thibmaek/87b217991c22536e2daa06e14959a685 to your computer and use it in GitHub Desktop.
Agnostic pod install! Source this to pod install wherever in your project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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