gpt4 book ai didi

objective-c - 在 iOS App info.plist 中使用预处理器定义

转载 作者:技术小花猫 更新时间:2023-10-29 10:20:28 25 4
gpt4 key购买 nike

我有一个 iOS 应用程序,它使用 SSO 和 Facebook 作为让你的应用程序与 Facebook 的 SSO 一起工作的一部分,你必须在 info.plist 中指定 FacebookAppId 和回调 url。我有 2 个不同的 Facebook 组,一个用于测试,一个用于生产。我希望能够根据预处理器指令设置上面指定的两个键的值。

在我的 MessageBomb-Prefix.pch 中,我有以下内容,效果很好:

#ifdef TEST
//Development environments
#define PARSE_APP_ID "dev parse app id"
#define PARSE_CLIENT_ID "dev parse client id"
#define FB_APP_ID "dev facebook id"
#else
//Production environments
#define PARSE_APP_ID "prod parse app id"
#define PARSE_CLIENT_ID "prod parse client id"
#define FB_APP_ID "prod facebook id"
#endif

但是在我的 info.plist 中,我已经完成了以下操作,但它似乎不起作用:

<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fb${FB_APP_ID}</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>${FB_APP_ID}</string>

我什至可以做我想做的事吗?我已将项目设置为预处理 info.plist。

谢谢彼得

最佳答案

如果您进入build设置,您可以将 Preprocess Info.plist File 设置为 YES,然后将 Info.plist Preprocessor Prefix File 设置为您使用 #define 指令放置在项目中的 .h 文件。

例如,如果我向我的 Info.plist 文件添加一个键:testKey,值为 TEST_VALUE。然后我将 test.h 放在我的项目中:

#define TEST_VALUE hello_world

然后我将 Preprocess Info.plist File 设置为 YES 并将 Info.plist Preprocessor Prefix File 设置为 test.h

检索到时,该键的值现在是“hello_world”。如果您经常更改宏的值,您可能会发现您需要执行 Product/Clean 才能看到更改,因为 XCode 似乎缓存了编译后的值。

关于objective-c - 在 iOS App info.plist 中使用预处理器定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14206621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com