Bundle Fonts Into An AppleScriptObjC App - xcode

Is the process for embedding a custom font different with Cocoa-AppleScript apps?
I have a label that would display a string in this custom font, but it is still defaulting to the system font when packaged and run on a mac that doesn't already have the font installed.
I've dragged the font (ConnectCode39.ttf) to the sidebar in Xcode, and ensured that the app is ticked under target membership.
I've even added Fonts provided by application - CCode39.ttf (The true name of the font, not the file) to the info.plist, although I'm not sure if I still need to do that with the latest Xcode?
I've confirmed that the .ttf file is in the 'Copy Bundled Resources' as well.
The label is currently set to use 'CCode39', although is this picking it up from my Mac's font library? If so, how do I change it to use the bundled copy of the font? Or is this part ok and there's something else I'm missing?
Thank you!

Related

Script for setting custom icon in Xcode for non-app MacOS bundle?

How can I set a custom icon (using a .icns file) during a script phase of an Xcode build targeting a non-app bundle?
We are making audio plug-ins, and would like to have our own icons instead of the default ones for our .vst3, .component, and .aaxplugin bundles.
I had some very old script that used to do this, but it relied on the old Rez utility and doing something I don't recall with a specific portion of the resource fork. Now, with bundles, I can't find the script I need to add to insert the icon and make it actually show up.
I have set the CFBundleIconFile string in the plist file to MyIcon.icns, and the script phase copies the MyIcon.icns file to the Contents/Resources folder, but it still does not show up in Finder with our icon. (If I change the plug-in extension to .app, our icon DOES show up, but then I can't change the bundle back to .vst3... it keeps the .app extension once that is set.)

Custom fonts in Mac sdk using storyboard

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.

Give an OS X app a custom icon?

Yes, my problem really is that simple. How the heck do I get my app to use the icon file or asset catalog?!
System info:
Xcode 6.1.1 (6A2008a)
app target OS X 10.10
OS X 10.10.1 (14B25)
This is my first OS X app but I have several years' experience developing iOS apps.
Steps to reproduce:
open Xcode, start an entirely new cocoa application project
not sure this matters, but i specified my new project not to use storyboards or core data
drag a .png file from my local directory into the project structure, and make sure (a) it ends up in the build target and (b) the file copies into the project's directory
drag the png into the Images.xcassets catalog under any/all of the sizes classes for AppIcon.
build and run
Expected: app in dock and tab-switcher has the new icon.
Actual: app in dock and tab-switcher has the default "blank page with instruments A on it"
Ok, maybe that's a DEBUG thing.
archive the project, show in finder
Expected: app in Finder has correct icon
Actual: nope. It should be noted however that Xcode's Organizer shows the correct icon, and there does exist a file Contents/Resources/AppIcon.icns. Contents/Info.plist specifies that the Icon File is "AppIcon".
grrr. Let's try without the asset catalog.
in the target's General settings, under App Icon, select "don't use asset catalogs"
delete Images.xcassets
In Info.plist, in the line for Icon File (CFBundleIconFile), specify the icon's name (in my case "AppIcon"). The documentation clearly states that
The system looks for the icon file in the main resources directory of the bundle.
File extension is not required here.
build & run. also archive, to save time later.
Expected: app icon in dock and tab-switcher is correct.
Actual: nope
Expected: archived app has correct icon.
Actual: nope, but the archived product did have the correct png file in Contents/Resources.
What am I missing?!
I've tried this with .png app icons and a regular .icns file (generated by Xcode via an asset catalog). I've tried excluding and including the file extension in the Info.plist. Why is this so difficult?
Edit: Clean, Clean Build Folder and deleting the Derived Data folder did not help.
So I found the answer through the help of a commenter: I had to fill all of the xcassets/icns slots with images of the exact dimensions.

Custom Font xCode 3.2 is not working

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)

How can I set the icon for a Mac Application in Xcode?

I have been learning a lot about writing Objective-C code and designing in Interface Builder and I wanted to set icons for my simple programs.
I added the same JPG to all the size fields in Icon Composer and got an ICNS, but I couldn't figure out how to add it to the project.
Thank you in advance.
Since Xcode 4.4 Icon Composer is no longer the recommended way to create icons and is no longer included in the standard install of Xcode.
Due to the introduction of Macs with retina display, it is now recommended to provide high resolution versions of all graphics including app icons.
To give your app an icon under Xcode > 4.4 do the following:
Create a folder [IconName].iconset in Finder
In this folder place your icon as png files. You'll need the icon in
sizes of 16px, 32px, 64px (retina only), 128px, 256px, 512px and
1024px (retina only)
These icons must be named with the pattern icon_16x16.png,
icon_32x32.png, icon_128x128.png and so on
To support retina displays you must also add icon files with double
resolution, named icon_16x16#2x.png (with size 32x32),
icon_32x32#2x.png (size 64x64) and so on up to icon_512x512#2x.png (size 1024x1024).
drag this [IconName].iconset folder to Xcode (copy if necessary)
in the info.plist file set the "CFBundleIconFile" (Icon File as Key) value to
[IconName] but without the .iconset extension
Annotations:
it is (currently) not required to provide the #2x icons
it will (usually) also work if you don't provide every icon file
the iconset folder should not contain a icon_64x64.png file. the 64px icon is only for the retina version of the icon_32x32
Update:
In the end your .iconset folder has the following 10 items:
icon_16x16.png
icon_16x16#2x.png
icon_32x32.png
icon_32x32#2x.png
icon_128x128.png
icon_128x128#2x.png
icon_256x256.png
icon_256x256#2x.png
icon_512x512.png
icon_512x512#2x.png
Official guide:
https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html
Additional information:
To convert the iconset folder to an icns file, run the following command on the terminal:
iconutil -c icns [IconName].iconset
where [IconName] should be replaced with the prefix of the iconset folder. You now have a file called [IconName].icns. In Xcode 4.4, in the Target Summary, right click the question mark for the icon, then select the icns file. You should then see the question mark get replaced with the icon.
As of Xcode 7 (not sure when this was originally introduced), you can use the Assets.xcassets file for app icons. This file is included by default for new projects.
Simply:
Go to your target's settings and ensure that under General, App Icons the Source is set to AppIcon.
Add all 10 png icons to your Assets.xcassets's AppIcon image.
Delete derived data if you have launched the app before, otherwise it will continue to show the default icon.
Run the app; it should now show your icon in the Dock, Application Switcher, and anywhere else it should appear.
Follow these steps to add an application icon to your project. This is the icon that will be show by the MacOS in the doc bar and alt-tab display.
Create an icon .icns resource file
Place it in the "resources/macos" folder
Add it to the resources group in the xcode project
Edit the Info.plist file and change the "CFBundleIconFile" value string to "icon"
Also, img2icns tool can come handy to convert images to an icon.
It's easy
Use automatic tool (Such as IconFly) for create correct ICNS or iconset with all necessary size.
Then drag and drop created ICNS or iconset to Xcode.
in the info.plist file set the "CFBundleIconFile" value to [IconName]
Steps to add an application icon to your cocoa project.
Find 'Icon Composer' from spotlight.
Drag and drop the icon(name should be like imagename.icns) in the given boxes.
Select one box and save it.
Drag and drop the saved image in the Resources folder of your application.
Select target-->right click on project name-->Select GetInfo.
In Properties enter the name of 'Icon File'.
Now Clean Build and run your application.
Xcode 8.2.1
Convert .png 👉.icns via IconMaker
Add the AwesomeApp.icns file in the same folder as info.plist
Drag AwesomeApp.icns file into xcode in the same folder as info.plist
In info.plist set icon: to AwesomeApp.icns
Step 1: Get iconfile name from info.plist and place icns(icon file) folder in SourceCode/resources folder
Step 2: And same thing goes for xcode,you have to copy all images from xcode using copyallframeworks or copyall resource file in your xcode and build the app again.

Resources