How to add Assets Catalog for iOS in Xamarin.Forms? - visual-studio

I am using Xamarin Forms. I was facing one weird issue from the past two days. First I have created App with assets catalog and not included a key for "CFBundleIconName". Then after just a few minutes, I got an error like
A value for the Info.plist key 'CFBundleIconName' is missing in the bundle "xxx".
Then after I have tried with assets catalog and removed above key from info.plist file. Then I got an error like
Missing Asset Catalog - Your app is missing the asset catalog file
If I am removing below lines from a plist file then getting 120X120 icon file missing.
<key>XSAppIconAssets</key>
<string>Media.xcassets\AppIcons.appiconset</string>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconName</key>
<string>icon</string>
<key>CFBundleIconFiles</key>
<array>
<string>icon-20#2x.png</string>
<string>icon-20#3x.png</string>
<string>icon-29#2x.png</string>
<string>icon-29#3x.png</string>
<string>icon-40#2x.png</string>
<string>icon-40#3x.png</string>
<string>icon-60#2x.png</string>
<string>icon-60#3x.png</string>
</array>
</dict>
</dict>
Are the above lines are necessary to include in plist file? What other things are necessary to include in plist file.
And My project structure is :
What is wrong with my code? How can I add all files and assets?
Any idea?

Delete all images and those lines from the info.plist.
Your Info.Plist should have the following lines:
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>XSLaunchImageAssets</key>
<string>Assets.xcassets/LaunchImage.launchimage</string>
Add all the required icons to Asset Catalogs/Media

Related

Facebook SDK for iOS Xcode?

I need help adding this code from Facebook to enable advertiser tracking. Here is a link to the description. I do not know where to place the code in Xcode’s source code. Can someone help me?
The link below has the code.
https://developers.facebook.com/docs/setting-up/platform-setup/ios/SKAdNetwork
enter image description here
The guide that you linked says:
Add the following SKAdNetwork IDs to your Xcode project’s Info.plist
So, add them! Note that the example is in XML form, but the Info.plist is displayed visually. You need to Right-Click -> Open As -> Source Code.
Then just paste them in.
<key>SKAdNetworkItems</key> /// make sure you also add this line
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>v9wttpbfk9.skadnetwork</string>
</dict>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>n38lu8286q.skadnetwork</string>
</dict>
</array>
The example doesn't include <key>SKAdNetworkItems</key>, but you need to add this (check out the For more information section)

xcode template change framework path

Is it possible in the templateInfo.plist to change where a framework is loaded from?
I can't seem to find how to change it with the framework also being installed to the iPhoneOS#.#SDK and iPhoneSimulatorOS#.#SDK System/Library/Frameworks directories.
I have my framework loading from those directories where it is installed but I have a request to change the template to load the framework from another install location to minimize disk space.
Example plist xml:
<key>Frameworks</key>
<array>
<string>MobileCoreServices</string>
<string>My_New_SDK</string>
<string>AddressBook</string>
<string>AddressBookUI</string>
<string>AudioToolbox</string>
<string>AVFoundation</string>
<string>CFNetwork</string>
<string>CoreGraphics</string>
<string>CoreLocation</string>
<string>CoreTelephony</string>
<string>ExternalAccessory</string>
<string>Foundation</string>
<string>MapKit</string>
<string>MessageUI</string>
<string>MediaPlayer</string>
<string>Security</string>
<string>SystemConfiguration</string>
<string>QuartzCore</string>
<string>UIKit</string>
</array>
If you remove the My_New_SDK from the frameworks list of the target area of the template, you can create a Node in the template for the framework and specify the absolute path in that node. Do not forget to add the node to the Nodes array in the template plist
<key>MY_New_SDK.framework</key>
<dict>
<key>Path</key>
<string>/PATH_TO_FRAMEWORK/My_New_SDK.framework</string>
<key>PathType</key>
<string>Absolute</string>
</dict>

Creating a localised mac help book file (.help)

I had created the help for my app in just one language in a folder and it worked. I've tried and failed to localise this content and add a Spanish translation.
My understanding of Apples Guide to creating a help book is that I need to create a .help package for localisation to work. I've done that, but I get an error saying "The selected topic is currently unavailable.". There have been a few times when I thought it was working, but it was just showing the pre localised content I had. Emptying the help viewer cache seems to stop that, but then I go back to getting the unavailable content error message.
In my app's AppName-Info.plist file I have the following help related entries:
<key>CFBundleHelpBookFolder</key>
<string>AppName.help</string>
<key>CFBundleHelpBookName</key>
<string>garsonix.appname.help</string>
My AppName.help file has the following structure:
AppName.help
Contents
Info.plist
Resources
English.lproj
index.html
search.helpindex
Spanish.lproj
index.html
search.helpindex
shrd
logo.png
The Info.plist file inside AppName.help has the following keys:
<key>CFBundleDevelopmentRegion</key>
<string>en_GB</string>
<key>CFBundleIdentifier</key>
<string>garsonix.appname.help</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>AppName</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.13</string>
<key>CFBundleSignature</key>
<string>hbwr</string>
<key>CFBundleVersion</key>
<string>1.13</string>
<key>HPDBookAccessPath</key>
<string>index.html</string>
<key>HPDBookIconPath</key>
<string>shrd/logo.png</string>
<key>HPDBookKBProduct</key>
<string>GAppName</string>
<key>HPDBookKBURL</key>
<string>http://www.garsonix.co.uk/</string>
<key>HPDBookRemoteURL</key>
<string>http://www.garsonix.co.uk/</string>
<key>HPDBookTitle</key>
<string>AppName Help</string>
<key>HPDBookType</key>
<string>3</string>
<key>HPDBookIndexPath</key>
<string>search.helpindex</string>
Does anyone know what I'm doing wrong, or know of a good tutorial on making .help files?
I finally got this working, but I had to abandon the .help file format.
I instead kept my old simple help folder, which I duplicated for each language. Each of the help folders was then put in the existing localised folders of the main app package along with the localised nib files.
I found the instructions in this article very helpful:
https://web.archive.org/web/20150421040211/https://www.icalamus.net/ioda/howto_applehelpbook.php?lan=en
I'd still like to know how to get the .help format working, but this has solved my problem and seems much simpler. The only slight disadvantage is there is no way of sharing resources like images that do not need localising.
You should localize some of your Info.plist keys after you localized the help book resources.
The keys CFBundleName and HPDBookTitle should be localized using InfoPlist.strings files.

Xcode Data Model Editor not appearing

I'm using Xcode 4.2 and I'm trying to use Core Data. Upon clicking the .xcdatamodeld file I see a strange view instead of the Data Model Editor View.
I have reinstalled Xcode 4.2 and have even created a starter project from scratch with Core Data Enabled but the issue persists. When I create a Data Model using new file --> Data Model. It is not being recognized as a DataModel. Ctrl+Click --> 'Open As' only displays a "Preview" option. I compared my basic project with that created on a different machine (where everything works fine). A directory diff reveals :
The Foos.xcdatamodeld file was placed under the "Copy Bundle Resources" section of the project's Build Phase instead of being under the "Compile Sources" section. I moved this file to the "Compile Sources" section but the data model editor still doesn't display.
The Foos/Foos.xcdatamodeld/.xccurrentversion file in the working project looked like
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Foos.xcdatamodel</string>
</dict>
</plist>
while in the non-functional one it was
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
The only other difference I noticed was that the working version had the following in the project.pbxproj file
/* Begin XCVersionGroup section */
831B12C114A7F73600524A33 /* Foos.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
831B12C214A7F73600524A33 /* Foos.xcdatamodel */,
);
currentVersion = 831B12C214A7F73600524A33 /* Foos.xcdatamodel */;
path = Foos.xcdatamodeld;
sourceTree = "";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
while the broken one did not have this entry.
I did a directory compare of /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates on my two machines and the templates are identical.
So I'm wondering what part of Xcode is causing the above differences on my primary dev machine. Any suggestions on things to try or what might be causing this issue?
I ran into a similar issue. The problem was the projects directory structure and how it was configured in XCode.
More details here: XCode Cant' Edit CoreData Model
I also ran into this.
I was finally able to get xcode 4.6.3 to restore the interactive editor by opening the .xcdatamodeld in my project and changing the File Type (in the file inspector) from Versioned Core Data Model to Core Data Model. I was able to change it back to Versioned Core Data Model, later, and things kept working.
I had the same problem, but by creating another user account on my Mac, I was able to create a project with Core Data where the editor opens normally. It appeared my user profile was corrupt and it couldn't be resolved by reinstalling Xcode.
When creating a new data model, go to Editor > Add Model Version
That fixed it for me! :)
I solved the problem by opening the package contents of xcdatamodeld, dragging out the file inside with the same name and using it instead, thanks to this answer.

Save documents as folders, like Pages, Numbers, etc

What's the right way to go about saving data like Pages, Numbers and other OSX applications do? That is, it looks like a file to the user, but is in fact a directory (a bundle?) containing a variety of stuff. I have some fairly complex data that I'd like to store in the same way; in particular, some sensor data that needs to be associated with video files.
The Apple official docs on the topic are probably a good starting point.
From the Pages Info.plist file:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>pages</string>
</array>
[...]
<key>LSTypeIsPackage</key>
<true/>
[...]
</dict>
</array>
seem to be what does the trick.
It also looks like NSFileWrapper may be part of the answer:
Document-Based Applications Overview FAQ.

Resources