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

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.

Related

How to support Xcode Templates for SwiftPM?

I have Xcode Template that generate a bunch of files (not project) with some predefined repetitive code (for example classes for MVVM pattern). When I try to create these files in Xcode Project all works fine (I can find and create my templates in New File… menu), but when I try to do the same thing in SwiftPM I can't find my templates in the New File… menu.
All my templates are leaving in ~/Library/Developer/Xcode/Templates/**/*.xctemplate.
What should I do to show templates for SwiftPM as well?
After some research of /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/ folder I found that some default templates have the property SupportsSwiftPackage that set to YES. I added it to my templates and it finally works.

In a Xamarin Forms application. What's a Styles.xcassets file in the iOS project used for?

My application has one of these files but it doesn't seem to do anything and when I click on it, then it shows as empty.
That is an Asset Catalog Image Sets
Asset Catalog Image Sets - Use Asset Catalog Image Sets to manage and
group all version of a given image asset required by an app.
You can add images to your iOS solution, using Resources, or creating a Catalog Image Set.
You can read the official Apple Documentation
There is no default file called Styles.xcassets in the iOS project. And I think this is a normal Asset Catalog Image Sets file created by someone.
In an iOS project, the is a default Asset Catalog Image Sets called Assets.xcassets file and manager your image there.
Also, instead of using the Assets.xcassets, you can create more ....xcassets to manager your images. It can be more clear and is easier to distinguish different kinds of images.
For example, if there is a Styles.xcassets, you can put all images of style into this file. You can also create a Home.xcassets there to put all images in the homePage there.
Hope you understand What's a Styles.xcassets file in the iOS project used for now.

Impossible to reference an image from the Assets Folder

I am currently building a Windows Universal App and the learning curve is OK. I get a response from my webservice, parse the JSON, display info in the app, but my current issue is the following one:
I tried to display an image that I put in the Assets folder, but this doesn't seem to work.
This is my layout:
As you can see, the text "Test" is correctly displayed but not the images.
On the right side, in the explorer pannel, I cannot see the files that should be here:
WHAT I HAVE TRIED:
In my example, they are in the Assets/picto folder, but I have also tried the root directory Assets, as wal as creating Image folder at the same level.
I have definitely no idea how to add a simple picture, so any help is appreciated!
Adding items in Windows explorer to the right location doesn't add them to your solution / deployment.
You have to right-click the picto folder -> Add > -> Add existing item. Your items are not even in your solution, so they won't show up on the layout screen.
Make sure you set the correct build target for each image.
If an image shouldn't show up, even through it's in your solution, this is often the reason.

Override Xcode's default templates

I want to modify Xcode's default templates but only for a given user in my Mac. I tried following the steps in this answer, but instead of overriding the default templates it created new ones. You can see the result in the following image.
Is there any way I can tell Xcode to use only my custom templates without modifying the original files?

Icon for Action Extension in iOS8

I have worked on extensions and it's all very interesting. For all type of extensions, icons work really well except for Action Extension where the icon is all white? Do you know how to create an icon for Action Extension?
In the Build Phases of your Extension Settings, just add Images.xcassets (or the icon file) to the Copy Bundle Resources.
PS: For Action Icon, any color data in the image itself is ignored. via Apple Docs
The alpha channel of the image is used as a mask to generate the final
image that is presented to the user. Any color data in the image
itself is ignored.
I had to manually add my icon assets catalog in the build settings. I described it here:
To get this to work with my existing Asset Catalog, I had to add the following to the extension's Build Settings:
The name of the set in my Assets Catalog is "ExtIcon". I had tried setting the CFBundleIcon and the NSExtensionServiceToolbarIconFile keys in the info.plist for the extension, but had no luck. This actually seems to make sense since it is the same way that icon sets are linked to the container app, not via info.plist, but via the Build Settings.

Resources