Distribution Error: "Reached end of file while looking for: Mach-O Slice"

Hey everbody,

I'm getting an error trying to distribute a React Native App to App Store Connect. Archiving the App works fine, when I try to distribute the App I'm getting the following Error:

Cheers for any help

Replies

Hmmm, that’s weird. The most likely explanation is that there’s a malformed Mach-O file within your Xcode archive. Open a Terminal window, change into the Products/Applications directory within the archive, and do this:

% find MyApp.app -type f -print0 | xargs -0 file | grep Mach-O

What do you see?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Excuse me, has the problem been solved?

Add a Comment

I am seeing a similar error while trying to validate app before distributing. The above command returns the below output but doesn't indicate any error find MyApplication.app -type f -print0 | xargs -0 file | grep Mach-O MyApplication.app/Frameworks/IDMMobileSDKv2.framework/IDMMobileSDKv2: Mach-O universal binary with 2 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7

  • Mach-O dynamically linked shared library arm_v7] [arm64:Mach-O 64-bit dynamically linked shared library arm64
  • Mach-O 64-bit dynamically linked shared library arm64]

MyApplication.app/Frameworks/IDMMobileSDKv2.framework/IDMMobileSDKv2 (for architecture armv7): Mach-O dynamically linked shared library arm_v7 MyApplication.app/Frameworks/IDMMobileSDKv2.framework/IDMMobileSDKv2 (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64 MyApplication.app/MyApplication: Mach-O 64-bit executable arm64

Appreciate any help!

Bumping because I found the same issue and ran

% find MyApp.app -type f -print0 | xargs -0 file | grep Mach-O

Which produced the following output (removed some empty spaces for easier reading) in the attached file.

I checked the project settings and search paths and they all seem fine.

Tried other solutions I found online, to no avail.

App runs fine on the simulator, and I can archive it with no issues.

Any help, please?

I’m confused by the find output you posted. It shows this:

appName.app/appName

which makes sense; that’s the path where I’d expect to find the main executable of an app called appName. But it also shows this:

appName.app/appName-ios/build/bin/…
… and so on …

which doesn’t make sense. It looks like a huge chunk of your build products have been added to your app’s bundle. Those have no business being there, and it seems likely that this is the cause of your issue.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I have several SPM packages and one Cocoapods framework, which is not embedded (or signed for that matter), but we develop it in-house.

Thanks for the help, I'll look into it and post results.

In addition to the problem with your bundle already pointed out by @eskimo, search your app bundle for any Java class files, i.e. those with the file name pattern *.class. Through an artifact of history, the magic bytes at the start of a Mach-O file, 0xCAFEBABE, are also used to identify a compiled Java class. As a result, this could confuse a tool expecting only Mach-O files with those magic bytes. If you find a Java class file has made its way into your iOS build product on accident, figure out how it is getting into your build output and remove it.

Regardless of what you discover as the source of the error, please use Feedback Assistant to request a better error message or log files from Xcode that points at a specific file path and describes what went wrong, and then post the FB numbers here. Make sure to attach a copy of the archive generating this error message.

In my case, I fixed the issue by deleting unwanted folders and files (which contained binaries) from 'Copy Bundle Resources' in 'Build Phases'.

  • Thanks for letting us know.

  • Where are my manners? 😅 Your insights helped me on this. Thanks for the help, folks!

  • This fixed the issue for met too. I was building a Google Web Toolkit based application wrapped using Cordova to publish as an iOS application. My script to prepare the Cordova bundle had a typo that was leaving the WEB-INF folder (with Java class files) in the web application bundle. Everything worked perfectly in Xcode until you tried to Validate or Distribute the app, where this error would appear. Fixing my script to exclude the Java class files fixed the issue.

Add a Comment

I'm also facing the same issue .any update on this?