spiegel-keyman/ios/scripts/kme-universal.sh
Eberhard Beilharz 4d81589f48
maint(common): use unique names for Keyman version variables
Previously the builder scripts defined a readonly `VERSION` environment
variable for the Keyman version. That caused problems when another
(external) script tried to define a `VERSION` variable. We encountered
this problem when trying to move the TC build steps of a configuration
into a single script (#13399) when we tried to source `~/.nvm/nvm.sh`.

This change uses a Keyman specific prefix for the version variables and
renames `VERSION` → `KEYMAN_VERSION` etc. Unfortunately these variables
are used in a lot of places, so this turned out to be a bit of a yak
shave.

Test-bot: skip
2025-05-07 18:46:51 +02: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/build-utils.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}