开发者

Two iPhone Apps with same code base

I want to create two iphone apps with very similar code base. The only dif开发者_开发技巧ferences will be some settings and the UI skin. Instead of creating two xcode project and copy the all the code over. Is there a better way to set this up? for better maintainability? 95% of the code are the same.


Yes, you can do that. You should not create two XCODE projects as you are already guessing.

For differences in your code for each version, you can use C preprocessor directives. #ifdef and related commands.

For differences in the UI, you can create multiple targets, each one using different XIB files if you want.

For settings differences, you can also create multiple targets, each one using different .info files.

Check out this and this blog entries on using multiple targets within XCODE.


Add two targets to the same project. Give them different Info.plists (see the "Info.plist" build setting; they do not have to be added to the target); an easy way is to do FooApp-Info.plist and BarApp-Info.plist.

Put "skinnable" resources in app-specific directories, which you add to Xcode. "Get Info" on the directory in Xcode, click "targets", and make sure that only the correct target includes each set of resources).

(You could give files for different "skins" different filenames, but that can easily become unmanageable, and doesn't work for stuff like Default.png which has a fixed name.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜