Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Saturday, May 23, 2015

Xcode Automated Build Numbering, Now For Watch Apps, Too

If your iOS project contains a watch extension, Xcode mandates the build numbers in the main app's and the extension's Info.plist files to match. This can be problematic if the build number is auto-generated from the number of Git changes for example.

Below is a build number generator script that ensures all extensions get the same build number as the main app.

First, replace MyApp, MyTodayWidget etc. with the actual app and extension names from your project. Then in Xcode, add the script to the main app build phases as a "New Run Script Phase", after the "Copy Bundle Resources" phase.


# Set the build number to the count of Git commits
buildNumber=$(git rev-list HEAD | wc -l | tr -d ' ')

# Enlist app name and extension names
app="MyApp"
todayExtension="MyTodayWidget"
watchKitExtension="MyWatchExtension"
watchKitApp="MyWatchApp"

# Ensure extension build numbers are the same as the main app
appDir="${app}.app"
todayExtensionDir="${appDir}/PlugIns/${todayExtension}.appex"
watchKitExtensionDir="${appDir}/PlugIns/${watchKitExtension}.appex"
watchKitAppDir="${watchKitExtensionDir}/${watchKitApp}.app"
plistDirs=( "$appDir" "$todayExtensionDir" "$watchKitExtensionDir"  "$watchKitAppDir" )

for dir in "${plistDirs[@]}"
do
    plist=${dir}/Info.plist
    echo "Updating ${TARGET_BUILD_DIR}/$plist"
    /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${TARGET_BUILD_DIR}/${plist}"

done

Monday, March 5, 2012

Qt Creator On Mac, Asking For Password

Qt Creator may ask for a password, if automatic login is not configured for the version control system. The Linux utility for this task is usually ssh-askpass, but it does not exist on the Mac.

Here is an alternative, originating from Joseph Mocker:


#! /bin/sh
# An SSH_ASKPASS command for MacOS X, with minor modifications to macos-askpass
# by Joseph Mocker, Sun Microsystems.
#
# To use this script:
#     setenv SSH_ASKPASS "ssh-askpass-mac"


TITLE="Enter SSH Password"  
DIALOG="display dialog \"$@\" default answer \"\" with title \"$TITLE\""
DIALOG="$DIALOG with icon 1 with hidden answer"  


result=`osascript -e 'tell application "Finder"' -e "activate"  -e "$DIALOG" -e 'end tell'`  


if [ "$result" = "" ]; then
    exit 1
else
    echo "$result" | sed -e 's/^text returned://' -e 's/, button returned:.*$//'
    exit 0
fi

Save it to /usr/local/bin/ssh-askpass-mac, and let Qt Creator know where to find: PreferencesVersion ControlSSH prompt command.