How to brand your iOS Application

1. First you will need to have iOS developer account with Apple. 
  If you plan to release your application to Apple App Store, you will need the normal developer account. 
  If you plan to put the iOS application for enterprise deployment, you will need the enterprise account.

2. You need a Mac OS X 10.11/10.10/10.9/ machine with XCode installed. XCode is a free download from Mac App Store.
  The current iOS application was built with XCode 6.4. It is recommended you download XCode from iOS developer download portal
  instead of download the XCode 7 from Mac AppStore. 

3. From the XCode, you can connect to your iOS developer account, download the certificate and create the mobile 
provision profile. Assuming your main app id is com.acme.cloudfile
    3.1 In App ID section you need to create 4 app ids
      com.acme.cloudfile
      com.acme.cloudfile.docprovider
      com.acme.cloudfile.docproviderFileProvider
      com.acme.cloudfile.actionext
   
    3.2 create an app group
      group.com.acme.cloudfile
  
    3.3 Assign the group to each App ID, so enable Application Group capability for each APP ID and assign the group to them.

  3.4 create distribution mobile profile 
     each application id needs a mobile provision profile. so you will create 4 of them and download them to the input_dir
        actionext.mobileprovision
        docprovider.mobileprovision
        fileprovider.mobileprovision
        main.mobileprovision

summary: after step 1,2,3 you will have the certificate ready on your Mac OS X machine, in the keychain. You also 
have the mobile provision file ready and downloaded. The mobile provision file needs to be placed in the inputdir so it can feed into the 
transform script.

4. there is an inputdir_appstore that contains the information to rebrand the iOS application for Apple AppStore deployment. You will need to prepare the inputdir_appstore following the examples. 
  
  4.1 - change the parameters in the common.sh to match your iOS product.
      ACCESSPOINT: this is your CentreStack server's external DNS name, make sure the HTTPS is ready before you try iOS application because by default it connects via HTTPS
	 
      PRODUCTNAME : Product Name
	 
      PRODUCTNAMENOS: Product Name without any space, all in one word.
	 
      BUNDLEID: The bundle id will need to match the application ID you created in the iOS developer program
	 
      PACKAGEID: Same as above
	 
      IOSPACKAGEID: Same as above.
	 
      FULLIOSID: the team prefix and a dot and the BUNDLEID together.
	 
      CERTIFICATENAME: your certificate to sign the iOS Application.
    
      IOSTEAMID: the team id in the iOS developer account
    
      IOSGROUPID: the group id used by all the app ids. 
	 
  4.2 - various bitmap files, replace the bitmap files, make sure you have the same resolution as the samples.
         4.2.1 - bitmap files directly inside inputdir folder (or inputdir_appstore folder).
         4.2.2 - Images.xcassets under this folder, there are two sub folders
                  AppIcon.appiconset - these are the app icons
		              LaunchImage.launchimage - these are the splash screens
  4.3 all 4 mobile provision files
  
  
5. the ipa file. The ipa file is the original iOS application package. 

6. transform_ios.sh
   bash -x transform_ios.sh input_dir iosapp.ipa
   
You can open a Mac Terminal and then run the script inside the Mac Terminal.   
How it works.
  The transform_ios.sh will open up the original iOS package in the ipa file, take bitmap files and input parameters
  from the inputdir folder and replace those in the ipa file.
  
  At the end, it will package the ipa file back into one package, sign it with your own certificate. 
  and the resigned package becomes your own branded package, with access point hard-coded to your access point.

NOTE:
   If you need to upload the transform multiple times to AppStore after a few rounds of beta testing to test out the artworks. 
   Because Apple doesn't allow duplicated version number, so if you updated the artworks and need to upload again, 

   you need to add these two lines to the transform_appstore.sh and everytime you upload, you update the version string such as 6.332, 6.333 and etc.

$PLISTBUDDY -c "Set :CFBundleShortVersionString '6.331.01'" "$PLIST_FILE"
$PLISTBUDDY -c "Set :CFBundleVersion '6.331'" "$PLIST_FILE"


For example, here is an example section of the transform_appstore.sh after updated to version 6.331

$PLISTBUDDY -c "Set :CFBundleIdentifier '$IOSPACKAGEID'" "$PLIST_FILE"
$PLISTBUDDY -c "Set :CFBundleName '$PRODUCTNAMENOS'" "$PLIST_FILE"
$PLISTBUDDY -c "Set :CFBundleDisplayName '$PRODUCTNAME'" "$PLIST_FILE"

$PLISTBUDDY -c "Set :CFBundleShortVersionString '6.331.01'" "$PLIST_FILE"
$PLISTBUDDY -c "Set :CFBundleVersion '6.331'" "$PLIST_FILE"

$PLISTBUDDY -c "Set :CSAccessPoint 'https://$ACCESSPOINT/namespace/n.svc/'" "$PLIST_FILE"
$PLISTBUDDY -c "Set :CSCopyright '$COPYRIGHTSTR'" "$PLIST_FILE"

TROUBLESHOOTING:
    In some system, the bash shell only take UNIX style text file (with Line-Feed at the end, e.g. \n). The current shell script 
    such as common.sh and transform_blah.sh are in Mac text file format, which may have Carriage Return e.g. \r at the end of line.
    If this is the case, use perl or other tool to transform the script to UNIX text line ending will solve the problem.
  
RELEASE NOTE:

   7.8.36272 - fix offline issue and update offline bitmaps