Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Storyboard update from constants
storyboard="path-to-storyboard"
constants="path-to-constants-file"
while read -r line || [[ -n "$line" ]]; do
propName=$(echo $line | grep "static let" | sed 's/static let \([^ ]*\): CGFloat =.*$/\1/' | sed 's/\n//g')
propValue=$(echo $line | grep "static let" | sed 's/.*CGFloat = \(.*$\)/\1/' | sed 's/\n//g')
if [ "x$propValue" != "x" ] && [ "x$propName" != "x" ]; then
sed -i '' "s/^\(.*<constraint.*\)constant=\"[^\"]*\" \(.*userLabel=\"${propName}\".*\)$/\1\2/g" $storyboard
sed -i '' "s/^\(.*<constraint.*\)\(id=\"[^\"]*\".*userLabel=\"${propName}\".*\)$/\1constant=\"${propValue}\" \2/g" $storyboard
fi
done < $constants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.