BuildSharedFramework.sh
iosApp/BuildSharedFramework.sh
1#!/bin/sh2set -e34if [ -z "${JAVA_HOME:-}" ]; then5 JDK_HOME="$(/usr/libexec/java_home -v 21 2>/dev/null || true)"67 if [ -z "$JDK_HOME" ]; then8 for candidate in \9 "$HOME/Applications/Android Studio.app/Contents/jbr/Contents/Home" \10 "/Applications/Android Studio.app/Contents/jbr/Contents/Home"11 do12 if [ -x "$candidate/bin/java" ]; then13 JDK_HOME="$candidate"14 break15 fi16 done17 fi1819 if [ -n "$JDK_HOME" ]; then20 export JAVA_HOME="$JDK_HOME"21 export PATH="$JAVA_HOME/bin:$PATH"22 fi23fi2425if [ -n "${SRCROOT:-}" ]; then26 REPO_ROOT="$SRCROOT/.."27else28 SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"29 REPO_ROOT="$SCRIPT_DIR/.."30fi3132cd "$REPO_ROOT"33. "$REPO_ROOT/scripts/yokan-version.sh"34./gradlew :composeApp:embedAndSignAppleFrameworkForXcode --stacktrace --console=plain3536# Bundle libmpv beside the app so kmp-mpv's dynamic bridge can resolve it.37# The published archive currently labels its arm64 binaries as device-only,38# but the binaries are also usable by the arm64 simulator after rewriting the39# Mach-O platform load command, matching the embedded JVM runtime strategy.40case "${PLATFORM_NAME:-}" in41 iphoneos|iphonesimulator)42 MPV_ROOT="${YOKAN_KMP_MPV_ROOT:-$REPO_ROOT/vendor/kmp-mpv}"43 "$MPV_ROOT/scripts/prepare-media-kit-ios.sh"44 MPV_FRAMEWORKS="$MPV_ROOT/build/media-kit-mpv/ios"45 APP_FRAMEWORKS="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"46 mkdir -p "$APP_FRAMEWORKS"4748 for xcframework in "$MPV_FRAMEWORKS"/*.xcframework; do49 framework_name="$(basename "$xcframework" .xcframework)"50 source_framework="$xcframework/ios-arm64/$framework_name.framework"51 if [ -d "$source_framework" ]; then52 destination_framework="$APP_FRAMEWORKS/$framework_name.framework"53 rm -rf "$destination_framework"54 ditto "$source_framework" "$destination_framework"5556 if [ "${PLATFORM_NAME:-}" = "iphonesimulator" ]; then57 binary="$destination_framework/$framework_name"58 patched="${binary}.iossim"59 /usr/bin/xcrun vtool \60 -set-build-version iossim "${IPHONEOS_DEPLOYMENT_TARGET:-15.0}" "${SDK_VERSION:-26.0}" \61 -replace -output "$patched" "$binary"62 /bin/mv "$patched" "$binary"63 fi6465 signing_identity="${EXPANDED_CODE_SIGN_IDENTITY:--}"66 codesign --force --sign "$signing_identity" \67 --preserve-metadata=identifier,entitlements \68 "$destination_framework"69 fi70 done71 ;;72esac73