简体   繁体   中英

XCode Distributing app failure with error: "Found an unexpected mach-o header code". Using carthage

App builds and runs without any problem. I Can archive the app but when I try to distribute for testing I get error: "Found an unexpected mach-o header code: 0x0987654"

When I digged deep in the console dump, I noticed warnings that I assume they are related to my problem:

Class PLCrashReportMachExceptionInfo is implemented in both /private/var/containers/Bundle/Application/xxx/Foo.app/Frameworks/DatadogCrashReporting.framework/DatadogCrashReporting and /var/containers/Bundle/Application/xxx/Foo.app/ One of the two will be used. Which one is undefined.

I have recently integrated RumSDK and when I remove RumSDK.xcframeworks from my app I dont get any errors and everything is solved, but Rum SDK is a dynamic library that needs to be embeded into the app. When I dont embed it app will crash because linker cant find the source. It has many dependencies that I assume some of them like DatadogCrashReporting.framework are nested dependencies. If any one can help me get out of misery I would really appreciate it.

my problem is very simmilar to this one: Xcode - Found an unexpected Mach-O header code: 0x72613c21 - Embedded API

I have tried many things, among them many times of cleaning build folder and driveddata folder and updating carthage... so please dont give me these simple answers.

I have searched many hours to find a solution for these problems, there are many solutions for cocoa pod to remove the nested/duplicated frameworks from the bundle, however I use carthage and I dont see any solutions for this problem using carthage.

Here are the examples of the solutions that I searched for: Class is implemented in both, One of the two will be used. Which one is undefined

Class Foo is implemented in both MyApp and MyAppTestCase. One of the two will be used. Which one is undefined

Found an unexpected Mach-O header code: 0x72613c21 in Xcode 7

Submitting to AppStore: Found an unexpected Mach-O header code: 0x72613c21

I also have another concole log:

 malloc: nano zone abandoned due to inability to preallocate reserved vm space.

but I havent been able to solve this and dont know if they are related or not.

After digging deep into this problem I found out Mach-O error such as this one are related how we embed/link the files and frameworks into our project.

In my case study: Integrated RumSDK (datadog) for analytics alongside AppCenterSDK for crashes - I am in the process of migrating completely to RUM!

RumSDK includes many dependency such as CrashReporter and DataDogCrashReporter. First one is from apple itself and the later is made by DataDog team.

Note that RumSDK is a Dynamic library and AppcenterSDK is static library.

Dynamic libraries should always be embeded and linked, they will be linked to app's binary after compilation and in runtime. They will be linked under frameworks folder in your app bundle.

Static libraries shouldnt be embeded because they will atomatically be linked at compile time to the app's binary itself.

Now imagine the CrashReporterSDK is used by both CrashReporters of Appcenter and RumSDK. This means that CrashReporter will be included in your app bundle twice, once in the app binary and once included in frameworks. This causes a problem of finding and linking the necessary frameworks.

My case study is an example but I could think that this might happen while trying to add 3rdParty libraries and dependencies to your project. Then you should make sure every thing your app needs is embeded or linked and the ones that it doesnt need should be eliminated. And the places to look in xcode are:

  1. app settings -> general tab -> embeded frameworks
  2. app settings -> build phases -> linked binaries and framework
  3. app settings -> build settings -> linking paths and search paths

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM