Now that Apple has taken away the Plist, naturally it has changed the way we add custom fonts to our app. Before we just added the file to our bundle and set a property for it and our plist and viola..
Now I am curious.. can it be done without adding a custom plist as shown here or is that the only option?
drag and drop your font-file into the project (make sure you hit copy if needed and check the target box)
choose Project -> Targets -> Info -> Custom iOS Target Properties and klick the small + icon under the "key" property. Start typing "Fonts provided by application"
enter the full font-filename inside this property-list
now you can use the font by its name
(Bonus: if you have trouble to find the font name, you can print all available fonts with [see detail explanation for this at code with chris ]:
for family: String in UIFont.familyNames
{
print(family)
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
You can add font files name same as you add in project directory info.plist
Just go to
Project -> Targets -> Info -> Custom iOS Target Properties
Add your all permission or file here.
Related
Has anyone figured out how to add/edit values in the Info.plist of Xcode 13 yet? I see they moved the Info.plist from the navigator pane... but although I can find it, I'm not sure how to edit it.
It's a "feature."
You don't need it anymore. From the Release Notes:
Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor. These files are added to the project when additional fields are used. (68254857)
So, instead of inside Info.plist, edit properties like NSCameraUsageDescription here:
Project -> Targets -> Info -> Custom iOS Target Properties
The first time you add/edit, Xcode will automatically generate a new Info.plist file that’s kind of synced1 with Custom iOS Target Properties. Xcode will later merge them for you.
[1]: They’re not fully synced. Some properties like NSCameraUsageDescription will only appear in Custom iOS Target Properties, while Application requires iPhone environment will appear in both. I have no idea how Xcode determines this.
Want Info.plist back, completely?
You might want all of your app's properties in one place. Or maybe you don't trust Xcode with the merging. I spoke with an Apple engineer at WWDC21 about this... here's how to get the classic Info.plist back.
Create a new "Property List" file (File -> New -> File)
Name it Info.plist
Copy and paste the existing values from Project -> Targets -> Info -> Custom iOS Target Properties to Info.plist.
Copy
Paste
Note: Currently you can only select and copy 1 row at a time. If you want to save some time, here are the default contents in XML format. To use this, right-click Info.plist -> Open As -> Source Code, then paste.
Copy the path to Info.plist in the attributes inspector.
Paste the path here:
Project -> Targets -> Build Settings -> Info.plist File
Set Generate Info.plist File to No
Last step. Remove Info.plist from Copy Bundle Resources (select, then press the - button).
Project -> Targets -> Build Phases -> Copy Bundle Resources
Yep, that was a lot. But whether you want classic Info.plist or not is up to you — both are fine and won't change your app.
Xcode 13.3.1, macOS Monterey(12.0.1)
Here is the most simple solution which work for both swiftUI and Storyboard projects, if you are not able to find info.plist and want to add target properties like Privacy - Camera Usage Description and things like we can add in older Xcode version. Here is the solution...
***> Select target of you project on top of the files click on Info on
> top of the right side, now you can see "Custom iOS properties" like
> info.plist, do whatever you want.***
Target > Info
see the image below for reference
Here is a link to a raywenderlich tutorial: https://www.raywenderlich.com/19611194-multiplatform-app-tutorial-swiftui-and-xcode-12
The sample projects uses Xcode 12.0-compatible (objectVersion = 54) project format, created with the Multi Platform app template. I borrowed the plists from this project. Until the sample project is revised, it's nice to have a reference project (structure) for comparison.
This also applies to Xcode 14. To be brief, a few pieces of information about this change:
There is a good write up of the issue here:
https://useyourloaf.com/blog/xcode-13-missing-info.plist/
There is a good YouTube video (found in this page above):
https://youtu.be/mml9ZI81VKA
This issue applies to SwiftUI projects not Storyboard. Once you make
a change to the "standard" info settings, Xcode actually
automatically creates an info.plist file in your project navigator. You can then add more custom settings in the info.plist file.
I am developing for macOS and I would like to use a custom TTF font with SKLabelNode in my SpriteKit project.
I did search the web how to do it and every place I can find describe the following steps:
Add the font to your app bundle
Add the "Application fonts resource path" key to Info.plist with
"Fonts" as the value
Add the "Fonts provided by application" key to Info.plist and add name of the font file
Create a Copy build phase with "Resources" as the Destination and
"Fonts" as the Subpath
Drag/Drop the font to the Copy build phase
In Finder right-click on the font file and select the "Get Info" menu option.
From the "Full Name" field, copy the font's name
I have done everything from the list above and I try to set the font inside the didMove() method programatically like so:
titleLabel = self.childNode(withName: "TitleLabel") as! SKLabelNode
titleLabel.fontName = "Lobster Regular"
However, when I run it, I get the error "Lobster Regular" font is not found. I double checked and this is the name of the font. I also tried to use the file name but that also did not worked.
I did also follow the official documentation.
The problem is however, the documentation suggest that after adding the font to the Xcode project and include the keys in info.plist, I should be able to assign the font to labels using interface builder. But in my case, the font does not show up inside interface builder.
If I add the font to Font Book, it works, I can use it both programatically and inside interface builder but I would like to include the font with my app/game instead.
What am I missing? Is there any other properties in Xcode I should check?
Thank you.
It seems in my case the solution was to set the "Application fonts resource path" key to an empty string, just leave it blank the value field to automatically pick up all fonts I have included with the project. Entering a . as value also seems to work and able to set the font programatically this way.
I found that the name of the first menu was dictated by BundleName and $(PRODUCT_NAME). I wanted him to support localization, and each region displayed a name, but I didn't find it.
Are there any relevant documents or cases that can give me some help, thank you?.
In your project, add a Strings file named InfoPlist.strings and add an entry for CFBundleName then localize the file and the entry per supported language:
CFBundleName = "¡Mi aplicación!";
This will allow the name of the app to appear localized in the app menu and also in the standard about panel.
Other Info.plist string entries can be localized in the InfoPlist.strings file as well (e.g., CFBundleGetInfoString, NSHumanReadableCopyright, NSContactsUsageDescription, etc.). To see the keys in Xcode, open the Info.plist file and control-click in the editor pane of the plist to see the contextual menu and select Show Raw Keys/Values.
I'm trying to use this font in my app. I've added it to the plist and to the project, but for some reason it is not loading on the label. I've tried to verify the font in the project with:
NSLog(#"DK Crayon Crumble: %#",
[UIFont fontNamesForFamilyName:#"DK Crayon Crumble"]);
But I'm getting this output:
DK Crayon Crumble: ( )
I found the problem. For some reason Xcode it was not copying the font file to the bundle package.
The convention with the built-in fonts (you can select them in Interface Builder) is that you eliminate the spaces and add the attributes after a hyphen, such as
#"HelveticaNeue-Bold"
for Helvetica Neue, Bold.
I don't know the exact name of your font but if you follow this scheme, it should work.
Some times the fonts are visible in the project file but are not actually
added to the target to do so
click on the project's name -> click on target -> Build Phases, go to
'Copy Bundle Ressources', if the concerned font(.ttf extension) file is not there add it to the list.
Clean your Project and run you should be able to see the font.
Maybe the problem is that the name of font is with space. Remove spaces, in real file name, add it again to your plist and try again with code:
[UIFont fontNamesForFamilyName:#"DKCrayonCrumble"];
This link help you to set font:
set custom font
How can I change a name of my project in the Xcode?
Newer Versions of Xcode
According to the Xcode documentation says that you can select your project in the lefthand panel and then open the properties inspector. By editing the project name, you'll be prompted to renamed targets etc.
Original Answer
I'm not sure exactly what you are asking, so I've given two parts to my answer.
To change the display name of your project, (under the icon on the home screen) you should edit your Info.plist file in the Resources group of your project. Change the Bundle Display Name key. Make sure that you save the plist file and that you've deleted the old app from the simulator. Then, clean your build and then you can build it again to the simulator.
To change the name of your project, target and executable, click on Project -> Rename... in Xcode.
It's simple. Just press enter on name of project. Rename your project as desired. This will prompt changes to be done in entire Project. Click on Rename.
Ap iOS app under construction has at least 6 "names". They can all be different and can be set in different places.
Project name.
Target name.
Product name (which will become the .app bundle file name, should have no spaces).
Bundle display name (in the info.plist, displayed under the icon, spaces allowed).
Bundle ID suffix.
App name you give iTunes Connect.
Depending on what you change, you may need to delete the app from your device/simulator, and reinstall/build-and-run, to quickly see the changes.
Ah, I figured it out already. You need to change the active target.
If you want to change Project Name, Target name, -Info.plist name & -Prefix.pch name then,
- Select Project in Xcode (.xcodeproj file)
- Selecte file inspector
- In identity section change project name which u want to update & press enter
- After scanning whole project it will ask to change the file names i.e target, plist & pch file
- Select check boxes as per your need
In Xcode try the Project | Rename menu command.
See here.
1) Expand the "Resources" folder
2) Click on the "yourappname-info.plist"
3) Expand the "Information Property List"
4) You can change the "Bundle Display Name" to anything you want to display on the iPhone Home Screen.
if only change display name under app icon in device main screen you just need change "Bundle display name" key of target at tab info.
#Mosche This question should be updated for XCode 4.
Seems one has to use sed in .xcodeproj directory:
find . -type f -exec sed -i -e 's/OldProjectName/NewProjectName/g' {} \;