I have done everything you are supposed to do to make a custom font show up in an Xcode project. However, the font comes out Helvetica every time and not Oswald as I hoped. Here you can see the name of the font is in fact, Oswald. I also tried different names - Oswald-Light, Oswald-Regular, Oswald-Bold...
Here you can see that the .ttf files are in fact in my project. They are also in the projects folder in the finder - I checked that.
I put the names of the files in the .plist under Fonts Provided by Application.
And finally I told the label to use Oswald font. Again, I tried #"Oswald-Light",#"Oswald-Bold"...
Solution:
Make sure the ttf files are in the target's Copy Bundle Resources build phase. If they aren't, they won't get copied to the app bundle when you build the project.
Solved by Mark Szymczyk - third comment (just to make it explicit in SO-style that the problem was solved)
Related
How to add a custom font to storyboard in Mac app development. I went through some blogs and tried by adding font book and develop one NStextfield using this custom font using storyboard. But it is system dependent. I created the DMG and install in another computer it uses the default font. I did it programmatically, but my requirement is through storyboard.
Please help me on this
I spent a bit of time trying to figure this out and found the solution in this related question.
In your info.plist file, which you made available to me at
It turns out you can safely get rid of the "Fonts Provided By Application" section (it's an iOS specific key and is ignored by macOS).
And for "Application Fonts resource path", make certain you have the font going into a "Fonts" folder (or some subfolder within your application bundle's Resources folder).
Lastly, do a custom copy build phase like this:
This is copying the font into the "Fonts" subfolder specified in your "Application Fonts resource path". You don't want the font in your Resources folder, but you do want it in a subfolder underneath Resources.
I'm trying to use custom fonts in my application. I followed the instructions and everything worked as expected.
The problem is that if I run the application again in Genexus, the custom fonts settings in the xcode's project are overwritten (Android still works).
I tried copy the project from Mac to models folder ("\mobile\iOS\"), but the problem persists.
Any solution?
As stated in the instructions:
As this is donde on the XCode project generated with GeneXus steps 3-5 have to be repeated after each execution from GeneXus.
However, there are a few things you can do to automate the process:
Add the fonts to your knowledge base as files, edit the properties for each of the files, set "Extract" to "Always", and in the "Extract to path" property add the relative path to the generated project's folder. Something like "..\mobile\iOS\main_object_name\iOS\Genexus"
Edit the template file located at "genexus_install_directory\iOS\Templates\iOS_Genexus\MainName-Info.plist", add the custom fonts key
You may also need to edit the project's template file located at "genexus_install_directory\iOS\Templates\iOS_Genexus\MainName.xcodeproj\project.pbxproj" (not sure about that), to add a reference to the fonts files
The best way to know what to add to the files from steps 2. and 3. is to generate the project in GeneXus, make a copy on the Mac before adding the fonts, add the fonts via Xcode as documented, and compare the resulting files with the originals.
A warning, though: the steps 2. and 3. apply to ALL applications generated with that GeneXus install, so you may want to make a copy or at least backup the modified files first.
I've been trying to set my application's icon following the directions here:
http://qt-project.org/doc/qt-5/appicon.html
If I understand correctly, the process should be fairly simple:
Create an icon file (FlySightViewer.icns) using iconutil. I followed the directions here: https://stackoverflow.com/a/20703594/443822.
Add ICON = FlySightViewer.icns to the .pro file.
However, when I follow these steps, the icon remains the default Qt application icon. I've tried deleting the app bundle and build folder, since I've read that these are sometimes not rebuilt through the usual process. This doesn't seem to resolve the issue.
Looking a bit deeper, when I run qmake from Qt Creator, the generated Makefile contains several instances of FlySightViewer.icns, including this line:
#$(COPY_FILE) ../flysight-viewer-qt/src/FlySightViewer.icns FlySightViewer.app/Contents/Resources/FlySightViewer.icns
The file ../flysight-viewer-qt/src/FlySightViewer.icns seems to be right where I expect it to be. However, when I build the project and look inside the app bundle, the icon is nowhere to be found. The only thing in the Resources folder is empty.lproj.
So it seems to me that the icon isn't appearing as expected because it is not being copied to the app bundle, but I have no idea why that might be.
Any help would be appreciated. I realize this is a fairly common question, but none of the answers I've found here seems to have helped.
Thanks for your time!
Add this line into .pro file:
QMAKE_INFO_PLIST = Info.plist
Then create the .plist and set the icon name there. I won't paste an example .plist because it's quite large, but you can see how it's done by right-clicking a random app and selecting "show package contents".
With older versions of Qt, I settled on changing the icon manually. However, the most recent version of Qt (or macdeployqt) seems to have fixed the problem, so I no longer need to set the icon manually.
I think I'm literally on the last step before submitting a new Mac app, and I've been banging my head against a wall for the past few hours on what I think should be really, really easy.
I've designed document icons for the two different types of icons my app creates and works with. I created a new "Icon" in Images.xcassets, and dropped the appropriate files into the drop zones.
In the product editor -> Info, I go to where the document type information is, but when I try to enter in the icon name in the "icon" field of either the Document Types or Exported UTI section, the icon image just turns into a question mark—no options show up in the drop down menus for icons.
How do I get the images/icons in the asset catalog to show up in the editor? Alternatively, if I was going to enter that manually into the plist, what sort of format would I use to reference an Icon file from the asset catalog?
I know I'm probably missing an easy step here, but I can't see it!
To my knowledge, Xcode doesn't currently support using .xcassets for document icons. This is a little strange—the .xcassets editor clearly allows you to create new icons, but it doesn't generate .icns files, it just puts all the files in the same folder and uses a plist to manage them.
To create an icon for your document types, upload the 1024x1024 version of the icon to http://iconverticons.com/online/ to convert it to a .icns file. Alternatively, you could use a third-party tool to generate an .icns file with different images for different resolutions. There used to be a great tool included in the Developer Tools for doing this, but I can't seem to find it anymore.
Once you've got an icns file, add it to your project and you should be able to select it as the "Icon" for your Document Type or External/Internal UTI. Enjoy!
To be honest, it might be worth filing a bug about this. Xcode's development seems so strongly driven by iOS these days, they may not have noticed this yet!
I did it in the most easy way:
Add "New OS X Icon" to images.xcassets and name it "DocIcon", for instance.
Drag and drop images of your document icon
Just type "DocIcon" to icon name of your document
You will see question mark as document icon thumbnail. Don't care about. All will work fine after build and launch of application.
This is what worked for me, using Xcode 10 in 2019 (none of the other answers worked in my case):
Select asset catalog in Project Navigator
Right click on the left pane (list of assets) and choose App Icons & Launch Images ▶︎ New macOS Generic Icon (second option from bottom). Name it "Document". This will create a folder named "Document.iconset" in the asset catalog directory.
Populate all entries with your custom images. They must all be of the appropriate size (e.g., "16 x 16 #2x" must be 32 x 32 pixels, otherwise you will get yellow a warning icon over the image slot).
Navigate to the asset catalog folder, and use the command: iconutil -c icns Document.iconset (must match the name of the icon created in step #2). I took this command from Apple's documentation here (which by the way, also says some BS about Xcode "automatically creating an .icns file from your .iconset folder on build". Sure...).
Copy the newly created Document.icns file as a resource to your project.
Select the target, open the Info pane, and in both Document Types and Exported UTIs set your .icns file as the icon for the file type.
Hej, allesamme,
I had the same problem and have been researching it for days. I found a family of four solutions, the first three of which did not work for me: 1. using a .png file as the document type icon file; 2. using a manually created .icns file as the document type icon file; 3. the above solution, and 4. what I will describe here. Only the last one worked for me.
I tried following the spirit of the above advice and found that it didn't work, at least for my MacOS app. I'm on OS X 10.9.2 (13C64) running Xcode Version 5.1 (5B130a).
The current wisdom seems to be to create a directory in your workspace with a lower-case name and .iconset extension, in which one puts files with an icon_ prefix and the usual suffixes (16x16.png, 16x16#2x.png, 32x32.png, etc.)
In Product Editor's Info pane you can go into Document Types and associate the .iconset file with the Icon field. The icon image happily displays something reasonable. The build process builds a .icns file from that spec and copies it into your app.
I had an intermittent problem that the .icns file wouldn't build, which I traced to mistakenly haven included a 64x64 icon in the list. That's a no-no.
The current Apple dogma on this issue can be found in the official documentation, which covers some details I glossed over here. I didn't need to edit the Info.plist file directly: everything seemed to work from the interfaces provided in Xcode.
I have no idea which solutions work in which contexts, but thought I'd add throw more alternative on the fire for people to try out. — Jim Coplien
I just upgrade my MonoDevelop to the latest version (2.8). I also installed XCode4, since it's fully supported now. When opening my solution (which consists of several projects) I was asked to migrate my solution. I did this and saved everything.
However, I think something is missing. When I open the .xib file, the project on the right doesn't show .h files, like shown in the tutorial.
It also shows warnings that the outlets were not found in XCode.
When I add a new screen, it creates the .h file as it should and shows this in XCode. However all existing screens don't have these files, which makes it impossible to add/change outlets.
How can I fix this.
Check that your classes you expect to see in Xcode have explicit [Register("SomeName")] attributes, which register them with a name usable from Xcode/Obj-C/IB.
I would expect an imported project to have those attributes already, since they're required for xibs to be able to load the classes by name, but you could maybe have got away without those attributes by using outlets on "File's Owner".