Xcode3 to Xcode4 code templates - xcode

can someone tell me how to convert code templates from xcode3 to xcode4?
I am reading article at http://iphonedevelopment.blogspot.com/2009/04/opengl-es-from-ground-up-part-2-look-at.html and author offers his OpenGLES code template, but I can't get it working in new xcode4, seems it have different format. Any suggestions?
Thanks in advance :)

I had the same problem, here is a list of the changes you need to do to make your xcode 3 templates works with xcode 4 :
First you have to move your templates to a new directory :
/YourUserDirectory/Library/Developer/Xcode/Templates/File Templates
(previously it was /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File Templates)
Then you need to :
rename your templates from "*.pbfiletemplate" to ".xctemplate"
rename class.h into ___FILEBASENAME___.h (the class.m can stay unchanged)
inside all of your files change «FILEBASENAMEASIDENTIFIER» into ___FILEBASENAMEASIDENTIFIER___
Additonaly all the key words like «FILENAME», «PROJECTNAME», need to be replaced by ___FILENAME___, ___PROJECTNAME___, etc
«OPTIONALHEADERIMPORTLINE» needs to be replaced by #import "___FILEBASENAME___.h"
Hope this helps,
Vincent

Until XCode 4 is finalised, there's probably not much point in this. However, you can side by side install XCode 3 and 4 and the XCode project format is compatible between them. Hence, I'd just install the template in XCode 3, create your new project(s), then open the results in XCode 4.

Related

Core Data in XCode 5 - installing manually and how?

It seems like that in the new version of XCode, Core Data is something i have to install manually. The check box that used to be there when i create a new project is gone.
I've searched to the end of the internet, finding no answer that seems to work in the new version of XCode. Can someone confirm my problem, and does someone have a solution for it? Thanks in advance.
Core Data checkbox is not available in all type of projects. If you try to create an empty project, the "Use core data" checkbox is still there (this was the same in xcode 4).
You can add core data manually by following this tutorial:
http://wiresareobsolete.com/wordpress/2009/12/adding-core-data-existing-iphone-projects/
you could create a new master-detail Xcode project (check the 'use core data' checkbox when creating) and just copy the code from there.
this is particularly helpful when combined with:
http://wiresareobsolete.com/2009/12/adding-core-data-existing-iphone-projects/

Storyboard vs XIB

I pretty much a rookie in XCODE and almost all of the tuts availible are explaining programming with XIB file with file's owner etc.. The newest version of XCODE only works with Storyboards, and I couldn't find anything which would help. So please, someone have to got a good tutorial I think. It would really help me out. Thanks
Sjors
when you create a project (File -> New -> Project -> select a template ex Single View..) remove the tag to "use storyboard" then you will get a xib file instead of a storyboard... now you can follow tutorials that use xib files :)
tip: if you follow old tutorials...allot of the time you also have to remove use automatic reference Counting because before Xcode 4 they all used manual method ( release etc)
Good luck!

Xcode file templates aren't created correctly

I'm having an issue with custom file templates in Xcode 4.
For example, with the cocos2d templates, when I try to make a new CCLayer file called GameLayer at my project root, it generates the files at .xctemplate/CCLayer/Gamelayer.h and .xctemplate/CCLayer/Gamelayer.m
The files seem to be correct but they're in the wrong place and they weren't added to the project.
I've tried this with the Cocos2d file templates as well as the Kiwi template from this post. Also any templates I try to create myself seem to have the same problem.
Turns out the issue was being caused by the fact that my ~/Libary/Developer/ was a symlink to a different drive to save space on my SSD. Whatever Xcode does when creating files from templates has problems with symlinks.

How do I use the Core Plot framework with Xcode 4?

How do I install the Core Plot framework into Xcode 4?
This older tutorial has instructions on how to install it for Xcode 3, but I could not find any similar instructions for Xcode 4. What do I need to do in order to use this framework with the newer Xcode?
I made one here that followed what I did:
http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html
Hope it helps!
It appears that I was unable to set up core plot project for the reason that I had corrupt example project which code I was using.
This are the steps:
open a project
add quartzcore framework
add other linker flags: -ObjC -all_load
add CorePlot.xcodeproj to existing project (drag and drop)
add sample class (from examples folder, drag and drop)
drag coreplot framework from added CorePlot.xcodeproj to linked frameworks
in IB
drop object and associate it to sample class
drop custom view to window and associate it vith CPTLayerHostingView
connect object and custom view
And hat is that (may sound complicated, but can be done in under a minute)
Steps can be taken in any order, except last few.
Everithing is very similar to instructions at: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application except the way it is done in xcode4 is actually easier.
Here are screenshoots that clarify the above steps: http://www.optimae.biz/data/stackoverflow/coreplot.pdf
Hope this will help someone.

Change templates in Xcode

How would I change the initial templates created by Xcode when creating a new Cocoa Class.
I am referring to the comments and class name created when using Xcode's new class wizard.
You wouldn't change the existing templates. In other words, don't modify anything under the /Developer hierarchy (or wherever you installed your developer tools).
Instead, clone the templates you want to have customized variants of. Then change their names and the information in them. Finally, put them in the appropriate location in your account's Library/Application Support folder, specifically:
File templates: ~/Library/Application Support/Developer/Shared/Xcode/File Templates/
Target templates: ~/Library/Application Support/Developer/Shared/Xcode/Target Templates/
Project templates: ~/Library/Application Support/Developer/Shared/Xcode/Project Templates/
That way they won't be overwritten when you install new developer tools, and you can tweak them to your heart's content.
Update
For newer versions of Xcode the updated path will be:
~/Library/Developer/Xcode/Templates/File Templates/Source
This may be useful for somebody:
As for XCode 6 to XCode 9 the file templates are in:
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source
Update:
As #carbo18 noted, it's proably better to create the directory ~/Library/Developer/Xcode/Templates/File Templates/Source and put your custom templates there. The best way may be to use as base one of the ones in /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates/Source
Xcode uses template files for file and project templates and does variable expansion in both at creation time.
Xcode 3.0 templates can be found in [Dev Installation]/Library/Xcode/, likely /Developer/Library/Xcode. If you want to modify these templates or add your own, use the following directories to save your new/modified templates so that they are not wiped out by future Developer Tool upgrades:
File templates:
~/Library/Developer/Shared/Xcode/File
Templates/
Target templates:
~/Library/Developer/Shared/Xcode/Target
Templates/
Project templates:
~/Library/Developer/Shared/Xcode/Project
Templates/
I think that you can also use the /Library/Developer/Shared/Xcode/[File|Target|Project] Templates/ directory for templates shared by all users.
If you just want to change the MyCompanyName in the templates, the following command line will do the trick:
defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ "ORGANIZATIONNAME" = "NewCompanyName";}'
A good tutorial on writing file templates is here [MacResearch.org].
In Xcode 4 and Xcode 5 the user file templates can be placed at:
~/Library/Developer/Xcode/Templates/[Category]
[Category] can be used to categorize your templates (choose a name of your choise)
If the folder doesn't exist already, create it!
As of Xcode 7
File templates: ~/Library/Developer/Xcode/Templates/File Templates
Project templates: ~/Library/Developer/Xcode/Templates/Project Templates
For example if I place a Empty Application.xctemplate in ~/Library/Developer/Xcode/Templates/Project Templates/Application
It will appear in the template dialog as
In xcode 5.0.1:
1.Go->Applications
2.right click "xcode" application
3.chose "Show Package Contents"
4.contents/Developer/Library/Xcode/Templates
If you are simply looking to change the Author Name and Organization see this answer.
It's much easier than modifying the templates.
For Xcode 4.4, none of the previously mentioned methods work. This gist provides a partial hacky solution. Please fork and enhance if you know a better way.
Right click on xCode and select Show Package contents, then go to contents/Developer/Library/Xcode/Templates. Here you can find the templates for all programming languages.
Here some visualization:
In XCode 4.5 right click on project, click Show File Inspector, then change Organization name in the file inspector's second tab (Project Document group)

Resources