This problem is a real whacky one! It involves the installation of Crashlytics - one of the best bug reporting services for iOS.

The story is that my app that I had been working on for quite some time had come to a point where Crashlytics would be very useful. Unfortunately after trying to install Crashlytics, I would get this build error:

'Metal/MTLPixelFormat.h' file not found

This was really strange because I never worked with Metal explicitly, even though I knew what it was from WWDC 2014...but how was this related to Crashlytics?

Even if I removed the framework, run script phase and intialisation code that is part of the Crashlytics installation process... the build error persisted!

The support staff that I was in contact with was initially very enthusiastic and congenial (opening his emails with "Hey dude,") however his enthusiasm diminished as our email chain grew trying to solve this problem.

Finally he was able to guide me to a solution - here is the reason for the build error.

  • When I started developing my app, I would include the frameworks within the project folder.
  • Later when migrating to Swift, these frameworks were built into the compiler so there was no need to include them in the app.
  • I removed these frameworks from my project BUT didn't remove them from the project folder.
  • When Crashlytics added it's own framework to the app, it created the search path back into my projects folder - meaning that the app would be looking for Crashlytics.framework and find all of these other old frameworks (hence the build error)
  • The Metal framework is incorporated into the UIKit framework so that's why I was getting an error. Metal was part of the new UIKit in the compiler but it wasn't found when Xcode tried loading the old UIKit framework it found in my project folder!

So that's it - I feel a lot dumber now but really happy to be past this issue!

Thank-you to Hemal my fantastic support at Crashlytics!