Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically set the version and build number of a Watchkit app target

The version and build number (or version and short version) of a Watchkit app and extension have to be set to the same value as the containing app.

I use environment variables to set the apps version in the Info.plist dynamically at build time. That also works fine for the Watchkit extension, but not for the Watchkit app.

The environment variables I use have to be provided in the plist for the main app and extension without ${} (for variable ${VERSION} I set VERSION).
if I do the same for the Watchkit app, it is taking the string itself, not the value. If I provide it with dollar & brackets there is no data in the variable.

Any idea how to set the variables for the Watchkit app?

like image 901
dogsgod Avatar asked Apr 01 '15 20:04

dogsgod


People also ask

What is a WatchKit extension?

Understand the WatchKit app and WatchKit extension An app bundle that contains your watchOS app's storyboard and any assets used by the storyboard. WatchKit Extension. An extension that contains your watchOS app's code.

How do you make a watch app in Xcode?

To create a watchOS app, start by adding a watchOS target to the project. Xcode adds groups and files for the watchOS app to your project, along with the schemes needed to build and run the app. Choose File > New > Target.


1 Answers

I use this to update all the targets:

#!/bin/bash buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE" /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$SRCROOT/Great WatchKit App/Info.plist" 
like image 199
Thomas Kekeisen Avatar answered Sep 28 '22 06:09

Thomas Kekeisen