Skip to content

Xcode 10.0 migration

Jakub Olejník edited this page Sep 24, 2018 · 4 revisions
  • Swift 4.2

Code changes

  • nothing much, just run migrator and most of the things should be fine
  • most of the changes just change namespaces of some constants and types

Project changes

Environment switch

  • add environment.plist as output file for Environment switch build phase
$(ACK_ENVIRONMENT_DIR)/Current/environment.plist
  • update Environment switch build phase script
CURRENT_ENV_FILE="${ACK_ENVIRONMENT_DIR}/.current"
ENVIRONMENT=`cat ${CURRENT_ENV_FILE} || echo "Development"`
SELECTED_ENV_DIR="${ACK_ENVIRONMENT_DIR}/${ENVIRONMENT}"
CURRENT_ENV_DIR="${ACK_ENVIRONMENT_DIR}/Current"

rm -r "${CURRENT_ENV_DIR}" 2>/dev/null || true
cp -r "${SELECTED_ENV_DIR}" "${CURRENT_ENV_DIR}"
touch "${INFOPLIST_FILE}"
touch "$CURRENT_ENV_DIR"
  • update Generate environment file build phase script
touch "${SCRIPT_INPUT_FILE_0}"
"${PROJECT_DIR}/Tools/EnvironmentGenerator.swift"
touch "${SCRIPT_OUTPUT_FILE_0}"
  • add GoogleService-Info.plist as output file for Select GoogleService-Info.plist build phase
${ACK_ENVIRONMENT_DIR}/Current/GoogleService-Info.plist
  • update Select GoogleService-Info.plist script
echo "Selecting GoogleService-Info.plist for configuration ${CONFIGURATION}"

SRC="${ACK_ENVIRONMENT_DIR}/GoogleService/GoogleService-Info-${CONFIGURATION}.plist"
DST="${SCRIPT_OUTPUT_FILE_0}"

cp "$SRC" "$DST"
touch "$DST"
  • add environment.plist as input file for Generate environment file build phase
$(ACK_ENVIRONMENT_DIR)/Current/environment.plist
  • add Environment.swift as output file for Generate environment file build phase
$(ACK_ENVIRONMENT_DIR)/Environment.swift

SwiftGen

  • add Localizable.strings and Images.xcassets as input files for SwiftGen build phase
${PROJECT_DIR}/${TARGET_NAME}/Resources/en.lproj/Localizable.strings
${PROJECT_DIR}/${TARGET_NAME}/Resources/Images.xcassets

IMPORTANT: Keep the order as is

  • add LocalizedStrings.swift and Assets.swift as output files for SwiftGen build phase
${PROJECT_DIR}/${TARGET_NAME}/Model/Generated/LocalizedStrings.swift
${PROJECT_DIR}/${TARGET_NAME}/Model/Generated/Assets.swift

IMPORTANT: Keep the order as is

  • update SwiftGen script so it touches input files on every build
export PATH="${PODS_ROOT}/SwiftGen/bin:$PATH"

LOC_SRC_FILE="${SCRIPT_INPUT_FILE_0}"
IMG_SRC_FILE="${SCRIPT_INPUT_FILE_1}"

touch "$LOC_SRC_FILE"
touch "$IMG_SRC_FILE"

swiftgen strings -t structured-swift4 "$LOC_SRC_FILE" -o "${SCRIPT_OUTPUT_FILE_0}"
swiftgen xcassets -t swift4 "$IMG_SRC_FILE" -o "${SCRIPT_OUTPUT_FILE_1}"