Repository Public
1#!/usr/bin/env bash2# SP Notes iOS3# File: Scripts/build.sh4# Description: Generate the Xcode project, build, test (filtered xcodebuild output; full log in build/logs).5# usage: build.sh generate | debug | release | test [xcodebuild args] | uitest [xcodebuild args] | core6# SPNOTES_SIM selects the simulator (default "iPhone 17 Pro"; e.g. "iPad Pro 13-inch (M5)").7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -uo pipefail11cd "$(dirname "$0")/.."12SIM="${SPNOTES_SIM:-iPhone 17 Pro}"13DD="build/DerivedData"14mkdir -p build/logs15filter() { grep -E "error:|warning: unre|warning: var|\*\* |Test Suite .* (passed|failed)|Executed [0-9]+ tests|✘|✔|Testing failed|failed \(|: error|Test run with" | grep -v "^$" | sort -u | head -${LINES_MAX:-60}; }16case "${1:-debug}" in17 generate)18 # Info-Debug.plist = Info.plist + local networking allowed + test server URL override allowed (development server through a tunnel)19 cp Resources/Info.plist Resources/Info-Debug.plist20 /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsLocalNetworking true" Resources/Info-Debug.plist21 # the fake backend of the Core, compiled into the test module (see project.yml)22 rm -rf Tests/CoreTestSupport && mkdir -p Tests/CoreTestSupport && cp ../SPNotesCore/Sources/SPNotesTestSupport/*.swift Tests/CoreTestSupport/23 xcodegen generate --quiet && echo "projet généré" ;;24 debug)25 xcodebuild -project SPNotes.xcodeproj -scheme SPNotes -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;26 release)27 xcodebuild -project SPNotes.xcodeproj -scheme SPNotes -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath "$DD" build 2>&1 | tee build/logs/release.log | filter ;;28 test)29 shift || true30 xcodebuild -project SPNotes.xcodeproj -scheme SPNotes -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:SPNotesTests "$@" test 2>&1 | tee build/logs/test.log | filter ;;31 uitest)32 shift || true33 rm -rf "build/results/uitest-${SIM// /_}.xcresult"34 xcodebuild -project SPNotes.xcodeproj -scheme SPNotes -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:SPNotesUITests -resultBundlePath "build/results/uitest-${SIM// /_}.xcresult" "$@" test 2>&1 | tee build/logs/uitest.log | filter35 rm -rf "build/shots/${SIM// /_}"; mkdir -p "build/shots/${SIM// /_}"36 xcrun xcresulttool export attachments --path "build/results/uitest-${SIM// /_}.xcresult" --output-path "build/shots/${SIM// /_}" >/dev/null 2>&1 || true ;;37 core)38 # the shared core, on the host (fast): unit tests of every module39 (cd ../SPNotesCore && swift test --scratch-path .build-ios 2>&1 | tail -15) ;;40 *) echo "usage: build.sh generate|debug|release|test|uitest|core"; exit 2 ;;41esac42