diff --git a/making_school_asignment_app/flutter_build_ios_onmac.command b/making_school_asignment_app/flutter_build_ios_onmac.command new file mode 100755 index 0000000..3bd0bfd --- /dev/null +++ b/making_school_asignment_app/flutter_build_ios_onmac.command @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' + +# Ensure UTF-8 locale for macOS terminals +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 + +# Resolve project directory (script location) +PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)" + +echo "Project dir: $PROJECT_DIR" + +force_delete() { + local target="$1" + local max_retries=3 + local retry_delay=1 + + if [ ! -e "$PROJECT_DIR/$target" ]; then + return 0 + fi + + for i in $(seq 1 $max_retries); do + echo "Attempting to delete $target (try $i of $max_retries)" + rm -rf "$PROJECT_DIR/$target" 2>/dev/null || true + if [ ! -e "$PROJECT_DIR/$target" ]; then + echo "Successfully deleted $target" + return 0 + fi + if [ "$i" -lt "$max_retries" ]; then + sleep $retry_delay + retry_delay=$((retry_delay * 2)) + fi + done + + echo "Warning: Could not completely delete $target, some files may be in use" + return 1 +} + +cd "$PROJECT_DIR" + +echo "Running flutter clean..." +if ! flutter clean; then + echo "flutter clean failed" + exit 1 +fi + +echo "Removing residual files" +force_delete build || true +force_delete .dart_tool || true +force_delete pubspec.lock || true + +echo "Running flutter pub get..." +if ! flutter pub get; then + echo "flutter pub get failed" + exit 1 +fi + +echo "Running build_runner (if present)..." +if ! flutter packages pub run build_runner build --delete-conflicting-outputs; then + echo "build_runner failed or not present — continuing" +fi + +echo "Building iOS release..." +if ! flutter build ios --release; then + echo "iOS build failed" + exit 1 +fi + +OUTPUT_DIR="$PROJECT_DIR/build/ios/iphoneos" +echo "Opening iOS build output directory: $OUTPUT_DIR" +if [ -d "$OUTPUT_DIR" ]; then + open "$OUTPUT_DIR" +else + echo "iOS build output directory does not exist: $OUTPUT_DIR" +fi + +echo "All steps completed successfully!" +echo "iOS output (if built): $OUTPUT_DIR" + +exit 0