Repository Public
1#!/usr/bin/env bash2# SP Chat iOS3# File: Scripts/build.sh4# Description: Generate the Xcode project, build, test (filtered xcodebuild output; full log in build/logs).5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -uo pipefail9cd "$(dirname "$0")/.."10SIM="${SPCHAT_SIM:-iPhone 17 Pro}"11DD="${SPCHAT_DD:-build/DerivedData}"12mkdir -p build/logs13filter() { grep -E "error:|warning: unre|warning: var|\*\* |Test Suite .* (passed|failed)|Executed [0-9]+ tests|✘|✔|Testing failed|failed \(|: error" | grep -v "^$" | sort -u | head -${LINES_MAX:-60}; }14case "${1:-debug}" in15 generate)16 # Info-Debug.plist = Info.plist + local networking allowed (development server through a tunnel)17 cp SPChat-iOS/Resources/Info.plist SPChat-iOS/Resources/Info-Debug.plist18 /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsLocalNetworking true" SPChat-iOS/Resources/Info-Debug.plist19 xcodegen generate --quiet && echo "projet généré" ;;20 debug)21 xcodebuild -project SPChat.xcodeproj -scheme SPChat -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;22 release)23 xcodebuild -project SPChat.xcodeproj -scheme SPChat -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath "$DD" build 2>&1 | tee build/logs/release.log | filter ;;24 test)25 shift || true26 xcodebuild -project SPChat.xcodeproj -scheme SPChat -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:SPChatTests "$@" test 2>&1 | tee build/logs/test.log | filter ;;27 uitest)28 shift || true29 rm -rf "build/results/uitest-${SIM// /_}.xcresult"30 xcodebuild -project SPChat.xcodeproj -scheme SPChat -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:SPChatUITests -resultBundlePath "build/results/uitest-${SIM// /_}.xcresult" "$@" test 2>&1 | tee build/logs/uitest.log | filter31 rm -rf "build/shots/${SIM// /_}"; mkdir -p "build/shots/${SIM// /_}"32 xcrun xcresulttool export attachments --path "build/results/uitest-${SIM// /_}.xcresult" --output-path "build/shots/${SIM// /_}" >/dev/null 2>&1 || true ;;33 *) echo "usage: build.sh generate|debug|release|test|uitest"; exit 2 ;;34esac35