是否可以在 iPhone 上添加新的应用程序变量,类似于 ${EXECUTABLE_NAME}?

发布于 2024-08-24 13:22:27 字数 59 浏览 4 评论 0原文

我想在 info.plist 中引用我自己的变量构建设置文件。

这可能吗?有什么想法吗?

I'd like to reference my own variables in my info.plist & build settings files.

Is this possible? Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月野兔 2024-08-31 13:22:27

如果您通过右下角的“添加构建设置”按钮添加自定义构建设置,那么您应该能够在 info.plist 中使用 ${} 表单来引用这些变量的名称。

例如,我有一个名为“PJ_VERSION_EXTRA”的设置。在我的 Info.plist 中,我有:

<key>CFBundleShortVersionString</key>
<string>1.1${PJ_VERSION_EXTRA}</string>

在我的调试构建配置中,我将该设置定义为“-DEBUG”。这意味着当我在应用程序中显示版本字符串时,调试版本会识别自己。

If you add custom build settings via the 'add build setting' button in the bottom right, then you should be able to use the ${} form within your info.plist to reference the names of those variables.

For example, I have such a setting called 'PJ_VERSION_EXTRA'. In my Info.plist I have:

<key>CFBundleShortVersionString</key>
<string>1.1${PJ_VERSION_EXTRA}</string>

In my debug build configuration, I define that setting as '-DEBUG'. That means that when I show the version string in app, debug builds identify themselves.

陌若浮生 2024-08-31 13:22:27

我可以看到这样做有什么问题。

应该像向 info plist 添加条目一样简单,然后使用检索它

[[[NSBundle mainBundle] infoDictionary] objectForKey:myPlistKeyName];

I can see any problems with doing this.

Should be as simple as adding an entry to the info plist, and then retrieving it using

[[[NSBundle mainBundle] infoDictionary] objectForKey:myPlistKeyName];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文