在 xCode 6 中发现了一个意外的 Mach-O 头代码:1918975009

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26559948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:59:51  来源:igfitidea点击:

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

iosxcodexcode6mach-o

提问by rtvanals

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 hocbuild and it builds/links/archives just fine but when I'm in the xCodeorganizer and select Export -> Ad Hoc,

我存档了我的项目以作为ad hoc构建发送,它构建/链接/存档很好,但是当我在xCode组织者中并选择时Export -> Ad Hoc

I get the error

我收到错误

Found an unexpected Mach-O header code: 191897500. 

回答by Naloiko Eugene

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

在我的情况下,这个问题(“发现意外的 mach-o 标头代码 0x72613c21”)出现在我安装 Crashlytics、Fabric 之后。

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

不知何故,pods 似乎变成了一个嵌入式二进制文件。所以我不得不删除它,再次安装 pod,问题就消失了。

Remove pods from embedded binaries

从嵌入式二进制文件中删除 pod

回答by mkeiser

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).

我有同样的错误。在我的情况下,它是由我不小心复制到应用程序资源中的通用框架引起的(这是不必要的,因为框架直接合并到 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).

因此,选择您的目标,单击“Build Phases”选项卡,然后查看“Copy Bundle Resources”列表以查看您是否复制了包含桌面架构(i386 或 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.

最有可能的是,复制这样的文件是错误的,但如果出于某种原因必须这样做,显然它只能包含与 iOS 兼容的架构。

回答by Mark Thormann

Had a similar error 1918975009with 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.

在手动添加的第三方框架(不使用 Cocoapods)上的 Xcode 9.3(在工作区设置...下)中使用新的 Swift 构建系统时出现了类似的错误1918975009。可能与上述线程有关,以防万一它对任何人有帮助...这仅在昨天正式发布后升级到 Xcode 9.3 后才出现。新构建系统上的 Xcode 9.2 及更早版本没有抛出警告。

:-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.

切换回旧的非基于 Swift 的构建系统可解决此问题。不是最佳解决方案,但如果您看到类似的警告,请暂时继续。

回答by damneddemand

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)

这里的“配置文件名称”是在 Xcode 中出现的配置文件的名称(不是配置文件的路径)

回答by Devansh Bhardwaj

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..

转到 BUILD PHASES -> COPY BUNDLE RESOURCES,你会发现那里有一些框架。从本节中删除并将其添加到 LINK BINARY WITH LIBRARIES。它会工作..

回答by u8391178

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

有时,你应该看看Build Phases- Embed Pods Frameworks。并找到shell文件。例如。

Build Phases

构建阶段

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

并打开Pods-midea-common-adddevice_Example-frameworks.sh查看此文件是否有问题。

回答by anas.p

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

要将结构或 crashlytics 添加到您的项目中,当将框架拖动或添加到项目文件夹或 Xcode 时,请取消选中“如果需要复制项目”框。在此处输入图片说明

回答by rockdaswift

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.

AFAIK 如果 .framework 内的二进制图标是白色,您可以检查框架是否是静态的,如果图标是黑色,则是动态框架。

回答by Perlguy

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.

就我而言,我通过复制现有目标创建了一个新目标。我已将名称从“MyApp-dev copy”更改为“MyApp-test”,但是,我忘记了一件事...当您创建新目标时,也会创建一个新的 .plist 文件。我忘记重命名该文件,然后将其链接回我新创建的目标。

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-appand going back through that page is what helped me solve the problem.

一旦我这样做了,问题就消失了。我最初一直在阅读有关目标的信息:http: //www.raywenderlich.com/68613/create-paid-lite-version-iphone-app并返回该页面帮助我解决了问题。

回答by Emre Gürses

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.

我删除了 TwitterKit 和 DigitKit 二进制文件。

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.

编辑:当我从 Copy Bundle Resources 中删除这个二进制文件时,项目可以被构建、存档、传递到验证并发送到 App Store。但是当我运行该项目时,它失败了。因此,如果我从 Copy Bundle Resources 中删除,然后添加到 Link Binary With Library 部分(我们选择“添加其他”,然后按 cmd + shift + g 组合转到您的包或二进制文件的位置),问题就解决了。