Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/build.sh4# Description: Generates the Xcode project and builds one target (errors only on the console).5#6# Usage: Scripts/build.sh [mac|ios] [Debug|Release] [lines]7# mac Debug → « SP Mail Dev.app » (no Associated Domains: safe to launch any time)8# ios → built for the iOS Simulator (no signing)9# Each scheme builds the app and its three embedded extensions (widgets, share extension, notification service).10# Products go outside ~/Desktop: ~/Library/Developer/SPMail/DerivedData.11set -uo pipefail12cd "$(dirname "$0")/.."13WHAT="${1:-mac}"; CONFIG="${2:-Debug}"; DD="${SPMAIL_DD:-$HOME/Library/Developer/SPMail/DerivedData}"; mkdir -p Build "$DD"14xcodegen generate --quiet15if [[ "$WHAT" == ios ]]; then16 xcodebuild -project SPMail.xcodeproj -scheme SPMail-iOS -configuration "$CONFIG" -derivedDataPath "$DD" -destination 'generic/platform=iOS Simulator' build 2>&1 | sed 's/\x1b\[[0-9;]*m//g' > "Build/build-ios-$CONFIG.log"17 LOG="Build/build-ios-$CONFIG.log"18else19 EXTRA=()20 # Release needs the Developer ID provisioning profile (Scripts/provision.py); without it, build unsigned to check that it compiles.21 # (one profile for the app and one per extension: SPMail, SPMailWidgets, SPMailShare, SPMailNotifications)22 if [[ "$CONFIG" == Release ]]; then23 for p in SPMail SPMailWidgets SPMailShare SPMailNotifications; do24 [[ -f "Build/profiles/$p.provisionprofile" ]] || { EXTRA=(CODE_SIGNING_ALLOWED=NO); echo "note: Build/profiles/$p.provisionprofile missing, Release built unsigned"; break; }25 done26 fi27 xcodebuild -project SPMail.xcodeproj -scheme SPMail -configuration "$CONFIG" -derivedDataPath "$DD" -destination 'platform=macOS' ${EXTRA[@]+"${EXTRA[@]}"} build 2>&1 | sed 's/\x1b\[[0-9;]*m//g' > "Build/build-mac-$CONFIG.log"28 LOG="Build/build-mac-$CONFIG.log"29fi30grep -E "error:|warning: unre|\*\* BUILD" "$LOG" | sed -E "s#$PWD/##" | grep -v "^ *|" | sort -u | cut -c1-320 | head -"${3:-50}"31grep -q "BUILD SUCCEEDED" "$LOG"32