Mobile step 7b: iOS packaging (simulator verified to the game scene)
- ios/build.sh builds static SDL3 + FreeType, then the .app (code only, embedded Python); signs ad hoc and runs on a simulator, or signs with a development profile and installs with devicectl (device path untested). Simulator-only SDL patch: accept the simulator Metal device for SDL_GPU. - ios/Info.plist.in: landscape, full screen, launch screen, file sharing. - Data dir is Documents on iOS; ios/push_assets.py stages the client root lower-cased (iOS is case-sensitive, the client opens lower-cased paths) and copies it into the app container. - EffectData path normalisation folds A-Z like the effect cache key. - android/push_assets.py: test-rundir base layer + svside/, which the game phase needs (also fixes Android); --lowercase (ASCII only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f973b24abc
commit
908838c8f9
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>ava2_client</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>AVA2</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>AVA2</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>${AVA2_IOS_PLATFORM}</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<!-- An (empty) launch screen opts into the native resolution instead of legacy letterboxing. -->
|
||||
<key>UILaunchScreen</key>
|
||||
<dict/>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>metal</string>
|
||||
</array>
|
||||
<!-- The client root lives in Documents (ios/push_assets.py); Finder / the Files app can copy it in. -->
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<!-- The game server is plain TCP on the local network. -->
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>Connects to the AVA2 game server on your network.</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.role-playing-games</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds the iOS app (arm64) and installs + launches it on a simulator or an attached device.
|
||||
#
|
||||
# ios/build.sh simulator build; boots $AVA2_IOS_SIMULATOR (default: first available
|
||||
# iPhone), installs and launches
|
||||
# ios/build.sh device device build, signed with $AVA2_IOS_SIGN_IDENTITY and
|
||||
# $AVA2_IOS_PROFILE (.mobileprovision); installs + launches when
|
||||
# `xcrun devicectl` sees a device
|
||||
# ios/build.sh deps [device] only (re)build the native dependencies
|
||||
# --no-run (any mode) build only
|
||||
#
|
||||
# Like the APK, the .app holds code only; push the client root with ios/push_assets.py.
|
||||
# Native dependencies (static SDL3 + FreeType) are built once into build/ios-deps (sources are
|
||||
# shared with build/android-deps when already downloaded).
|
||||
# Environment overrides: AVA2_SDK_ROOT, AVA2_SOURCE_DIR (CMake source tree, default this checkout),
|
||||
# AVA2_IOS_BUNDLE_ID (default com.metin2.ava2), AVA2_IOS_SIMULATOR, AVA2_IOS_DEVICE,
|
||||
# AVA2_IOS_BUILD_TYPE (default RelWithDebInfo).
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
ROOT="$(cd "$HERE/.." && pwd)"
|
||||
SOURCE_DIR="${AVA2_SOURCE_DIR:-$ROOT}"
|
||||
|
||||
SDL_VERSION=3.4.16
|
||||
FREETYPE_VERSION=2.13.3
|
||||
DEPLOYMENT_TARGET=15.0
|
||||
|
||||
MODE=simulator RUN=1 DEPS_ONLY=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
sim|simulator) MODE=simulator ;;
|
||||
device) MODE=device ;;
|
||||
deps) DEPS_ONLY=1 ;;
|
||||
--no-run) RUN=0 ;;
|
||||
*) echo "unknown argument: $arg"; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
if [[ "$MODE" == simulator ]]; then SDK=iphonesimulator; else SDK=iphoneos; fi
|
||||
xcrun --sdk "$SDK" --show-sdk-path >/dev/null 2>&1 || { echo "Xcode $SDK SDK not found (xcode-select)"; exit 1; }
|
||||
|
||||
DEPS="$ROOT/build/ios-deps"
|
||||
PREFIX="$DEPS/prefix-$SDK"
|
||||
mkdir -p "$DEPS/src"
|
||||
IOS_CMAKE=(-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT="$SDK" -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET)
|
||||
|
||||
fetch() { # url file
|
||||
[[ -f "$DEPS/src/$2" ]] && return
|
||||
if [[ -f "$ROOT/build/android-deps/src/$2" ]]; then cp "$ROOT/build/android-deps/src/$2" "$DEPS/src/$2"; return; fi
|
||||
curl -fL --retry 3 -o "$DEPS/src/$2.part" "$1" || { echo "download failed: $1"; exit 1; }
|
||||
mv -f "$DEPS/src/$2.part" "$DEPS/src/$2"
|
||||
}
|
||||
|
||||
cmake_dep() { # source-dir build-dir extra-args...
|
||||
local src="$1" bld="$2"; shift 2
|
||||
cmake -S "$src" -B "$bld" "${IOS_CMAKE[@]}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PREFIX" "$@"
|
||||
cmake --build "$bld" -j"$(sysctl -n hw.ncpu)"
|
||||
cmake --install "$bld"
|
||||
}
|
||||
|
||||
if [[ ! -f "$PREFIX/lib/libSDL3.a" ]]; then
|
||||
fetch "https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL3-$SDL_VERSION.tar.gz" "SDL3-$SDL_VERSION.tar.gz"
|
||||
rm -rf "$DEPS/src/SDL3-$SDL_VERSION-$SDK" && mkdir "$DEPS/src/SDL3-$SDL_VERSION-$SDK"
|
||||
tar -xzf "$DEPS/src/SDL3-$SDL_VERSION.tar.gz" -C "$DEPS/src/SDL3-$SDL_VERSION-$SDK" --strip-components 1
|
||||
if [[ "$SDK" == iphonesimulator ]]; then
|
||||
# The simulator's Metal device does not report MTLGPUFamilyApple3, so SDL_GPU refuses it
|
||||
# although the host GPU runs the client fine. Skip the check there; device builds are untouched.
|
||||
perl -0pi -e 's/(hasHardwareSupport = \[device supportsFamily:MTLGPUFamilyApple3\])/$1 || TARGET_OS_SIMULATOR/' \
|
||||
"$DEPS/src/SDL3-$SDL_VERSION-$SDK/src/gpu/metal/SDL_gpu_metal.m"
|
||||
grep -q "MTLGPUFamilyApple3\] || TARGET_OS_SIMULATOR" \
|
||||
"$DEPS/src/SDL3-$SDL_VERSION-$SDK/src/gpu/metal/SDL_gpu_metal.m" || { echo "SDL simulator patch failed"; exit 1; }
|
||||
fi
|
||||
cmake_dep "$DEPS/src/SDL3-$SDL_VERSION-$SDK" "$DEPS/build-sdl3-$SDK" \
|
||||
-DSDL_SHARED=OFF -DSDL_STATIC=ON -DSDL_TEST_LIBRARY=OFF -DSDL_TESTS=OFF -DSDL_EXAMPLES=OFF
|
||||
fi
|
||||
if [[ ! -f "$PREFIX/lib/libfreetype.a" ]]; then
|
||||
fetch "https://download.savannah.gnu.org/releases/freetype/freetype-$FREETYPE_VERSION.tar.xz" "freetype-$FREETYPE_VERSION.tar.xz"
|
||||
rm -rf "$DEPS/src/freetype-$FREETYPE_VERSION" && tar -xJf "$DEPS/src/freetype-$FREETYPE_VERSION.tar.xz" -C "$DEPS/src"
|
||||
cmake_dep "$DEPS/src/freetype-$FREETYPE_VERSION" "$DEPS/build-freetype-$SDK" -DBUILD_SHARED_LIBS=OFF \
|
||||
-DFT_DISABLE_ZLIB=ON -DFT_DISABLE_BZIP2=ON -DFT_DISABLE_PNG=ON -DFT_DISABLE_HARFBUZZ=ON -DFT_DISABLE_BROTLI=ON
|
||||
fi
|
||||
[[ "$DEPS_ONLY" == 1 ]] && exit 0
|
||||
|
||||
BUILD="$ROOT/build/ios-$SDK"
|
||||
CONFIG_ARGS=("${IOS_CMAKE[@]}" -DCMAKE_BUILD_TYPE="${AVA2_IOS_BUILD_TYPE:-RelWithDebInfo}"
|
||||
-DAVA2_BUILD_HOST=ON -DAVA2_EMBED_PYTHON=ON -DBUILD_TESTING=OFF
|
||||
-DSDL3_DIR="$PREFIX/lib/cmake/SDL3" -DCMAKE_PREFIX_PATH="$PREFIX"
|
||||
-DAVA2_IOS_BUNDLE_ID="${AVA2_IOS_BUNDLE_ID:-com.metin2.ava2}")
|
||||
[[ -n "${AVA2_SDK_ROOT:-}" ]] && CONFIG_ARGS+=(-DAVA2_SDK_ROOT="$AVA2_SDK_ROOT")
|
||||
cmake -S "$SOURCE_DIR" -B "$BUILD" "${CONFIG_ARGS[@]}"
|
||||
cmake --build "$BUILD" --target ava2_client mtpython_stdlib -j"$(sysctl -n hw.ncpu)"
|
||||
APP="$BUILD/ava2_client.app"
|
||||
BUNDLE_ID="${AVA2_IOS_BUNDLE_ID:-com.metin2.ava2}"
|
||||
|
||||
if [[ "$MODE" == simulator ]]; then
|
||||
codesign --force --sign - --timestamp=none "$APP"
|
||||
else
|
||||
[[ -n "${AVA2_IOS_SIGN_IDENTITY:-}" && -f "${AVA2_IOS_PROFILE:-}" ]] || {
|
||||
echo "Device builds need AVA2_IOS_SIGN_IDENTITY (security find-identity -v -p codesigning) and"
|
||||
echo "AVA2_IOS_PROFILE (a development .mobileprovision for $BUNDLE_ID)."; exit 1; }
|
||||
cp "$AVA2_IOS_PROFILE" "$APP/embedded.mobileprovision"
|
||||
ENTITLEMENTS="$BUILD/entitlements.plist"
|
||||
security cms -D -i "$AVA2_IOS_PROFILE" > "$BUILD/profile.plist"
|
||||
/usr/libexec/PlistBuddy -x -c "Print :Entitlements" "$BUILD/profile.plist" > "$ENTITLEMENTS"
|
||||
codesign --force --sign "$AVA2_IOS_SIGN_IDENTITY" --entitlements "$ENTITLEMENTS" --timestamp=none "$APP"
|
||||
fi
|
||||
du -sh "$APP"
|
||||
[[ "$RUN" == 1 ]] || exit 0
|
||||
|
||||
if [[ "$MODE" == simulator ]]; then
|
||||
SIM="${AVA2_IOS_SIMULATOR:-}"
|
||||
if [[ -z "$SIM" ]]; then
|
||||
SIM="$(xcrun simctl list devices booted | sed -nE 's/.*\(([0-9A-F-]{36})\) \(Booted\).*/\1/p' | head -1)"
|
||||
fi
|
||||
if [[ -z "$SIM" ]]; then
|
||||
SIM="$(xcrun simctl list devices available | grep -E '^ +iPhone' | tail -1 | sed -nE 's/.*\(([0-9A-F-]{36})\).*/\1/p')"
|
||||
fi
|
||||
[[ -n "$SIM" ]] || { echo "No iOS simulator available (Xcode > Settings > Platforms)"; exit 1; }
|
||||
xcrun simctl boot "$SIM" 2>/dev/null || true
|
||||
open -a Simulator --args -CurrentDeviceUDID "$SIM" || true
|
||||
xcrun simctl bootstatus "$SIM" -b >/dev/null
|
||||
xcrun simctl install "$SIM" "$APP"
|
||||
xcrun simctl launch "$SIM" "$BUNDLE_ID"
|
||||
echo "Launched on simulator $SIM. Logs: xcrun simctl spawn $SIM log stream --predicate 'process == \"ava2_client\"'"
|
||||
else
|
||||
DEVICE="${AVA2_IOS_DEVICE:-}"
|
||||
if [[ -z "$DEVICE" ]]; then
|
||||
DEVICE="$(xcrun devicectl list devices 2>/dev/null | awk '/available|connected/ && /iPhone|iPad/ {print $3; exit}')"
|
||||
fi
|
||||
if [[ -z "$DEVICE" ]]; then echo "No device attached; app not installed."; exit 0; fi
|
||||
xcrun devicectl device install app --device "$DEVICE" "$APP"
|
||||
xcrun devicectl device process launch --device "$DEVICE" "$BUNDLE_ID"
|
||||
fi
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Copy the client root into the iOS app's Documents directory (development builds).
|
||||
|
||||
The .app holds code only; on iOS the client runs in its Documents directory and reads the same
|
||||
flattened client root as Android (test-rundir + assets/loose + upstream/python-root + python27.zip).
|
||||
The tree is staged by android/push_assets.py --stage-only --lowercase into build/ios-data/root (all
|
||||
names ASCII lower-case: iOS file systems are case-sensitive and the client opens lower-cased
|
||||
paths), then:
|
||||
|
||||
simulator copied into `xcrun simctl get_app_container <udid> <bundle> data`/Documents as APFS
|
||||
clones (cp -c: no extra disk space, and the app cannot write through to the checkout)
|
||||
device sent with `xcrun devicectl device copy to` into the app data container
|
||||
|
||||
Install the app first (ios/build.sh), since the container only exists after install.
|
||||
|
||||
usage: ios/push_assets.py [device] [--simulator UDID] [--device ID] [--stdlib ZIP] [--pack-maker DIR]
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
BUNDLE_ID = os.environ.get("AVA2_IOS_BUNDLE_ID", "com.metin2.ava2")
|
||||
|
||||
|
||||
def booted_simulator():
|
||||
out = subprocess.run(["xcrun", "simctl", "list", "devices", "booted"], check=True,
|
||||
capture_output=True, text=True).stdout
|
||||
match = re.search(r"\(([0-9A-F-]{36})\) \(Booted\)", out)
|
||||
return match.group(1) if match else None
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument("target", nargs="?", choices=["sim", "simulator", "device"], default="simulator")
|
||||
parser.add_argument("--simulator", default=os.environ.get("AVA2_IOS_SIMULATOR"), help="UDID (default: booted)")
|
||||
parser.add_argument("--device", default=os.environ.get("AVA2_IOS_DEVICE"), help="devicectl device id")
|
||||
parser.add_argument("--stdlib", help="python27.zip (default: the matching ios/build.sh output)")
|
||||
parser.add_argument("--pack-maker", help="passed to android/push_assets.py")
|
||||
parser.add_argument("--stage", type=Path, default=ROOT / "build/ios-data/root")
|
||||
args = parser.parse_args()
|
||||
device = args.target == "device"
|
||||
|
||||
stdlib = args.stdlib or ROOT / f"build/ios-{'iphoneos' if device else 'iphonesimulator'}/python27.zip"
|
||||
if not Path(stdlib).is_file():
|
||||
sys.exit(f"{stdlib} not found; run ios/build.sh first or pass --stdlib")
|
||||
# iOS file systems are case-sensitive while the client lower-cases the paths it opens
|
||||
# (ResourceManager::NormalizePath) and the data mixes cases, so stage every name lower-case.
|
||||
stage_cmd = [sys.executable, str(ROOT / "android/push_assets.py"), "--stage-only", "--lowercase",
|
||||
"--stage", str(args.stage), "--stdlib", str(stdlib)]
|
||||
if args.pack_maker:
|
||||
stage_cmd += ["--pack-maker", args.pack_maker]
|
||||
subprocess.run(stage_cmd, check=True)
|
||||
|
||||
if not device:
|
||||
udid = args.simulator or booted_simulator()
|
||||
if not udid:
|
||||
sys.exit("no booted simulator; run ios/build.sh or pass --simulator")
|
||||
container = subprocess.run(["xcrun", "simctl", "get_app_container", udid, BUNDLE_ID, "data"],
|
||||
check=True, capture_output=True, text=True).stdout.strip()
|
||||
docs = Path(container) / "Documents"
|
||||
docs.mkdir(parents=True, exist_ok=True)
|
||||
# Trailing "/." copies the directory's contents; -c clones, plain copy across volumes.
|
||||
if subprocess.run(["cp", "-Rc", f"{args.stage}/.", str(docs)]).returncode != 0:
|
||||
subprocess.run(["cp", "-R", f"{args.stage}/.", str(docs)], check=True)
|
||||
print(f"copied to {docs}")
|
||||
return
|
||||
|
||||
if not args.device:
|
||||
out = subprocess.run(["xcrun", "devicectl", "list", "devices"], check=True,
|
||||
capture_output=True, text=True).stdout
|
||||
ids = [line.split()[2] for line in out.splitlines()
|
||||
if re.search(r"available|connected", line) and re.search(r"iPhone|iPad", line)]
|
||||
if not ids:
|
||||
sys.exit("no device attached")
|
||||
args.device = ids[0]
|
||||
subprocess.run(["xcrun", "devicectl", "device", "copy", "to", "--device", args.device,
|
||||
"--domain-type", "appDataContainer", "--domain-identifier", BUNDLE_ID,
|
||||
"--source", str(args.stage), "--destination", "Documents"], check=True)
|
||||
print(f"copied to {args.device}:{BUNDLE_ID}/Documents")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user