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?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With