spiegel-keyman/ios/scripts/kme-universal.sh
Marc Durdin f394245636 maint(common): consolidate builder scripts
Clarifies the confusing builder.inc.sh / build-utils.sh distinction by
giving the scripts more appropriate names. Most build scripts should use
builder-full.inc.sh; some helper scripts can use builder-basic.inc.sh.
Documented in resources/build/README.md.

Renames:
* resources/build/builder.inc.sh to resources/build/builder-full.inc.sh
* resources/build/build-utils.sh to resources/build/builder-basic.inc.sh

Other changes:
* Moves Android-specific functions out of builder-basic.inc.sh and into
  android/build.sh.
* Renames functions in builder-basic.inc.sh

More functions may be moved from builder-basic.inc.sh into utils.inc.sh
or other scripts in the future.

Fixes: #14065
Build-bot: build all
Test-bot: skip
2025-08-02 08:11:24 +10:00

75 lines
2.5 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
set -u
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
. "${THIS_SCRIPT%/*}/../../resources/build/builder-basic.inc.sh"
## END STANDARD BUILD SCRIPT INCLUDE
SCHEME_NAME="KeymanEngine"
FRAMEWORK_NAME="KeymanEngine"
# CONFIGURATION: one of [Debug, Debug + Sentry, Release]
# - is auto-set by Xcode, is also managed by initial build script
XCFRAMEWORK="${BUILD_DIR}/${CONFIGURATION}/${FRAMEWORK_NAME}.xcframework"
IPHONE_FRAMEWORK="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
SIMULATOR_FRAMEWORK="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
echo ""
echo "Running: ${KEYMAN_ROOT}/ios/scripts/kme-universal.sh"
echo ""
# Used to build the appropriate archive files needed to construct the XCFramework.
# $1 - defines the target device type (`-destination` parameter for `xcodebuild`).
build_archive ( ) {
# Note: while official docs say we should use `xcodebuild archive ...`, that
# is not only markedly slower, it also adds undesired side-effects to
# our build processes.
# (It nukes the base .framework file used to build the archive with a
# broken alias that subsequent builds [like the main app's!] can't process.)
run_xcodebuild build \
-scheme "${SCHEME_NAME}" \
-configuration ${CONFIGURATION} \
-sdk "$1" \
-quiet \
BUILD_DIR="${BUILD_DIR}" \
BUILD_ROOT="${BUILD_ROOT}" \
KEYMAN_VERSION=$KEYMAN_VERSION \
KEYMAN_VERSION_WITH_TAG=$KEYMAN_VERSION_WITH_TAG \
KEYMAN_VERSION_ENVIRONMENT=$KEYMAN_VERSION_ENVIRONMENT \
UPLOAD_SENTRY=$UPLOAD_SENTRY
}
# Build the target-specfic archives
echo ""
echo "Building iphoneos archive"
echo ""
build_archive iphoneos
echo ""
echo "Building iphonesimulator archive"
echo ""
build_archive iphonesimulator
# Clean old build product if it exists
if [ -e ${XCFRAMEWORK} ]; then
rm -rf "${XCFRAMEWORK}"
fi
echo ""
echo "Compiling ${FRAMEWORK_NAME}.xcframework"
echo ""
# Build the final XCFramework file.
# -allow-internal-distribution: preserves the .swiftmodule files, greatly
# simplifying integration in consuming apps.
# - Carthage uses this for its XCFramework support.
run_xcodebuild -create-xcframework \
-allow-internal-distribution \
-framework ${IPHONE_FRAMEWORK} \
-framework ${SIMULATOR_FRAMEWORK} \
-output ${XCFRAMEWORK}