如何自动设置Watchkit应用程序目标的版本和内部版本号 [英] How to automatically set the version and build number of a Watchkit app target

查看:82
本文介绍了如何自动设置Watchkit应用程序目标的版本和内部版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Watchkit应用和扩展程序的版本和内部版本号(或版本和简短版本)必须设置为与包含应用程序相同的值。

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使用环境变量在构建时动态设置 Info.plist 中的应用程序版本。这也适用于Watchkit扩展,但不适用于Watchkit应用。

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.

我使用的环境变量必须在主应用和扩展的plist中提供 $ {} (对于变量 $ {VERSION} 我设置 VERSION )。

如果我对Watchkit应用程序执行相同的操作,它将获取字符串本身,而不是值。如果我提供美元&括号变量中没有数据。

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.

知道如何设置Watchkit应用程序的变量吗?

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

推荐答案

好吧,如果它不起作用,请使用运行脚本构建阶段。做这样的事情:

Well, if it doesn´t work like this, do it with a Run Script Build Phase. Do something like this:

#!/bin/sh
INFOPLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "writing to $INFOPLIST"
PLISTCMD="Set :CFBundleVersion $(git rev-list --all|wc -l)"
echo -n "$INFOPLIST" | xargs -0 /usr/libexec/PlistBuddy -c "$PLISTCMD"

我没有您的WatchKit应用程序的正确路径,因此您必须自己更改。

I don´t have the right paths for your WatchKit App, so you will have to change that yourself.

这篇关于如何自动设置Watchkit应用程序目标的版本和内部版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆