feat(ios): add comprehensive requirements checking and improved CocoaPods detection
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
This commit is contained in:
@@ -10,11 +10,35 @@ This guide explains how to set up the standalone iOS test app for the DailyNotif
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- macOS with Xcode 15.0 or later
|
||||
- CocoaPods installed (`gem install cocoapods` or via rbenv)
|
||||
- Node.js 18+ (for Capacitor CLI)
|
||||
- iOS 13.0+ deployment target
|
||||
- Ruby 3.1+ (for CocoaPods)
|
||||
### Required
|
||||
|
||||
- **macOS** (iOS development requires macOS)
|
||||
- **Xcode 15.0+** with Command Line Tools
|
||||
```bash
|
||||
xcode-select --install # If not installed
|
||||
```
|
||||
- **Ruby 3.1+** (required for CocoaPods)
|
||||
- Check version: `ruby --version`
|
||||
- If using system Ruby and version < 3.1, use rbenv (recommended)
|
||||
- **CocoaPods** (dependency manager)
|
||||
- **Node.js 18+** and npm (for Capacitor CLI)
|
||||
- **UTF-8 encoding** (required for CocoaPods)
|
||||
|
||||
### Recommended
|
||||
|
||||
- **rbenv** (Ruby version manager) - Makes Ruby/CocoaPods setup easier
|
||||
- **Homebrew** (package manager) - Simplifies installation
|
||||
|
||||
### Quick Requirements Check
|
||||
|
||||
Run the requirements checker:
|
||||
|
||||
```bash
|
||||
cd test-apps/ios-test-app
|
||||
./scripts/check-requirements.sh
|
||||
```
|
||||
|
||||
This will verify all prerequisites and provide installation instructions for missing items.
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -67,13 +91,29 @@ end
|
||||
|
||||
### Step 2: Install CocoaPods Dependencies
|
||||
|
||||
**First, check requirements:**
|
||||
```bash
|
||||
cd test-apps/ios-test-app
|
||||
./scripts/check-requirements.sh
|
||||
```
|
||||
|
||||
**Then install CocoaPods dependencies:**
|
||||
```bash
|
||||
cd test-apps/ios-test-app/App
|
||||
export LANG=en_US.UTF-8 # Required for CocoaPods
|
||||
~/.rbenv/shims/pod install # or: pod install if in PATH
|
||||
|
||||
# Use the pod command found by check-requirements.sh, or:
|
||||
# If using rbenv:
|
||||
~/.rbenv/shims/pod install
|
||||
|
||||
# If using system Ruby:
|
||||
pod install
|
||||
|
||||
# If using Homebrew:
|
||||
pod install
|
||||
```
|
||||
|
||||
**Note**: If `pod` command is not found, use the full path: `~/.rbenv/shims/pod` or ensure CocoaPods is in your PATH.
|
||||
**Note**: The build script will automatically detect and use the correct `pod` command location.
|
||||
|
||||
### Step 3: Capacitor Configuration
|
||||
|
||||
@@ -259,7 +299,7 @@ iOS handles background execution differently than Android:
|
||||
**No signing required** - The build scripts automatically disable signing for simulator builds:
|
||||
|
||||
```bash
|
||||
CODE_SIGN_IDENTITY=""
|
||||
CODE_SIGN_IDENTITY=''
|
||||
CODE_SIGNING_REQUIRED=NO
|
||||
CODE_SIGNING_ALLOWED=NO
|
||||
```
|
||||
|
||||
@@ -48,12 +48,35 @@ if ! command -v xcodebuild &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v pod &> /dev/null; then
|
||||
log_error "CocoaPods not found. Install with:"
|
||||
log_info " gem install cocoapods"
|
||||
# Check for CocoaPods (try multiple locations)
|
||||
POD_CMD=""
|
||||
if command -v pod &> /dev/null; then
|
||||
POD_CMD="pod"
|
||||
elif [ -f ~/.rbenv/shims/pod ]; then
|
||||
POD_CMD="~/.rbenv/shims/pod"
|
||||
elif [ -f ~/.gem/bin/pod ]; then
|
||||
POD_CMD="~/.gem/bin/pod"
|
||||
else
|
||||
log_error "CocoaPods not found."
|
||||
log_info ""
|
||||
log_info "Installation options:"
|
||||
log_info " 1. Using rbenv (recommended):"
|
||||
log_info " rbenv install 3.1.0"
|
||||
log_info " rbenv global 3.1.0"
|
||||
log_info " gem install cocoapods"
|
||||
log_info ""
|
||||
log_info " 2. Using system Ruby (requires Ruby 3.1+):"
|
||||
log_info " gem install cocoapods"
|
||||
log_info ""
|
||||
log_info " 3. Using Homebrew:"
|
||||
log_info " brew install cocoapods"
|
||||
log_info ""
|
||||
log_info "Current Ruby version: $(ruby --version 2>/dev/null || echo 'not found')"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Using CocoaPods: $POD_CMD"
|
||||
|
||||
# Get simulator device (default to iPhone 15 Pro)
|
||||
SIMULATOR_DEVICE="${1:-iPhone 15 Pro}"
|
||||
log_info "Using simulator: $SIMULATOR_DEVICE"
|
||||
@@ -76,8 +99,16 @@ fi
|
||||
# Install CocoaPods dependencies
|
||||
log_step "Installing CocoaPods dependencies..."
|
||||
cd App
|
||||
export LANG=en_US.UTF-8 # Required for CocoaPods
|
||||
|
||||
if [ ! -f "Podfile.lock" ] || [ "Podfile" -nt "Podfile.lock" ]; then
|
||||
pod install
|
||||
if eval "$POD_CMD install"; then
|
||||
log_info "✓ CocoaPods dependencies installed"
|
||||
else
|
||||
log_error "Failed to install CocoaPods dependencies"
|
||||
log_info "Try running manually: export LANG=en_US.UTF-8 && $POD_CMD install"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
log_info "CocoaPods dependencies up to date"
|
||||
fi
|
||||
@@ -95,7 +126,7 @@ xcodebuild -workspace "$WORKSPACE" \
|
||||
-sdk "$SDK" \
|
||||
-destination "platform=iOS Simulator,name=$SIMULATOR_DEVICE" \
|
||||
-derivedDataPath build/derivedData \
|
||||
CODE_SIGN_IDENTITY="" \
|
||||
CODE_SIGN_IDENTITY='' \
|
||||
CODE_SIGNING_REQUIRED=NO \
|
||||
CODE_SIGNING_ALLOWED=NO \
|
||||
clean build
|
||||
|
||||
169
test-apps/ios-test-app/scripts/check-requirements.sh
Executable file
169
test-apps/ios-test-app/scripts/check-requirements.sh
Executable file
@@ -0,0 +1,169 @@
|
||||
#!/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"
|
||||
|
||||
Reference in New Issue
Block a user