28

What causes the error

Found an unexpected Mach-O header code: 1918975009 in xCode 6

I archived my project to send out as an ad hoc build and it builds/links/archives just fine but when I'm in the xCode organizer and select Export -> Ad Hoc,

I get the error

Found an unexpected Mach-O header code: 191897500. 
Anik Islam Abhi
  • 25,137
  • 8
  • 58
  • 80
rtvanals
  • 341
  • 1
  • 3
  • 7

10 Answers10

37

In my case this issue ("found an unexpected mach-o header code 0x72613c21") appeared after I've installed Crashlytics, Fabric.

Somehow pods appeared to become an embedded binary. So I had to remove it, pod install once more, and the issue disappeared.

Remove pods from embedded binaries

Naloiko Eugene
  • 2,453
  • 1
  • 28
  • 18
35

I had the same error. In my case it was caused by an universal framework that I accidentally copied into the resources of the app (which is unnecessary, since frameworks get merged directly into the main executable on iOS AFAIK).

So, select your target, click the "Build Phases" tab, and look through the "Copy Bundle Resources" list to see if you copy a library or framework that contains desktop architectures (i386 or x86_64).

Most likely, copying such a file is wrong, but if for some reason you have to, apparently it can only contain iOS compatible architectures.

mkeiser
  • 965
  • 9
  • 17
  • @YohanesKhosiawan许先汉Yes. I was using the wrong version of a framework in my project. Once I switched it to the non-desktop version, the issue was fixed. – rtvanals Nov 06 '14 at 14:34
  • 1
    This is also encountered due to any Mach-O setting set to "Static" in the build setting. – Ravi Dalmia Feb 26 '15 at 14:47
  • I'm getting this for the MoPub framework. Any other suggestions? How do I see if the framework contains desktop architectures? – conorgriffin Aug 01 '15 at 17:16
  • Hello, I am getting this warning for GoogleMaps on adding GoogleMaps.Bundle to Copy Bundle Resources . How to resolve this? – TechSavy May 11 '16 at 06:52
11

Had a similar error 1918975009 with the new Swift build system in Xcode 9.3 (under Workspace Settings...) on a third-party framework that was manually added (not using Cocoapods). Maybe related to the above thread so in case it helps anyone... This only appeared after upgrading to Xcode 9.3 after it released officially yesterday. Xcode 9.2 and earlier on the new build system did not throw the warning.

:-1: <path>/Frameworks/<frameworkName>.framework/<frameworkName>: Failed to parse executable: Unknown header: 1918975009

Switching back to the old non-Swift-based build system fixes the issue. Not an optimal solution but if you're seeing a similar warning, will let you move on for now.

Mark Thormann
  • 2,522
  • 1
  • 21
  • 23
  • 4
    I have the same issue since upgrading to Xcode 9.3, but switching back to the old build system is not the solution I'm looking for. Anyone have other ideas? – Jeehut Apr 03 '18 at 11:09
  • I have the same issue since I have updated to Xcode 9.3. I would guess that having a new version of that framework built with swift 4.1 would help. Although since it is third party framework I can't test till I get update from authors. – iur Apr 03 '18 at 11:58
4

I have been experiencing the same error and wasn't able to trace it to library / framework in copy bundle resources, or an incorrect version of a library.

As a workaround, I've found that I can do an export build from the command line and it seems to work:

xcodebuild -exportArchive -exportFormat ipa \
-archivePath /path/to/app.xcarchive/ \
-exportPath /path/to/app.ipa \
-exportProvisioningProfile "Name of provisioning profile"

Here "Name of provisioning profile" is the name of the provisioning profile as it appears in Xcode (not the path to the profile)

  • works for me, but why? i not understand this method. If you share in testflight, or more importantly, if it is sent to appStore. What are the risks? It is operating normally? – jose920405 May 11 '16 at 19:54
2

Go to BUILD PHASES -> COPY BUNDLE RESOURCES, you will find there some framework. Remove from this section and add it to LINK BINARY WITH LIBRARIES. It will work..

1

sometimes, you should look Build Phases - Embed Pods Frameworks. and find the shell file. eg.

Build Phases

and open Pods-midea-common-adddevice_Example-frameworks.sh See if this file is a problem.

邓立兵
  • 76
  • 5
0

I just ran into this issue as well, and I was able to solve it...

In my case, I had created a new target by duplicating an existing one. I had changed the name from "MyApp-dev copy" to "MyApp-test", however, I forgot one thing... When you create a new target, a new .plist file is also created. I forgot to rename that file, and then link it back to my newly created target.

Once I had done that, the problem went away. I had originally been reading about targets at: http://www.raywenderlich.com/68613/create-paid-lite-version-iphone-app and going back through that page is what helped me solve the problem.

Perlguy
  • 982
  • 10
  • 25
0

solved problem in my case

Build Phases -> Copy Bundle Resources for a framework or other binary that shoundn't be there

i delete TwitterKit and DigitKit binary.

Edit: When i delete this binary from Copy Bundle Resources, project can be build, archived, pass to validation and also sent to App Store. But when i run the project it's fails. So, if i delete from Copy Bundle Resources and than add to Link Binary With Library sections(we choose "Add other" and than press cmd + shift + g combination to go where your bundle or binary) it's solved.

Emre Gürses
  • 1,992
  • 1
  • 23
  • 28
0

To add fabric or crashlytics into your project, when drag or add frameworks to project folder or to Xcode , keep 'copy items if needed' box unchecked.enter image description here

anas.p
  • 2,246
  • 19
  • 26
0

Check that you are not embedding an static framework in the "Embedded Binaries" section in the General tab of the target.

AFAIK You can check if the framework is static if the binary icon inside the .framework is white, if the icon is black then is a dynamic framework.

rockdaswift
  • 9,613
  • 5
  • 40
  • 46