Enhanced iOS test app setup with better prerequisite handling: Requirements Checker: - Created check-requirements.sh script - Verifies all prerequisites (macOS, Xcode, Ruby, CocoaPods, Node.js) - Checks Ruby version (requires 3.1+) - Detects CocoaPods in multiple locations (PATH, rbenv, gem bin) - Validates UTF-8 encoding - Provides installation instructions for missing items Build Script Improvements: - Enhanced CocoaPods detection (checks PATH, rbenv, gem bin) - Better error messages with installation options - Automatic LANG=en_US.UTF-8 export - Uses detected pod command location Documentation Updates: - Expanded prerequisites section with versions - Added rbenv recommendation - Added quick requirements check step - Clearer installation instructions Fixes: - Handles rbenv-based CocoaPods installation - Works with system Ruby, rbenv, or Homebrew - Provides helpful error messages Result: Developers can easily verify and install all requirements
170 lines
4.4 KiB
Bash
Executable File
170 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
||
# iOS Test App Requirements Checker
|
||
# Verifies all prerequisites are installed and configured
|
||
|
||
set -e
|
||
|
||
# Colors
|
||
RED='\033[0;31m'
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
NC='\033[0m'
|
||
|
||
check_pass() {
|
||
echo -e "${GREEN}✓${NC} $1"
|
||
}
|
||
|
||
check_fail() {
|
||
echo -e "${RED}✗${NC} $1"
|
||
}
|
||
|
||
check_warn() {
|
||
echo -e "${YELLOW}⚠${NC} $1"
|
||
}
|
||
|
||
check_info() {
|
||
echo -e "${BLUE}ℹ${NC} $1"
|
||
}
|
||
|
||
echo "Checking iOS Test App Requirements..."
|
||
echo ""
|
||
|
||
# Check macOS
|
||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||
check_fail "macOS required (current: $OSTYPE)"
|
||
exit 1
|
||
else
|
||
check_pass "macOS detected"
|
||
fi
|
||
|
||
# Check Xcode
|
||
if ! command -v xcodebuild &> /dev/null; then
|
||
check_fail "Xcode command line tools not found"
|
||
echo " Install with: xcode-select --install"
|
||
exit 1
|
||
else
|
||
XCODE_VERSION=$(xcodebuild -version 2>&1 | head -1)
|
||
check_pass "Xcode found: $XCODE_VERSION"
|
||
fi
|
||
|
||
# Check Ruby
|
||
RUBY_VERSION=$(ruby --version 2>&1 | awk '{print $2}' || echo "not found")
|
||
if [ "$RUBY_VERSION" = "not found" ]; then
|
||
check_fail "Ruby not found"
|
||
echo " Install with: brew install ruby"
|
||
exit 1
|
||
else
|
||
# Check Ruby version
|
||
RUBY_MAJOR=$(echo "$RUBY_VERSION" | cut -d. -f1)
|
||
RUBY_MINOR=$(echo "$RUBY_VERSION" | cut -d. -f2)
|
||
if [ "$RUBY_MAJOR" -lt 3 ] || ([ "$RUBY_MAJOR" -eq 3 ] && [ "$RUBY_MINOR" -lt 1 ]); then
|
||
check_warn "Ruby version $RUBY_VERSION is too old (requires 3.1+)"
|
||
echo " Recommended: Use rbenv to install Ruby 3.1+"
|
||
echo " rbenv install 3.1.0"
|
||
echo " rbenv global 3.1.0"
|
||
else
|
||
check_pass "Ruby version: $RUBY_VERSION"
|
||
fi
|
||
fi
|
||
|
||
# Check rbenv (optional but recommended)
|
||
if command -v rbenv &> /dev/null; then
|
||
RBENV_VERSION=$(rbenv version-name 2>/dev/null || echo "not set")
|
||
check_pass "rbenv found (current: $RBENV_VERSION)"
|
||
else
|
||
check_info "rbenv not found (optional, but recommended for Ruby version management)"
|
||
fi
|
||
|
||
# Check CocoaPods
|
||
POD_CMD=""
|
||
POD_VERSION=""
|
||
if command -v pod &> /dev/null; then
|
||
POD_CMD="pod"
|
||
POD_VERSION=$(pod --version 2>/dev/null || echo "unknown")
|
||
check_pass "CocoaPods found: $POD_VERSION"
|
||
elif [ -f ~/.rbenv/shims/pod ]; then
|
||
POD_CMD="~/.rbenv/shims/pod"
|
||
POD_VERSION=$($POD_CMD --version 2>/dev/null || echo "unknown")
|
||
check_pass "CocoaPods found via rbenv: $POD_VERSION"
|
||
check_info " Using: $POD_CMD"
|
||
elif [ -f ~/.gem/bin/pod ]; then
|
||
POD_CMD="~/.gem/bin/pod"
|
||
POD_VERSION=$($POD_CMD --version 2>/dev/null || echo "unknown")
|
||
check_pass "CocoaPods found: $POD_VERSION"
|
||
check_info " Using: $POD_CMD"
|
||
else
|
||
check_fail "CocoaPods not found"
|
||
echo ""
|
||
echo " Installation options:"
|
||
echo " 1. With rbenv (recommended):"
|
||
echo " rbenv install 3.1.0"
|
||
echo " rbenv global 3.1.0"
|
||
echo " gem install cocoapods"
|
||
echo ""
|
||
echo " 2. With system Ruby (if Ruby 3.1+):"
|
||
echo " gem install cocoapods"
|
||
echo ""
|
||
echo " 3. With Homebrew:"
|
||
echo " brew install cocoapods"
|
||
exit 1
|
||
fi
|
||
|
||
# Check Node.js
|
||
if ! command -v node &> /dev/null; then
|
||
check_fail "Node.js not found"
|
||
echo " Install with: brew install node"
|
||
exit 1
|
||
else
|
||
NODE_VERSION=$(node --version)
|
||
check_pass "Node.js found: $NODE_VERSION"
|
||
fi
|
||
|
||
# Check npm
|
||
if ! command -v npm &> /dev/null; then
|
||
check_fail "npm not found"
|
||
exit 1
|
||
else
|
||
NPM_VERSION=$(npm --version)
|
||
check_pass "npm found: $NPM_VERSION"
|
||
fi
|
||
|
||
# Check Capacitor CLI
|
||
if ! command -v npx &> /dev/null; then
|
||
check_warn "npx not found (needed for Capacitor CLI)"
|
||
else
|
||
check_pass "npx found"
|
||
fi
|
||
|
||
# Check encoding
|
||
if [ -z "$LANG" ] || [[ ! "$LANG" =~ UTF-8 ]]; then
|
||
check_warn "LANG not set to UTF-8 (CocoaPods requires this)"
|
||
echo " Add to ~/.zshrc or ~/.bash_profile:"
|
||
echo " export LANG=en_US.UTF-8"
|
||
else
|
||
check_pass "LANG set to UTF-8: $LANG"
|
||
fi
|
||
|
||
# Check iOS Simulator
|
||
if command -v xcrun &> /dev/null; then
|
||
SIMULATORS=$(xcrun simctl list devices available 2>/dev/null | grep -i "iphone" | wc -l | tr -d ' ')
|
||
if [ "$SIMULATORS" -gt 0 ]; then
|
||
check_pass "iOS Simulators available: $SIMULATORS devices"
|
||
else
|
||
check_warn "No iOS simulators found"
|
||
echo " Install via Xcode: Xcode > Settings > Platforms"
|
||
fi
|
||
else
|
||
check_warn "xcrun not found"
|
||
fi
|
||
|
||
echo ""
|
||
echo -e "${GREEN}All requirements met!${NC}"
|
||
echo ""
|
||
echo "Next steps:"
|
||
echo " 1. cd test-apps/ios-test-app/App"
|
||
echo " 2. export LANG=en_US.UTF-8"
|
||
echo " 3. $POD_CMD install"
|
||
echo " 4. ../scripts/build-and-deploy.sh"
|
||
|