Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent concept in iOS development to an Android product flavor?

Tags:

xcode

ios

We utilize product flavors in Android to keep the same code under source control, but conditionally target the endpoints to dev/qa/production servers based on the flavor selected. For reference:

http://tools.android.com/tech-docs/new-build-system/build-system-concepts

For example, when we want to test a new endpoint in the "dev" environment we can have a file in src/dev/res/values/endpoints.xml that has an entry that's the XML equivalent of urlbase = https://dev-endpoint.ourserver.com/v3/, and build using the "dev" product flavor to build an APK pointed to our dev environment.

Is there an equivalent concept for iOS development?

like image 359
Joe Avatar asked Apr 14 '15 21:04

Joe


People also ask

Is there something like Android Studio for iOS?

The Xcode IDE is at the center of the Apple development experience. Tightly integrated with the Cocoa and Cocoa Touch frameworks, Xcode is an incredibly productive environment for building amazing apps for Mac, iPhone, and iPad. Android Studio and Xcode can be categorized as "Integrated Development Environment" tools.

What is a flavor in Android?

Product flavours lets you create multiple variants of an android app while using a single codebase. To create product flavours you need to define rules in the build.

What is a build type and a product flavor in Android?

Build Type applies different build and packaging settings. An example of build types are “Debug” and “Release”. Product Flavors specify different features and device requirements, such as custom source code, resources, and minimum API levels.

How can I get Flavour in Android?

Now you have three different flavors of the same application to change the build variant, Android Studio uses select Build > select Build Variant in the menu bar (or click Build Variants within the windows bar), then select a build variant from the menu.


1 Answers

Yes. If you select your project in the left bar, then select your Project under Project in the inner left bar, and select Info on the inner top bar, you will see a section labeled Configurations. You can configurations here.

Then select your Target on the inner left bar and select Build Settings on the inner top bar. Search for "preproc" in the search box. Under the Apple LLVM - Preprocessing section, you can add custom Preprocessor Macros. For your configurations, define something like "DEV=1", etc.

Now in your code you can say #if DEV, etc.

Many projects use AFNetworking to talk to their back end. You can set the baseURL for your AFHTTPSessionManager subclass, or whatever, based on the defines.

like image 105
i_am_jorf Avatar answered Jan 01 '23 11:01

i_am_jorf