royclarkson / xcode-templates

Create custom Xcode templates
Other
61 stars 19 forks source link

'Cocoa Touch Class' template #6

Open J-Swift opened 8 years ago

J-Swift commented 8 years ago

Hi! I've used custom templates I generated for a while now (at least a year or two), but just got a new computer and didn't carry over what I generated. When I went through to regenerate templates, I noticed that the script isn't able to make available a handful of templates that we generate.

I'm specifically concerned with the 'Cocoa Touch Class' option when generating a new file, but the others might be useful too. I attempted to track down the root cause, but didn't see anything that might be affecting this. The templates are generated just fine, it just seems that Xcode 7.2.1 doesn't seem to want to show the template, probably due to plist issues? The 'Cocoa Touch Class' plist is so minimal, that I can't think of what could be going wrong.

Directory listings:

$ ls /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/
C File.xctemplate
C++ File.xctemplate
Cocoa Class.xctemplate
Header File.xctemplate
Objective-C File.xctemplate
Objective-C new superclass.xctemplate
Playground Page.xctemplate
Playground with Platform Choice.xctemplate
Playground.xctemplate
Sources Folder Swift File.xctemplate
Swift File.xctemplate
UI Test Case Class.xctemplate
Unit Test Case Class.xctemplate

$ ls ~/Library/Developer/Xcode/Templates/File\ Templates/Custom/
C File.xctemplate
C++ File.xctemplate
Cocoa Class.xctemplate
Header File.xctemplate
Objective-C File.xctemplate
Objective-C new superclass.xctemplate
Playground Page.xctemplate
Playground with Platform Choice.xctemplate
Playground.xctemplate
Sources Folder Swift File.xctemplate
Swift File.xctemplate
UI Test Case Class.xctemplate
Unit Test Case Class.xctemplate

XCode Screenshots:

screen shot 2016-02-05 at 3 57 20 pm screen shot 2016-02-05 at 3 57 29 pm
royclarkson commented 8 years ago

Interesting. I'm not sure what's going on either. Obviously, sometimes things change between Xcode releases. I'll take a look and see if I can figure out why.

royclarkson commented 8 years ago

I copied the unmodified templates and they still aren't showing up as available templates, so something else is needed here. Requires a bit more digging...

antskaar commented 8 years ago

Cocoa Touch template can be found from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source. There are also some other iOS related templates.

xctemplates.rb copying part needs to be updated. Rest of the process(updating headers part of the script and copy-templates.rb) works fine.

Another thing: copying part does not cover all the templates. I would recommend including templates from /Other and /Resource folders as-well. And make sure that header replacing works with all file types.

royclarkson commented 8 years ago

@antskaar thanks for the recommendations!

akshaykolte commented 7 years ago

By default there is no Cocoa touch class templates in File Templates. You can find the templates on a github project https://github.com/jdg/Xcode-File-Templates or at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source . You'll need to add these manually and then run the script.