iOS: App Store Mach-O error

“Found an unexpected Mach-O header code: 0x72613c2” App Store upload error

📘

This guide may apply to all frameworks that create or generate iOS applications and use Swift Package Manager.

When uploading your app with embedded Smartlook or another static library Swift Package, you may experience the following:

Found an unexpected Mach-O header code: 0x72613c2

error that protects you from uploading the app to the App Store.

The cause of this error is a bug in Xcode that does not handle static libraries being added via Swift Package Manager properly. The static libraries are linked right, but then they are packaged to the app archive to be set to the App Store as if they are dynamic.

To fix this, use the following steps:

  1. Add Swift Package as normal
  2. Navigate to you app target General info pane
  3. In the left column Project Navigator, reveal the Swift Package structure
  4. Drop the xcproject to Frameworks, Libraries, and Embedded Content list next to the library already added by the Swift Package Manager
  5. Change its Embed type to Do Not Embed
  6. Remove the original reference (ignore the warning about removing the dependency)
  7. Delete the Xcode derived data folder content (usually in ~/Library/Developer/Xcode/DerivedData)
    From now on, Xcode should treat the static library added in Swift Package as expected.
2028