• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
About Xcode Project Templates [was: How do start from scratch?]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About Xcode Project Templates [was: How do start from scratch?]


  • Subject: About Xcode Project Templates [was: How do start from scratch?]
  • From: Chris Espinosa <email@hidden>
  • Date: Thu, 16 Aug 2007 17:06:28 -0700

On Aug 15, 2007, at 3:57 AM, Bob Ueland wrote:

When I start a new project named Test2 and choose main.m I get a non empty file that looks like this

//
//  main.m
//  Test2
//
//  Created by Bob Ueland on 8/15/07.
//  Copyright __MyCompanyName__ 2007. All rights reserved.
//

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
    return NSApplicationMain(argc,  (const char **) argv);
}

But I want to start with an empty file, or a default of my own choosing and not the one that Xcode provides. Is there any way to do that.

Somebody pointed you to a method to modify the Xcode project templates, but with inadequate introduction that is a delicate proposition.

An Xcode project template is a specially modified Xcode project.  It has an additional plist file that contains lists of files that should get renamed when the project is created from the template, and a list of files whose contents need to be macro-expanded when the project is created from the template

Basically, the way Xcode project template instantiation works is as follows:

1) Xcode reads the TemplateInfo.plist in the template bundle's .xcodeproject wrapper.
2) All files that aren't listed in the FilesToRename or FilesToMacroExpand arrays in the plist are copied unaltered to the designated project directory.
3) All files in the FilesToRename list are copied to the designated project directory and renamed accordingly.  Each item in the list is a pair of (original file name) = (replacement file name).  The replacement file name usually has a macro like «PROJECTNAME», which is replaced with the project name given by the user.
4) All files in the FilesToMacroExpand list are then run through a grep-like process that replaces macros enclosed in « » characters with expanded equivalents.  Below is the list of candidate macros.  The ASIDENTIFIER macros are munged to start with alpha characters and not include spaces. The ASXML versions are escaped as XML, so they can be used in the plist file, for example. The UUID is unique for each file expanded, so you can uniquify file names if needed.

 DATE
 TIME
 USERNAME
 FULLUSERNAME
 ORGANIZATIONNAME
 YEAR
 UUID
 UUIDASIDENTIFIER
 FILENAME
 FILEBASENAME
 FILEBASENAMEASIDENTIFIER
 FILEBASENAMEASXML
 FILEEXTENSION
 PROJECTNAME
 PROJECTNAMEASIDENTIFIER
 PROJECTNAMEASXML
 PRODUCTNAME
 PRODUCTNAMEASIDENTIFIER
 PRODUCTNAMEASXML
 TARGETNAME
 TARGETNAMEASIDENTIFIER
 TARGETNAMEASXML

Here's the really important part.  The project files are encoded as UTF-8, but the macro delimiter« and » are encoded in MacRoman.   This is guaranteed to confuse you and most text editors.  This is done to eliminate the possibility that real content in the project files or sources will be mistaken for template macros.  Allowing your text editor (Xcode or TextMate) to set the file encoding to UTF-8 will cause the macro expansion to fail, and the templates will create corrupted products that don't work.

Better, more complete instructions can be found at

http://briksoftware.com/blog/?p=28

There's also

http://harnly.net/2007/software/xcode-template-maker/xcode-template-maker-10/

a Ruby script that templatizes any existing project.


The short answer to your question, then, would be as follows:

1) Make a copy of the Cocoa Application template

2) Edit its "main.m" file to remove the content so you start with an empty project

3) Edit the Description in the TemplateInfo.plist so you can distinguish your version from the original

And that should do it.

Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How do start from scratch? (From: Bob Ueland <email@hidden>)

  • Prev by Date: Re: Custom data formatter for pthread_mutex_t?
  • Next by Date: Re: Custom data formatter for pthread_mutex_t?
  • Previous by thread: Re: How do start from scratch?
  • Next by thread: Re: How do start from scratch?
  • Index(es):
    • Date
    • Thread