How to create custom SwiftUI View playground template in Xcode? - xcode

I want to create a custom Xcode playground template for SwiftUI View.
What file formats are used?
How can I find examples?
Where should I put those files?

You can make template by duplicating file templates at path
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Playground
Note that each platform has it's own templates.
Copy two folders TEMPLATE_NAME.xctemplate and TEMPLATE_NAME___FileMenu.xctemplate
to ~/Library/Developer/Xcode/Templates/File Templates and rename them as you want.
(you can put it in subfolder SwiftUI, it's name will be used to separate your templates from others)
To change the displayed name of template you can change Name field in TemplateInfo.plist
Paste the code of your template into ___FILEBASENAME___.playground file (you can use placeholders to generate code base on parameters, see for example this article)
Here are my templates as an example: https://github.com/DanSkeel/XcodeTemplates/tree/main/Playground
Note: ...___FileMenu.xctemplate files will be used when you create new file from opened playground.

Related

How do I customize go-present template?

I am new to Go and just stumbled upon Go's present package which I imported via go get golang.org/x/tools/present.
Is there any way to customize the look of the presentation? E.g. via adjusting the default css file?
If so where are the files used for the style? I cannot find the package anywhere in my Go path...
Let's assume you have a directory myslides with some .slide files in it.
Create a subfolder theme in myslides.
Copy the folders template and static from $GOPATH/src/golang.org/x/tools/cmd/present to that new theme directory
Start present with a new parameter -base: present -base theme
Modify the styles and template files. Most small things are in styles.css.
If you change the template files, then you need to stop and restart present. If your are changing the styles only, then a reload in the browser will do (take care to disable the cache.)
I found that the only way to change presentation styles is to modify library files directly.
If you use vgo:
$GOPATH/pkg/mod/golang.org/x/tools#<version>/cmd/present
Otherwise:
$GOPATH/src/golang.org/x/tools/cmd/present
Of cause first you need to download present package: go get golang.org/x/tools/cmd/present

Is it possible to use custom icon for Xcode file template?

In our project we generate multiple swift files when using the file xctemplate configuration. However, with this configuration, there is no icon displayed in Xcode when generating the files (see attached image). We did try to add two images to the template folder: TemplateIcon-png and TemplateIcon#96.png which yielded no success. Is it possible to use a custom icon for file templates in Xcode?
Not sure if you're still looking for an answer to this, but you should be able to create an .icns icon package named TemplateIcon.icns. This should contain your template image(s) to be displayed in the new project picker.
I suspect your issue was trying to use the PNG assets directly.
See the Base Acceptance Testing Bundle for an example. It is part of the OCSlimProjectXcodeTemplates repository.

How can I place my custom file templates to the top?

Using Xcode 9.
I have created several custom file templates.
When creating new files, the dialog box shows my custom templates at the bottom.
How can I get them to show at to top?
Under the following file path:
Xcode 11 and below (thanks for this comment)
/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates
Xcode 10
~/Library/Developer/Xcode/Templates/File Templates/
...rename the folder named Custom to Source. That will move your custom file templates to the Source section, which is on the top.

Joomla 2.5 - Phocagallery and component.php

I'm setting up a site and I've run into a problem:
I've modified the component.php file in order to customize the printing of an article. Unfortunately i discovered that phocagallery uses the same file to display pictures.
Is it possible to indicate a file different from component.php as template view for phocagallery images?
That template file is what controls the look/output of ALL components. You're better off doing a template override for whatever component (like com_content) or doing this to customize the print view.

Xcode - change project templates

So I can add new templates for single files, but I want Xcode to uses these files when setting up the new project (most noticeably the Controller and Delegate .h and .m files). How do I do that?
In addition to the templates for individual classes that you found, there are also templates for the various project types. If you just want to replace a single class file that is already being added in the projects you can just replace the file in each of the project template files (as long as the names are the same). You will need to copy the template files into each project template that you want to change it in. The other option is to make your own project templates with whatever default files you want.

Resources