fix(ios): use environment and version-with-tag for sentry

This commit is contained in:
Marc Durdin 2020-04-28 11:35:59 +10:00
parent b5f32fbbaf
commit aa22a3757a
6 changed files with 23 additions and 11 deletions

View file

@ -1239,7 +1239,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "NAME=\"KeymanEngine\"\nUNIVERSAL_DIR=\"${BUILD_DIR}/${CONFIGURATION}-universal/${NAME}.framework\"\nIPHONE_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${NAME}.framework\"\nSIMULATOR_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${NAME}.framework\"\n\n# Build architecture that was not built\nif [ ${PLATFORM_NAME} = \"iphonesimulator\" ]; then\n xcodebuild -scheme \"${NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" build VERSION=$VERSION VERSION_WITH_TAG=$VERSION_WITH_TAG\nelse\n xcodebuild -scheme \"${NAME}\" -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" build VERSION=$VERSION VERSION_WITH_TAG=$VERSION_WITH_TAG\nfi\n\n# Clean\nrm -rf \"${UNIVERSAL_DIR}\"\nmkdir -p \"${UNIVERSAL_DIR}\"\n\n# Use iPhone framework as base\ncp -R \"${IPHONE_DIR}/\" \"${UNIVERSAL_DIR}/\"\n\n# Copy Swift modules from simulator build\ncp -R \"${SIMULATOR_DIR}/Modules/${NAME}.swiftmodule/\" \"${UNIVERSAL_DIR}/Modules/${NAME}.swiftmodule/\"\n\n# Create universal binary using lipo\nlipo -create \"${IPHONE_DIR}/${NAME}\" \"${SIMULATOR_DIR}/${NAME}\" -output \"${UNIVERSAL_DIR}/${NAME}\"\n";
shellScript = "NAME=\"KeymanEngine\"\nUNIVERSAL_DIR=\"${BUILD_DIR}/${CONFIGURATION}-universal/${NAME}.framework\"\nIPHONE_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphoneos/${NAME}.framework\"\nSIMULATOR_DIR=\"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${NAME}.framework\"\n\n# Build architecture that was not built\nif [ ${PLATFORM_NAME} = \"iphonesimulator\" ]; then\n xcodebuild -scheme \"${NAME}\" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" build VERSION=$VERSION VERSION_WITH_TAG=$VERSION_WITH_TAG VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT\nelse\n xcodebuild -scheme \"${NAME}\" -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" build VERSION=$VERSION VERSION_WITH_TAG=$VERSION_WITH_TAG VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT\nfi\n\n# Clean\nrm -rf \"${UNIVERSAL_DIR}\"\nmkdir -p \"${UNIVERSAL_DIR}\"\n\n# Use iPhone framework as base\ncp -R \"${IPHONE_DIR}/\" \"${UNIVERSAL_DIR}/\"\n\n# Copy Swift modules from simulator build\ncp -R \"${SIMULATOR_DIR}/Modules/${NAME}.swiftmodule/\" \"${UNIVERSAL_DIR}/Modules/${NAME}.swiftmodule/\"\n\n# Create universal binary using lipo\nlipo -create \"${IPHONE_DIR}/${NAME}\" \"${SIMULATOR_DIR}/${NAME}\" -output \"${UNIVERSAL_DIR}/${NAME}\"\n";
};
C0A5FF381F6684A300BE740C /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;

View file

@ -30,16 +30,16 @@ public class SentryManager {
log.debug("Sentry error logging enabled.")
#endif
#if DEBUG
let environment = "DEVELOPMENT-\(Version.currentTagged.majorMinor.fullString)"
#else
let environment = "PRODUCTION-\(Version.currentTagged.majorMinor.fullString)"
#endif
let infoDict = Bundle.main.infoDictionary
let versionWithTag = infoDict?["KeymanVersionWithTag"] as? String ?? ""
let environment = infoDict?["KeymanVersionEnvironment"] as? String ?? ""
let release = "release-\(versionWithTag)"
let options: [String: Any] = [
"dsn": "https://d14d2efb594e4345b8367dbb61ebceaf@sentry.keyman.com/8",
"enabled": allowEnabled && sendingEnabled,
"environment": environment
"environment": environment,
"release": release
]
Sentry.Client.shared = try Sentry.Client(options: options)
try Sentry.Client.shared?.startCrashHandler()

View file

@ -4,6 +4,8 @@
<dict>
<key>KeymanVersionWithTag</key>
<string>10.0.0-local</string>
<key>KeymanVersionEnvironment</key>
<string>local</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>

View file

@ -47,6 +47,8 @@
<false/>
<key>KeymanVersionWithTag</key>
<string>10.0.0-local</string>
<key>KeymanVersionEnvironment</key>
<string>local</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>

View file

@ -165,13 +165,15 @@ echo
echo "Build products will be set with the following version metadata:"
echo " * VERSION=$VERSION"
echo " * VERSION_WITH_TAG=$VERSION_WITH_TAG"
echo " * VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT"
echo
echo "Building KMEI..."
rm -r $BUILD_PATH/$CONFIG-universal 2>/dev/null
xcodebuild $XCODEFLAGS_EXT $CODE_SIGN -scheme KME-universal \
VERSION=$VERSION \
VERSION_WITH_TAG=$VERSION_WITH_TAG
VERSION_WITH_TAG=$VERSION_WITH_TAG \
VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT
if [ $? -ne 0 ]; then
fail "KMEI build failed."
@ -190,7 +192,8 @@ if [ $DO_KEYMANAPP = true ]; then
if [ $DO_ARCHIVE = false ]; then
xcodebuild $XCODEFLAGS_EXT $CODE_SIGN -scheme Keyman \
VERSION=$VERSION \
VERSION_WITH_TAG=$VERSION_WITH_TAG
VERSION_WITH_TAG=$VERSION_WITH_TAG \
VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT
if [ $? -ne 0 ]; then
fail "Keyman app build failed."
@ -204,7 +207,8 @@ if [ $DO_KEYMANAPP = true ]; then
-archivePath $ARCHIVE_PATH \
archive -allowProvisioningUpdates \
VERSION=$VERSION \
VERSION_WITH_TAG=$VERSION_WITH_TAG
VERSION_WITH_TAG=$VERSION_WITH_TAG \
VERSION_ENVIRONMENT=$VERSION_ENVIRONMENT
assertDirExists "$ARCHIVE_PATH"

View file

@ -17,7 +17,7 @@ function buildError() {
# Imports the autogenerated environment.sh from command-line builds.
function importEnvironment() {
# Requires that KEYMAN_ROOT is set... which it should be, if a build is successfully
# Requires that KEYMAN_ROOT is set... which it should be, if a build is successfully
if [ -z "${KEYMAN_ROOT:-}" ]; then
buildError "KEYMAN_ROOT is not defined. Recommendation: define it as a project-wide \"user-defined\" Build Setting for the \"$PROJECT_NAME\" project."
exit 1
@ -49,6 +49,7 @@ function phaseSetBundleVersions() {
echo "UI build - fetching version from repository:"
echo " Plain: $VERSION"
echo " Tagged: $VERSION_WITH_TAG"
echo " Environment: $VERSION_ENVIRONMENT"
else
echo "Command-line build - using provided version parameters"
fi
@ -63,6 +64,8 @@ function phaseSetBundleVersions() {
if [ $TAGGED == true ]; then
echo "Setting $VERSION_WITH_TAG for tagged version"
/usr/libexec/Plistbuddy -c "Set :KeymanVersionWithTag $VERSION_WITH_TAG" "$APP_PLIST"
echo "Setting $VERSION_ENVIRONMENT"
/usr/libexec/Plistbuddy -c "Set :KeymanVersionEnvironment $VERSION_ENVIRONMENT" "$APP_PLIST"
fi
if [ -f "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}.dSYM/Contents/Info.plist" ]; then
@ -84,6 +87,7 @@ function setSettingsBundleVersion() {
echo "UI build - fetching version from repository:"
echo " Plain: $VERSION"
echo " Tagged: $VERSION_WITH_TAG"
echo " Environment: (not setting, assume 'local')"
else
echo "Command-line build - using provided version parameters"
fi