4

     How does one go about creating a project template in Xcode 8.2.1? I'm asking this because of how I would like to use such a project template as the basis for the many Xcode projects that I will most likely create in the process of learning how to program in C++ from Bjarne Stroustrup's Programming: Principles and Practices Using C++, Second Edition. Mr. Stroustrup provides his readers with several header files, which I have copied into a GitHub repository, on the book's rudimentary web site, and I would like to figure out how to link them into Xcode's build system.
     Someone created a makefile for use with the Darwin base of OS X, but I'd rather be able to use Xcode so that I can learn how to do so while I am learning C++ so that I know how to use it for later projects. I don't know whether I should use this makefile or not, but Apple does provide instructions on 'Building Makefile Projects with Xcode', so should I use those? I've also noticed that other people have similarly asked questions about how to create project templates for older versions of Xcode here, here, here, and here. Would any of the material from these Stack Overflow posts help my prospective answerer or answerers by providing them with some source material for their research?

Community
  • 1
  • 1
RandomDSdevel
  • 431
  • 6
  • 17
  • Is anybody going to take this question for me, or do I have to go fishing for answers? Here, fishy, fishy, fishy… – RandomDSdevel Oct 07 '14 at 17:11
  • Me, fishing with an Old Rod: ". . . . ." – RandomDSdevel Oct 15 '14 at 18:02
  • Aw! "Not even a nibble…" – RandomDSdevel Oct 15 '14 at 18:04
  • Should I go and get a Good Rod and try fishing for answers again? (Oh, wait…how exactly do I _advertise_ this question so that people can _find_ it?) – RandomDSdevel Oct 16 '14 at 15:33
  • Maybe I should point somebody on the Apple Developer Forums to this question so they can answer it for me? – RandomDSdevel Oct 16 '14 at 19:15
  • Well, I tried that [here](https://devforums.apple.com/thread/250781), but, so far, nobody has answered this question either here _or_ there. Maybe I should recategorize it? – RandomDSdevel Oct 18 '14 at 19:11
  • Should have looked before I leaped: apparently, you're not supposed to post links to questioos on the Apple Developer Forums, so I…kinda got put on probation (evidence [here](https://devforums.apple.com/message/1061674#1061674)) — yeah, I know: both 'ouch' and 'oops!' I still need help _here_, though…now, just _how_ am I supposed to deal with that? – RandomDSdevel Oct 20 '14 at 17:22
  • I'd offer this question as a bounty, but it both appears that I don't have enough reputation points in order to do that and happens that I _probably_ won't start offering bounties until 50 points is no longer an uncomfortable amount of them to give away. – RandomDSdevel Oct 25 '14 at 22:52
  • Am I the only one who's been looking at this page, or is somebody working on answering this question? – RandomDSdevel Nov 03 '14 at 17:12
  • Since this question has to do with one of Bjarne Stroustup's books, I shared it with him via Twitter. He probably won't get around to taking a look at it, though; he's likely to be very busy since he's the head of the ISO C++ working group. Oh, well; does anybody else have any idea how to help me with this? – RandomDSdevel Nov 08 '14 at 22:37
  • And I _still_ don't have an answer! In _that_ case, I'd better go get my Super Rod…and start fishing for help again! (I think I've drunk too much [Chuckola Cola](http://www.mariowiki.com/Chuckola_Cola)…) – RandomDSdevel Dec 04 '14 at 21:26
  • For anybody who's still interested in how this question gets answered, I've filed a bug (number 19170664) in [Apple's 'Bug Report' tool](http://bugreport.apple.com/) (an [Apple Developer Connection](http://developer.apple.com/) account and/or [Apple ID](https://en.wikipedia.org/wiki/Apple_ID) is, however, required to view that bug report.) – RandomDSdevel Jan 18 '15 at 17:33
  • I've actually got a lead on a possible answer to this question now since I've been able to cobble [something](https://github.com/RandomDSdevel/Xcode-Templates/tree/master/Project%20Templates/Mac/Application/Default%20Template%20for%20'Programming:%20%20Principles%20and%20Practice%20Using%20C%2B%2B'.xctemplate) together that _mostly_ works, but I don't yet know if what I've learned is enough for me to formulate my own answer here, so I'll defer that until later for now. – RandomDSdevel May 11 '17 at 00:45

3 Answers3

2

There seems to be an amazing lack of information on this topic. As far as I know templates have not changed materially since Xcode 4. Templates I made for it still work on Xcode 6.

Like one of the commenters above, I used this post to get started.

I am only developing for macOS (OS X), not iOS.

I also made some file templates, which are much easier; maybe try making one or two of them first. Macro names in file templates do need triple underscores at each end.

James Risner
  • 5,451
  • 11
  • 25
  • 47
  • Xcode's template mechanism may not have changed since version 4, but some of the IDE's UI elements have _definitely_ moved around since that release. _That_ is why I asked this question in the first place: I wanted a step-by-step walkthrough of _exactly_ how to put a template together to accomplish the task which I had set out to do before I asked this question. I've tried using some of the documentation that's been linked to on this question's page, but I seem to be doing _something_ wrong, 'cause my template's not showing up in Xcode's 'New Project' window. … – RandomDSdevel Mar 23 '15 at 19:52
  • …Maybe I should put a link to what I've got so far at the bottom of my original question? – RandomDSdevel Mar 23 '15 at 19:53
  • What do you think? Should I do what I proposed to do in my previous comments? – RandomDSdevel Mar 28 '15 at 19:49
1

In XCode 7.3.1 (and maybe above versions too), you just need to go to Application folder, find XCode and right click on it and pick "Show Package Contents". Then, make your way to:

Contents/Developer/Library/XCode/Templates/..

In here you will find more folders which you mess with. Basically they are the items that appear when you goto XCode->File->New File... Becareful though, cause this is part of the XCode application. Not sure what will happen if you edit or add files wrongly.

ps. You also should quit XCode before opening the package contents.

Hope that helps.

GeneCode
  • 7,545
  • 8
  • 50
  • 85
-1

http://robnapier.net/project-templates This link helps me much,since the macros did not change. I want to custom a project template. But no automatic tools could be found,I make one my self.

first,drag a template to my desktop from Path below. Xcode ▸ Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ Developer ▸ Library ▸ Xcode ▸ Templates ▸ Project Templates ( I use the empty template from the link: https://github.com/tobymao/EmptyApplication.xctemplate)

then,add your files to the *.xctemplate directory . And edit plist file. two items needs: Definitions which type should be Dictionary;Nodes which type is Array; In Definitions for each added file define a correspond Dictionary (name should be filename or filename had PROJECTNAMEASINDENTIFIER as prefix) ,which has key "Path" hold your files' path; In Nodes ,add all the items defined in Definitions. and, if you had your filename has projectname as prefix ,you should change content of your class files,change the classnames to macro FILEBASENAMEASIDENTIFIER at last , move your template directory back, and don't forget to change the identifier in plist.

Ray
  • 1
  • sorry, I only made a simple test .several flaws in answer.\n First macros should have three underlines in the head and three in the back .your file name, had better have ___PROJECTNAMEASIDENTIFIER___ as prefix,and items' value in Nodes,items'name in Definitions should better be the same as filename . this should be more convenient ,considering there are many different names in one class file,your change every classname in your file content to has ___PROJECTNAMEASIDENTIFIER___ as prefix. – Ray Feb 04 '15 at 10:27
  • 1
    I asked for information on how to create project templates using Xcode _6.1.1_. The article you reference is from May 20th, 2009, at which time the latest version of Xcode was '3.1.2.' If you could find and post step-by-step instructions on how to create project templates in Xcode 6.1.1, then I would greatly appreciate your help. Your current post, however, is worthy of another down-vote which I cannot give due to lack of permissions. – RandomDSdevel Feb 04 '15 at 20:06
  • sorry ,I came here want to solve problem.Today I found some materials.maybe useful to you ,Since the templateinfo.plist first appear in xcode4.http://blog.boreal-kiss.net/2011/03/11/a-minimal-project-template-for-xcode-4/ I followed the instructions in that link and build one temple which can work with my xcode 6.1.1 – Ray Feb 05 '15 at 06:50
  • 1
    That link also leads to content relevant to creating project templates out of a _specific_ other one (``com.apple.t.unit.windowBasedApplication``, in this case) for Xcode _4_.x, not Xcode _6_.x, and was, I believe, also referenced in my original question as being out of date. Please edit your original answer to clarify how you were able to follow instructions intended to work under Xcode 4.x and get a project template compatible with Xcode 6.1.1. – RandomDSdevel Feb 11 '15 at 16:53