Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone Build Configuration Enabling Features

Question about best practices.

Is there a way to programmatically detect whether the app is being compiled for an AdHoc configuration, and, if so, enable a feature in the app?

For example, I am thinking of enabling a switch between beta and prod environment given depending on whether the app is an an AdHoc vs. Release configuration.

This way we can give testers the ability to switch between server environments in the same app.

Could do this with a #define but thought I would ask if there is a more elegant way to do it by detecting the current configuration.

like image 916
Genericrich Avatar asked Jul 10 '09 14:07

Genericrich


People also ask

How do I enable developer options on my Iphone?

As indicated by the alert, to enable Developer Mode go to Settings > Privacy & Security on the iOS device. Scroll down to the Developer Mode list item and navigate into it. To toggle Developer mode, use the “Developer Mode” switch. Tap the switch to enable Developer Mode.

What is enable capabilities in provisioning profile?

Try following things : Turn on/off Associated Domains in Xcode capabilities section. Create provisioning profile again. Go to developer.apple.com and check capabilities under your app id.

How do I enable capabilities in Xcode?

In the toolbar, click the Library button (+) to open the Capabilities library. Alternatively, click + Capability to the left of the build configurations, or choose Editor > Add Capability.

What are build settings?

A build setting is a variable that contains information about how a particular aspect of a product's build process should be performed. For example, the information in a build setting can specify which options Xcode passes to the compiler. You can specify build settings at the project or target level.


1 Answers

You can set a custom define in your configuration using the Preprocessor Macros setting in your project or target info. This works just as if you had #define'd a variable in your source.

In your release configuration, set GCC_PREPROCESSOR_DEFINITIONS ("Preprocessor Macros") to MYAPP_RELEASE=1. You can then use this code to change functionality at compile-time:

#ifdef MYAPP_RELEASE
    NSString *title = @"Release Version";
#else
    NSString *title = @"Beta Version";
#endif
like image 66
pix0r Avatar answered Sep 19 '22 07:09

pix0r