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

查看:34
本文介绍了如何自动设置 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.

我使用环境变量在构建时动态设置 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} 我设置了 版本).
如果我对 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?

推荐答案

好吧,如果它不能像这样工作,请使用 Run Script Build Phase 来完成.做这样的事情:

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天全站免登陆