Add iOS simulator launch scripts

This commit is contained in:
Mikhail Kilin
2026-05-20 22:26:53 +03:00
parent 6576a37198
commit 10f4c3a84b
7 changed files with 160 additions and 24 deletions

View File

@@ -0,0 +1,87 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
package_dir="${repo_root}/apps/ios/TeleTuiIOS"
if [[ -z "${DEVELOPER_DIR:-}" && -d /Applications/Xcode.app/Contents/Developer ]]; then
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
fi
configuration="${IOS_CONFIGURATION:-Debug}"
derived_data="${IOS_DERIVED_DATA:-/private/tmp/tele-tui-ios-derived-data}"
destination="${IOS_DESTINATION:-generic/platform=iOS Simulator}"
bundle_id="${IOS_BUNDLE_ID:-dev.teletui.TeleTuiIOSApp}"
pushd "${package_dir}" >/dev/null
xcodebuild \
-scheme TeleTuiIOSApp \
-destination "${destination}" \
-configuration "${configuration}" \
-derivedDataPath "${derived_data}" \
build
popd >/dev/null
product_dir="${derived_data}/Build/Products/${configuration}-iphonesimulator"
binary_path="${product_dir}/TeleTuiIOSApp"
app_path="${product_dir}/TeleTuiIOSApp.app"
if [[ ! -x "${binary_path}" ]]; then
printf 'Expected simulator executable was not produced: %s\n' "${binary_path}" >&2
exit 1
fi
rm -rf "${app_path}"
mkdir -p "${app_path}"
cp "${binary_path}" "${app_path}/TeleTuiIOSApp"
cp "${package_dir}/Resources/PrivacyInfo.xcprivacy" "${app_path}/PrivacyInfo.xcprivacy"
printf 'APPL????' > "${app_path}/PkgInfo"
cat > "${app_path}/Info.plist" <<PLIST
<?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>CFBundleDisplayName</key>
<string>TeleTui</string>
<key>CFBundleExecutable</key>
<string>TeleTuiIOSApp</string>
<key>CFBundleIdentifier</key>
<string>${bundle_id}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>TeleTuiIOSApp</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchScreen</key>
<dict/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
PLIST
codesign --force --sign - --timestamp=none "${app_path}/TeleTuiIOSApp" >/dev/null
codesign --force --sign - --timestamp=none "${app_path}" >/dev/null
printf 'Packaged simulator app: %s\n' "${app_path}"

View File

@@ -10,4 +10,10 @@ xcodebuild -version
xcrun simctl list devices available
swift --version
if ! xcrun simctl list devices available | grep -Eq 'iPhone|iPad'; then
printf 'No available iOS simulator devices found. Install the iOS platform from Xcode Settings > Components or run:\n' >&2
printf ' DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcodebuild -downloadPlatform iOS\n' >&2
exit 1
fi
printf 'iOS prerequisites are available.\n'

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if [[ -z "${DEVELOPER_DIR:-}" && -d /Applications/Xcode.app/Contents/Developer ]]; then
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
fi
configuration="${IOS_CONFIGURATION:-Debug}"
derived_data="${IOS_DERIVED_DATA:-/private/tmp/tele-tui-ios-derived-data}"
bundle_id="${IOS_BUNDLE_ID:-dev.teletui.TeleTuiIOSApp}"
app_path="${derived_data}/Build/Products/${configuration}-iphonesimulator/TeleTuiIOSApp.app"
"${repo_root}/scripts/build-ios-simulator-app.sh"
simulator_udid="${IOS_SIMULATOR_UDID:-}"
if [[ -z "${simulator_udid}" ]]; then
simulator_udid="$(xcrun simctl list devices available | awk -F '[()]' '/iPhone/ { print $2; exit }')"
fi
if [[ -z "${simulator_udid}" ]]; then
printf 'No available iPhone simulator found. Run scripts/check-ios-prereqs.sh for details.\n' >&2
exit 1
fi
if ! xcrun simctl list devices "${simulator_udid}" | grep -q 'Booted'; then
xcrun simctl boot "${simulator_udid}"
fi
xcrun simctl bootstatus "${simulator_udid}" -b
xcrun simctl install "${simulator_udid}" "${app_path}"
xcrun simctl launch "${simulator_udid}" "${bundle_id}"
printf 'Launched %s on simulator %s.\n' "${bundle_id}" "${simulator_udid}"