thatidiotguy
thatidiotguy

Reputation: 9011

Different Application Name For Development/Release Build

I have an iOS application that has "sysadmin" only features when in the development build which are removed for the release build.

What is the easiest way to have two builds on our testing devices in house, one in development mode, and one in release mode that have different names on the iOS home screen?

The current situation is that when we want to test the release build, I have to manually rebuild it for each device. When we want to switch back, I have to once again manually rebuild the application.

Upvotes: 1

Views: 451

Answers (2)

Eimantas
Eimantas

Reputation: 49354

As LoVo mentioned - you will need different app-identifiers and bundle display names. Here's how I would approach the problem:

  1. In Project's build settings set the following values:

    • Preprocess Info.plist File - Yes
    • Info.plist Preprocessor Prefix File - InfoPlist_proc.h
  2. Add the header generation script to your Xcode project.

The script in ruby should look like this:

#!/usr/bin/env ruby

# build type is going to be passed 
build_type = ENV["CONFIGURATION"]

proc_header_path = File.join(ENV["SRCROOT"], "InfoPlist_proc.h")
File.open(proc_header_path, "w+") do |f|
    f.write("#define BUNDLE_IDENTIFIER com.company.app.#{ build_type.downcase }\n")
    f.write("#define BUNDLE_DISPLAY_NAME \"My App #{ build_type.downcase }\"")
end
  1. Now in the "Build" stage of your scheme (Cmd+Shift+,) create "Run Script" pre-action:

"Run Script" pre-action

  1. Add execution permissions to previously created script ($ chmod a+x script.rb) and set it to run from your pre-build script run phase:

Run ruby script in build's pre-action

  1. Finally in your current Info.plist file change the bundle identifier and display name values with preprocessor definitions:

Preprocessor defines as values in Info.plist file

Now each time you build your app, the InfoPlist_proc.h file will be regenerated. This has a drawback though: to change your app's bundle identifier or name you would have to edit the script, not the Info.plist

But it also gives an advantage: you can inject the bundle version and short version string from what your cvs gives you. I usually use git rev-list --count --all for bundle version and git describe --tags --first-parent for short version string.

Hope this helps.

Upvotes: 2

LoVo
LoVo

Reputation: 2083

Set different App-Identifiers and Bundle Display Names

Upvotes: 1

Related Questions