在运行时查找Xcode构建方案名称 [英] Find the Xcode Build scheme name at run time

查看:114
本文介绍了在运行时查找Xcode构建方案名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法找出在运行时使用的方案?

Is there a way to find out the Scheme used at the run time ?

可能有更好的方法来做到这一点,我正在尝试设置使用Scheme名称访问环境(生产与开发)。

May be there is a better way to do this, I'm trying to set the Access Environment (Production vs Development) by using the Scheme name.

目前我使用 #define ENV @PROD App-Prefix.pch 文件中执行此操作,但在将pkg发送到Apple审核时有可能错过此项:(

Currently I use #define ENV @"PROD" in App-Prefix.pch file to do this, but there is a chance to miss this when sending pkg to apple for review :(

推荐答案

在模拟器或设备上运行应用程序时,设置了 DEBUG 变量,允许你可以从代码中使用它:

When running an app on the simulator or on your device, the DEBUG variable is set, allowing you to use it from your code:

#ifdef DEBUG
    // Something
#else
    // Something else
#endif

您可以从目标的构建中看到此变量设置:

You can see this variable from your target's build settings:

只要在 Debug 上设置了运行配置(产品 - >方案 - >编辑S. cheme),此变量将被设置:

As soon as the Run configuration is set on Debug (Product -> Scheme -> Edit Scheme), this variable will be set:

这篇关于在运行时查找Xcode构建方案名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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