Let the same iPhone project Compile two versions-official and Lite
Original blog address:Add Lite version to the same iPhone Project
Add Lite version to the same iPhone Project (2)
As a basic promotion method, it is necessary to reduce key functions and add the lite version of AdMob or IAD.
But for Lite to simply open another project and constantly synchronize code in lite and the full version of the project, it is certainly not good. The best way is to add a target to the same xcode project.
The procedure is as follows:
1. Find the target node in the groups & files window on the left.
2. Right-click the original target and select duplicate.
3. Rename the copied target to yourappname-lite.
(Target name I hide first)
4. Add yourappname-Info copy. plist under the resources directory under the project and rename it to the yourappname-lite-info.plist
5. Open the project menu and set active target to Lite.
6. Select the following edit Active Target "***** name-Lite" menu
7. In the open form, modify the following values:
7.1 product name --> yourappname-Lite
7.2 info. plist file --> yourappname-lite-Info.plist
7.3 preprocess macros --> lite_version)
8. After completing the task, turn xcode off and open the project. This step must be done to see if it can be compiled and run the second application in the simulator. If not, as prompted, you may need to copy the hosts file and restart the xocde project every time.
9. Run the following code to provide different functions for different versions:
# Ifdefined (lite_version) uialertview
* Alertversion
= [[Uialertview alloc]
Initwithtitle: Nil
Message: @ "this is lite version" delegate: Nil
Cancelbuttontitle: @ "cancel"
Otherbuttontitles: Nil];
[Alertversion show];
[Alertversion release];
# Endif
If you want to make a more thorough distinction between the two versions, for example, the files in the two version packages are different, and the libraries loaded by the two versions are different (for example, the official version does not need to load the AdMob module ), at the beginning of the program, the entry is different. What should I do?
In the previous set, we duplicate out a XX-lite target and also copy out a xx-lite-info.plist (note, plist and referenced external. file a does not need to be included in the copy bundle Resources in the target. Otherwise, some inexplicable warnning occurs during compilation. If the package is included, expand your target in the groups & files window on the left and find the target to be deleted.) Open the plist file, which contains "Main NIB file base name" and change the value, for example, mainwindow-lite. In this way, when the program starts, load is not the original mainwindow, but another MainWindows-Lite.xib file. Copy or manually copy the original mainwindows and xxxappdelegate. m, and change the command to the corresponding XX-lite. Open the MainWindows-Lite.xib and place the xxx
The type of the app delegate object is changed to xxxappdelegate_lite. In this way, the app initially loads appdelegate. Then modify your appdelegate_lite.m, such as adding the AdMob function. If the view also needs to be changed, change the viewcontroller to your own. Anyway, the entry from XIB to the back-end code, you can control it. Or in the target interface, do not need different versions. file ,. m Files and images are all cleaned up. In this way, the size of the compiled versions will be the intersection of the two versions.