Files
ARMSX2/platforms/ios/scripts/generate-ios-sim-xcode.sh
J1coding 2e50c8bfbc iOS: gate MetalFX upscaler out of simulator builds
MetalFX.framework is not part of the iphonesimulator SDK, so building the
iOS app for the simulator failed at compile time on every MetalFX reference
(`<MetalFX/MetalFX.h>`, `MTLFXSpatialScalerDescriptor`, the cached scaler
members) even though the upscaler is correctly runtime-gated on real
hardware.

Introduce a compile-time switch that follows the SDK target:

- GSDeviceMTL.h defines PCSX2_HAS_METALFX (1 on device, 0 on sim) and
  wraps the MetalFX include, the m_mfx_spatial cache members, and the
  scaler function declarations behind it. The sim build gets a stub
  EnsureMetalFXSpatial that returns false, and DoMetalFXSpatial short-
  circuits the same way; m_features.metalfx_spatial keeps its default
  false so the UI reports the upscaler as unavailable.
- ARMSX2Bridge.mm gates its MetalFX import the same way (ARMSX2_HAS_METALFX)
  and isMetalFXSupported returns NO on sim without touching the descriptor.
- pcsx2/CMakeLists.txt only emits -weak_framework MetalFX for device or
  non-iOS builds; on sim there is nothing to link against.

Adds generate-ios-sim-xcode.sh, a simulator counterpart to the existing
generate-ios-xcode.sh, so the CMake-generated Xcode project can target
iphonesimulator (ARMSX2_REAL_DEVICE=OFF) for simulator debug and test
workflows. Device IPA builds keep using the existing scripts unchanged.
2026-07-24 12:15:28 +02:00

45 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Generates a CMake Xcode project configured for the iOS Simulator (SDK
# iphonesimulator, ARMSX2_REAL_DEVICE=OFF). This is the project XcodeBuildMCP
# should target for simulator workflows (debug, test, UI automation). Device
# IPAs continue to use generate-ios-xcode.sh + build-ios-ipa.sh.
#
# The sim project disables the -weak_framework MetalFX link flag (see
# pcsx2/CMakeLists.txt) because MetalFX.framework is absent from the
# iphonesimulator SDK; all source-level MetalFX references are also
# compile-guarded by PCSX2_HAS_METALFX=0 (see GSDeviceMTL.h).
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SOURCE_DIR="$ROOT_DIR/app/src/main/cpp"
BUILD_DIR="${BUILD_DIR:-$ROOT_DIR/build-ios-sim-xcode}"
BUNDLE_ID="${BUNDLE_ID:-com.armsx2.ios}"
if ! command -v cmake >/dev/null 2>&1; then
echo "error: cmake is required to generate the iOS Simulator Xcode project." >&2
echo "Install CMake from https://cmake.org/download/ or through your package manager." >&2
exit 1
fi
cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -G Xcode \
-DCMAKE_SYSTEM_NAME=iOS \
-DARMSX2_REAL_DEVICE=OFF \
-DARMSX2_BUNDLE_IDENTIFIER="$BUNDLE_ID"
cat <<EOF
Generated iOS Simulator Xcode project:
$BUILD_DIR/ARMSX2iOS.xcodeproj
Open in Xcode:
open "$BUILD_DIR/ARMSX2iOS.xcodeproj"
Simulator build:
xcodebuild -project "$BUILD_DIR/ARMSX2iOS.xcodeproj" -scheme ARMSX2iOS -configuration Debug -sdk iphonesimulator build
XcodeBuildMCP defaults (set after first build):
projectPath: $BUILD_DIR/ARMSX2iOS.xcodeproj
EOF