Skip to content

Instantly share code, notes, and snippets.

@csknns
csknns / replacePlistEnvironmentVariables.swift
Last active April 14, 2023 08:35
Replaces referenced environment variables (e.g. $(BUILD_VERSION)) in a plist file
// Usage:
// $/usr/bin/xcrun --sdk macosx swift replacePlistEnvironmentVariables.swift "$inputfile.plist" "$outputfile"
// This will replace all the referenced enviroment variables with their value, for example:
// <string>$(A_VARIABLE)</string>
import Foundation
enum ScriptError: Error {
case invalidPlistArgument(argument: URL)
case sameInputAndOutptFile
}
@csknns
csknns / preprocess-plists.sh
Last active November 19, 2022 08:06
Xcode build phase script to preprocess a plist file
#!/usr/bin/env bash
# Add this to a custom build phase script to enable preprocessing plist files.
#
# This takes as input all the input files from the build phase script
# and runs the preprocessor using the token definitions from the GCC_PREPROCESSOR_DEFINITIONS
# enviroment variable.
#
# This allows you to have the following plist:
#
# <dict>