When starting a new project with XCode, you are often given the option to add CoreData to your project. I build almost every project using CoreData in some way (given most of my apps are business related, there needs to be some form of caching or data retention).
However, for some reason, the option to add CoreData to the TabViewController app is missing in XCode. Which is strange as TabViewController is probably the most versatile of the options available.
Manually adding in CoreData support is an option, but it’s time consuming and I’ve found its easier to change the project template to allow CoreData.
Here’s how to do it:
1. Open up Terminal
2. Type in the following command:
bash$ cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Application/Tab Bar Application.xctemplate/
This will take you to the directory where the TabBarTemplate XML file is
3. Open up a text editor (use vim or nano, I use nano here)
bash$ nano TemplateInfo.plist
Add this line into the top of the file into the array under the “Ancestors” key:
The top of your XML file should now look like this:
<!--?xml version="1.0" encoding="UTF-8"?--> Ancestors com.apple.dt.unit.cocoaTouchFamiliedApplication com.apple.dt.unit.coreDataCocoaTouchApplication ............
4. Hit ctrl-X to save, then Y to confirm and you are done.
The next time you boot up XCode and try for the TabBar template you should see the option to add CoreData.