XCode 4: CoreData Tab Bar Application template
Hi,
When apples released its XCode application, it never added CoreData support to the Tab Bar Application template… although, in my case I usually want this feature. So… now I need to create a Tab Bar Application and a Window-based Application and copy the CoreData stuff from one to the other.
This is, off course, very annoying. So, what I want is to adapt the current templates to support even Core Data… “F*cking hell, this is most likely a mess to get working”… but I was wrong.
It is much easier to do in XCode 4 then it is in XCode 3.x. I am not going to cover XCode 3 cause I have gone over to the dark side (= XCode 4).
What I am going to do is adapt the current Tab Bar Application template to show the “Use Core Data” checkbox when creating a new project. I am not adding any unit tests or any functionality to add data to the core data (SQLlite) DB. Just making sure the functionality exists.
To get this checkbox in XCode 4 when creating a Tab Bar Application, have to add 1 line to the template file. I assume you have installed XCode using the default location. If so, open:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project\ Templates/Application/Tab\ Bar\ Application.xctemplate
No, in this directory you will find a file called “TemplateInfo.plist”. Open this file.
When opened, add the following line on row 8 (just below <string>com.apple.dt.unit.cocoaTouchFamiliedApplication</string>):
<string>com.apple.dt.unit.coreDataCocoaTouchApplication</string>
Save the file and restart XCode… it should now be working. Now you can create Tab Bar Application with Core Data from the template. Voila!
Best regards,
Paul Peelen
May 19th, 2011 at 0:56
Nice! This saved me a lot of time.
May 20th, 2011 at 11:30
Thanks! It worked. That was so stupid from Apple not to include Core Data in Tab Bar Application Template
May 20th, 2011 at 21:11
Glad to hear it is of use
May 29th, 2011 at 0:06
You are a real star. A simple fix but a huge benefit. You deserve a medal. Thanks a lot
August 17th, 2011 at 6:56
hi Paul,
Do u have any other code like the one u have given for Heallo WOrld program, if so can u publish those
October 1st, 2011 at 22:33
saved me a headache and a lot of redbull.. thx alot.
October 1st, 2011 at 22:34
yw
October 30th, 2011 at 13:41
Amazing, thank you!
April 9th, 2012 at 15:33
Hi, I use XCode 4.3.2. and I have looked everywhere I cannot find a folder with the name.In Developer there is only a Documentation folder not a Library Folder. Where could I find the predefined templates instead?
April 10th, 2012 at 13:35
The latest XCode has moved this from the /Developer folder to the /Applications folder. Gå to the XCode.app file and right click it. Choose “Show content” and browse there. Just from the top of my head I cannot remember where it is located, but will look it up tonight and update the post (or write a new one).
June 6th, 2012 at 4:46
Use “/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/Application/Tabbed Application.xctemplate” and don’t forget to use sudo to edit file (it’s readonly by default)
June 15th, 2012 at 8:36
Hi there I found the file but how do you edit it?
Also the com.apple.dt.unit.coreDataCocoaTouchApplication
is not there anymore?
Cheers
July 19th, 2012 at 7:22
Thank you very much!
July 24th, 2012 at 10:27
Fantastic tip! Works across the board with the project templates. Thanks much.
September 4th, 2012 at 0:12
I dont know why for me is not working.. any Tips?
Thanks
September 15th, 2012 at 19:04
You’ll have to give me some more info… what is the problem?