SPB Git

Repository Public

build.sh 5.7 KB 101 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | SOFTWARE & RESEARCH4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : Groupe Ka — app iOS native8# File             : Scripts/build.sh9# Module           : Scripts10# Repository       : https://git.spboucher.ai/groupe-ka-ios11# Project Website  : Not specified12# Created          : 2026-12-0313# Last Modified    : 2026-12-0314#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development      : dev@spboucher.ai24# Support          : support@spboucher.ai25# Security/Admin   : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License          : None specified (no license file in this repository)34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142# Génération du projet, compilation et tests sur le simulateur dédié.43# usage : build.sh generate | debug | release | device | test | uitest | run [args] | shot <nom>44# GROUPEKA_SIM choisit le simulateur (défaut « GroupeKa iPhone » ; « GroupeKa iPad » pour la tablette).45set -uo pipefail46cd "$(dirname "$0")/.."47SIM="${GROUPEKA_SIM:-GroupeKa iPhone}"48DD="build/DerivedData"49BUNDLE="com.spboucher.groupeka"50mkdir -p build/logs build/shots51filter() { grep -v "CoreData: error\|\[error\] CoreData" | grep -E "error:|warning: unre|\*\* |Executed [0-9]+ tests|✘|✔|Testing failed|failed \(|: error|Test run with|Test [Cc]ase .* (passed|failed)" | grep -v "^$" | sed "s|$PWD/||" | awk '!seen[$0]++' | head -"${LINES_MAX:-60}"; }52generate() {53  xcodegen generate --quiet || return 154  # Info de débogage = Info de production + réseau local (API de développement en http://127.0.0.1)55  cp GroupeKa/Resources/Info.plist GroupeKa/Resources/Info-Debug.plist56  /usr/libexec/PlistBuddy -c "Set :NSAppTransportSecurity:NSAllowsLocalNetworking true" GroupeKa/Resources/Info-Debug.plist57}58udid() {59  local u; u="$(xcrun simctl list devices | grep -F "$SIM (" | head -1 | sed -E 's/.*\(([0-9A-F-]{36})\).*/\1/')"60  if [ -z "$u" ]; then61    # simulateur dédié, créé une fois : l'app n'emprunte pas ceux des autres projets62    local type="com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro"63    case "$SIM" in *SE*) type="com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation";; esac64    case "$SIM" in *iPad*) type="$(xcrun simctl list devicetypes | grep -E "iPad Pro 13-inch \(M[0-9]+\)|iPad Pro \(13-inch\)" | tail -1 | sed -E 's/.*\((com\.apple[^)]*)\).*/\1/')";; esac65    u="$(xcrun simctl create "$SIM" "$type")"66  fi67  echo "$u"68}69case "${1:-debug}" in70  generate) generate && echo "projet généré" ;;71  debug)72    generate; udid >/dev/null73    xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -configuration Debug -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" build 2>&1 | tee build/logs/debug.log | filter ;;74  release)75    generate76    xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -configuration Release -destination "generic/platform=iOS Simulator" -derivedDataPath "$DD" build 2>&1 | tee build/logs/release.log | filter ;;77  device)78    generate79    xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -configuration Debug -destination "generic/platform=iOS" -derivedDataPath "$DD" -allowProvisioningUpdates build 2>&1 | tee build/logs/device.log | filter ;;80  test)81    shift || true; generate; udid >/dev/null82    xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:GroupeKaTests "$@" test 2>&1 | tee build/logs/test.log | filter ;;83  uitest)84    shift || true; generate; udid >/dev/null85    # les parcours tournent hors ligne, sur les réponses réelles capturées (GroupeKaTests/Fixtures)86    mkdir -p build/results87    rm -rf "build/results/uitest-${SIM// /_}.xcresult"88    xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -destination "platform=iOS Simulator,name=$SIM" -derivedDataPath "$DD" -only-testing:GroupeKaUITests -parallel-testing-enabled NO \89      -resultBundlePath "build/results/uitest-${SIM// /_}.xcresult" "$@" test 2>&1 | tee build/logs/uitest.log | filter90    rm -rf "build/shots/uitest-${SIM// /_}"; mkdir -p "build/shots/uitest-${SIM// /_}"91    xcrun xcresulttool export attachments --path "build/results/uitest-${SIM// /_}.xcresult" --output-path "build/shots/uitest-${SIM// /_}" >/dev/null 2>&1 || true ;;92  run)93    # installe et lance l'app sur le simulateur ; arguments suivants = arguments de lancement94    U="$(udid)"; xcrun simctl boot "$U" 2>/dev/null; xcrun simctl bootstatus "$U" >/dev/null 2>&195    xcrun simctl install "$U" "$DD/Build/Products/Debug-iphonesimulator/GroupeKa.app" && xcrun simctl terminate "$U" "$BUNDLE" >/dev/null 2>&196    xcrun simctl launch "$U" "$BUNDLE" "${@:2}" ;;97  shot)98    U="$(udid)"; xcrun simctl io "$U" screenshot "build/shots/${2:-capture}.png" >/dev/null 2>&1 && echo "build/shots/${2:-capture}.png" ;;99  *) echo "usage: build.sh generate|debug|release|device|test|uitest|run [args]|shot <nom>"; exit 2 ;;100esac101
Files main
Menu

Theme