Skip to main content

Error: resource fork, Finder information, or similar detritus not allowed in Xamarin iOS app

·2 mins

Just a quick write up for the error message in the title. I wanted to run my app on a physical device, but couldn’t, while on the Simulator it went fine. I Googled the error message and quickly came across a number of solutions. At first, I thought it might have to do with the Visual Studio preview, but as it turns out now, it doesn’t. In this post you will read what the exact problem is and how to get rid of it.

The Problem #

After reading a couple of sites, apparently the cause does not lie with Xamarin or the .NET tooling, but with image (or resources files) having certain extra attributes. For some reason I must have had one or more in my iOS project, preventing me from building for a physical device.

This is due to a new restriction by Apple, they describe it as:

This is a security hardening change that was introduced with iOS 10, macOS Sierra, watchOS 3, and tvOS 10.

Code signing no longer allows any file in an app bundle to have an extended attribute containing a resource fork or Finder info.

You can find the files that are subject to this, with this command in a Terminal $ window: xattr -lr <path_to_app_bundle>. The path to your app bundle is found in the error message.

The Solution #

This one on StackOverflow had a number of different options to try. I started with the easiest one, and that also turned out to be a working solution!

In your Solution Explorer go to your iOS project, right-click, hover over Tools and choose Open in Terminal. You can see where to find it in the screenshot underneath.

A new Terminal window will pop up in the root of your project folder. Make sure it is the root of that folder and not any other, because the next step will potentially be destructive of attributes in your image files.

Run this command in the Terminal, which removes all kinds of attributes from files that fall within the wildcard. In this case, all png files: $ find . -type f -name ‘*.png’ -exec xattr -c {} \;

You might want to repeat this for jpg files, json files and any other files that might be included in your project. Of course, if you ran the command from above and know which file it is, you can simply target that file(s) and you should be good.

Now clean, rebuild, throw out your output folders to be sure and run again!