构建错误——文件中缺少必需的架构i386

时间:2022-02-14 19:55:38

I'm getting this error when building my iPhone application:

我在构建iPhone应用程序时遇到了这个错误:

ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit, missing required architecture i386 in file

ld:警告:在/开发/平台/ iPhoneOS.platform /开发/ sdk / iPhoneOS3.1。sdk/系统/库/框架/ ui .framework/UIKit,文件中缺少必需的架构i386

It goes the same for all the frameworks in my app. It's very weird since this was not happening earlier.

我的应用中所有的框架都是一样的,这很奇怪,因为之前没有发生过。

15 个解决方案

#1


130  

This happens when you add a framework to your project and unintentionally copy the framework into your project directory.

当您在项目中添加一个框架并无意中将该框架复制到项目目录中时,就会发生这种情况。

The fix is to check your project directory (where you store your project on disk) for any iphone SDK *.Framework files and delete them.

解决方案是检查您的项目目录(您将项目存储在磁盘上),以获得任何iphone SDK *。框架文件并删除它们。

Project will build fine afterwards.

项目建成后会很好。

#2


85  

I had this same problem, and the solution turned out to be an easy fix. Backup then open project.pbxproj (located inside your project file bundle) in TextMate or TextEdit and search for the section titled "/* Begin XCBuildConfiguration section */". Look for a key named FRAMEWORK_SEARCH_PATHS and delete it and it's contents (once per build configuration, so I removed it in two places). Here is an example of what I deleted:

我也遇到了同样的问题,而解决办法其实很简单。备份然后打开项目。pbxproj(位于项目文件包内)位于TextMate或TextEdit中,搜索标题为“/* Begin XCBuildConfiguration section */”的部分。查找名为FRAMEWORK_SEARCH_PATHS的键并删除它及其内容(每个构建配置一次,因此我在两个地方删除了它)。下面是我删除的一个例子:

FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks\"",);

My project now build for both the iPhone device and the iPhoneSimulator.

我的项目现在为iPhone设备和iPhoneSimulator构建。

#3


43  

What has happened here is that Xcode has mysteriously added a "Framework Search Paths" entry that points to a particular iPhone device SDK. For example, mine was recently set to:

这里发生的事情是Xcode神秘地添加了一个“框架搜索路径”条目,指向一个特定的iPhone设备SDK。例如,我的最近设定为:

$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks

This leads the compiler to find frameworks of the incorrect architecture. Removing any values under the "Framework Search Paths" key in your target's build settings will resolve the issue.

这将导致编译器找到错误体系结构的框架。在目标的构建设置中的“框架搜索路径”键下删除任何值将解决这个问题。

#4


10  

I just wanted to mention that in XCode if you go to "Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". Updating this should fix the problem, without having to hack the project file!

我只是想在XCode中提到如果你去“编辑项目设置”并找到“搜索路径”有一个“框架搜索路径”的字段。更新这个应该可以修复这个问题,而不必破坏项目文件!

Cheers!

干杯!

Jesse

杰西

#5


8  

Check that you didn't copy the framework into your project when you added it. If you copied it, it can't find the original paths. To fix this problem. Delete the AVFoundation framework from your frameworks folder in your project, then add it again, but this time, make sure you don't have copy check marked.

在添加框架时检查是否没有将框架复制到项目中。如果你复制它,它就找不到原来的路径。来解决这个问题。从您的项目的框架文件夹中删除AVFoundation框架,然后再添加它,但是这次,确保您没有标记的副本。

This fixed it for me!

这帮我搞定了!

#6


8  

I fixed it in a different way.The reason why i was getting this error was that i added security.framework twice in my project.I was not able to see security framework in xcode ,i opened the project in finder and found this framework which i deleted and problem solved.

我用另一种方法解决了这个问题。我得到这个错误的原因是我在我的项目中添加了两次security.framework。我无法在xcode中看到安全框架,我在finder中打开了这个项目,找到了我删除的这个框架并解决了问题。

#7


5  

Though it is possible that something got deleted, it has been my experience that something gets screwed up in the project file. I have yet to pin down what that "something" is. I've had similar issues when the SDK installation is just fine. There are a couple of options.

虽然有可能被删除了,但我的经验是,在项目文件中有一些事情被搞砸了。我还没弄清楚那个“东西”是什么。当SDK安装正常时,我也遇到过类似的问题。有几个选择。

First, add all of your files to a new project. This seems to usually work. Kind of a pain, though.

首先,将所有文件添加到新项目中。这似乎通常是有效的。虽然有点痛。

Second, you can right-click project in XCode/Get Info/Build/Library Search Paths. Add new paths similar to /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib. Add appropriate versions of that string for each version (2.2.1, etc) and platform (simulator or iPhoneOS). Perform a similar action for Framework Search Paths if frameworks are your problem.

其次,可以在XCode/Get Info/Build/Library Search路径中右键单击项目。添加类似于/Developer/ platform/ iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib的新路径。为每个版本(2.2.1,etc)和平台(模拟器或iPhoneOS)添加该字符串的适当版本。如果框架是您的问题,请对框架搜索路径执行类似的操作。

Third, which is more work but more reliable, is to open project.pbxproj from within MyProject.xcodeproj (Textmate is good for this). Look for "/* Begin XCBuildConfiguration section */", then "LIBRARY_SEARCH_PATHS" and "FRAMEWORK_SEARCH_PATHS". Add or modify the paths as appropriate, and save the file.

第三,开放式项目,工作量大,可靠性高。从内部pbxproj MyProject的。xcodeproj (Textmate适用于此)。查找“/* Begin XCBuildConfiguration部分*/”,然后是“LIBRARY_SEARCH_PATHS”和“FRAMEWORK_SEARCH_PATHS”。适当地添加或修改路径,并保存文件。

In any case, a pain in the butt, and I'd sure like to pin-point the cause because I've had this happen a couple of times. Project builds fine, then just up and refuses to do so with what seems to be little reason.

在任何情况下,都是一种痛苦,我肯定会把原因说出来,因为我已经经历过好几次了。项目构建得很好,然后就开始了,并拒绝这么做似乎没什么理由。

#8


5  

If your app is meant to run on the device, make sure you are not trying to run in it on the simulator. May sound obvious, but check anyway.

如果你的应用程序是要运行在设备上,确保你没有试图在模拟器上运行它。听起来很明显,但还是要检查一下。

#9


4  

"Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". delete all!!

“编辑项目设置”和“查找路径”有一个“框架搜索路径”字段。删除所有! !

#10


4  

It just happened here to me as well. Thanks to a great partner we found the answer. Your Xcode may be pointing to the simulator ..change it to a IOS device instead ..built smooth after ....

这也发生在我身上。多亏了一位伟大的合作伙伴,我们找到了答案。你的Xcode可能指向模拟器。把它改成IOS设备。建成后顺利....

#11


1  

Run the file command on the framework from Terminal:

从终端运行框架上的文件命令:

file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit

You should get back a message telling you which architectures the UIKit binary is compatible with. If you don't see "i386" listed, then you've somehow managed to remove the i386 version of UIKit, which will mean that you can't build for the simulator.To fix that, you'll have to re-install the SDK.

您应该得到一条消息,告诉您UIKit二进制文件与哪些体系结构兼容。如果您没有看到“i386”列表,那么您已经设法删除了UIKit的i386版本,这意味着您无法为模拟器构建。要解决这个问题,您必须重新安装SDK。

If you get some other error, hopefully it'll help you figure out what the actual problem is.

如果你有别的错误,希望它能帮助你找出真正的问题。

#12


1  

I just want to let you know that In my case, I was having the same problem, I realized that I had an older Xcode folder called Xcode3.1.3 I just rename it because it was an older version and that did the magic for me.

我只是想让你们知道,在我的案例中,我遇到了同样的问题,我意识到我有一个更老的Xcode文件夹,叫做Xcode3.1.3,我只是重新命名它,因为它是一个旧版本,它为我做了魔术。

#13


1  

Check your library search paths in your target settings. Sometimes goofy libraries get entered in there and this will give you a similar error.

在目标设置中检查库搜索路径。有时候一些愚蠢的库会被输入,这会给你一个类似的错误。

You can remove all entries in this section.

您可以删除此部分中的所有条目。

#14


0  

I'd just experienced something slightly different, because I work on my own library (WM_GSRecognizerLib), but the error is the same.

我只是经历了一些稍微不同的事情,因为我在自己的库(wm_gsrecognition zerlib)上工作,但是错误是相同的。

What'd happen: due to some updates, the path targeting the lib to include (.a) was from the "Debug-iphoneos" folder (where it is generated). Compiling for Generic iOS Devices worked fine, but not for simulator, complaining for the missing i386 architecture.

会发生什么:由于一些更新,要包含(a)的lib目标路径来自“Debug-iphoneos”文件夹(在那里生成)。为通用的iOS设备进行编译工作得很好,但对模拟器却不行,因为缺少i386架构。

What I did for this issue, is to also include the binaries from the "Debug-iphonesimulator" folder.

我为这个问题所做的是,也包括来自“Debug-iphonesimulator”文件夹的二进制文件。

It can help for this topic, because the explanation is here: devices require binaries for arm64/armv7/armv7s, while simulator does need i386.

它可以帮助这个主题,因为这里的解释是:设备需要arm64/armv7/armv7s的二进制文件,而模拟器需要i386。

#15


-1  

I too got the same error am using xcode version 4.0.2 so what i did was selected the xcode project file and from their i selected the Target option their i could see the app of my project so i clicked on it and went to the build settings option.

我在使用xcode版本4。2时也犯了同样的错误所以我选择了xcode项目文件从他们的目标选项中我可以看到我的项目的应用所以我点击了它然后进入了build settings选项。

Their in the search option i typed Framework search path, and deleted all the settings and then clicked the build button and that worked for me just fine,

在搜索选项中,我输入了框架搜索路径,删除了所有设置,然后点击了build按钮,这对我来说很好,

Thanks and Regards

感谢和问候

#1


130  

This happens when you add a framework to your project and unintentionally copy the framework into your project directory.

当您在项目中添加一个框架并无意中将该框架复制到项目目录中时,就会发生这种情况。

The fix is to check your project directory (where you store your project on disk) for any iphone SDK *.Framework files and delete them.

解决方案是检查您的项目目录(您将项目存储在磁盘上),以获得任何iphone SDK *。框架文件并删除它们。

Project will build fine afterwards.

项目建成后会很好。

#2


85  

I had this same problem, and the solution turned out to be an easy fix. Backup then open project.pbxproj (located inside your project file bundle) in TextMate or TextEdit and search for the section titled "/* Begin XCBuildConfiguration section */". Look for a key named FRAMEWORK_SEARCH_PATHS and delete it and it's contents (once per build configuration, so I removed it in two places). Here is an example of what I deleted:

我也遇到了同样的问题,而解决办法其实很简单。备份然后打开项目。pbxproj(位于项目文件包内)位于TextMate或TextEdit中,搜索标题为“/* Begin XCBuildConfiguration section */”的部分。查找名为FRAMEWORK_SEARCH_PATHS的键并删除它及其内容(每个构建配置一次,因此我在两个地方删除了它)。下面是我删除的一个例子:

FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks\"",);

My project now build for both the iPhone device and the iPhoneSimulator.

我的项目现在为iPhone设备和iPhoneSimulator构建。

#3


43  

What has happened here is that Xcode has mysteriously added a "Framework Search Paths" entry that points to a particular iPhone device SDK. For example, mine was recently set to:

这里发生的事情是Xcode神秘地添加了一个“框架搜索路径”条目,指向一个特定的iPhone设备SDK。例如,我的最近设定为:

$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks

This leads the compiler to find frameworks of the incorrect architecture. Removing any values under the "Framework Search Paths" key in your target's build settings will resolve the issue.

这将导致编译器找到错误体系结构的框架。在目标的构建设置中的“框架搜索路径”键下删除任何值将解决这个问题。

#4


10  

I just wanted to mention that in XCode if you go to "Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". Updating this should fix the problem, without having to hack the project file!

我只是想在XCode中提到如果你去“编辑项目设置”并找到“搜索路径”有一个“框架搜索路径”的字段。更新这个应该可以修复这个问题,而不必破坏项目文件!

Cheers!

干杯!

Jesse

杰西

#5


8  

Check that you didn't copy the framework into your project when you added it. If you copied it, it can't find the original paths. To fix this problem. Delete the AVFoundation framework from your frameworks folder in your project, then add it again, but this time, make sure you don't have copy check marked.

在添加框架时检查是否没有将框架复制到项目中。如果你复制它,它就找不到原来的路径。来解决这个问题。从您的项目的框架文件夹中删除AVFoundation框架,然后再添加它,但是这次,确保您没有标记的副本。

This fixed it for me!

这帮我搞定了!

#6


8  

I fixed it in a different way.The reason why i was getting this error was that i added security.framework twice in my project.I was not able to see security framework in xcode ,i opened the project in finder and found this framework which i deleted and problem solved.

我用另一种方法解决了这个问题。我得到这个错误的原因是我在我的项目中添加了两次security.framework。我无法在xcode中看到安全框架,我在finder中打开了这个项目,找到了我删除的这个框架并解决了问题。

#7


5  

Though it is possible that something got deleted, it has been my experience that something gets screwed up in the project file. I have yet to pin down what that "something" is. I've had similar issues when the SDK installation is just fine. There are a couple of options.

虽然有可能被删除了,但我的经验是,在项目文件中有一些事情被搞砸了。我还没弄清楚那个“东西”是什么。当SDK安装正常时,我也遇到过类似的问题。有几个选择。

First, add all of your files to a new project. This seems to usually work. Kind of a pain, though.

首先,将所有文件添加到新项目中。这似乎通常是有效的。虽然有点痛。

Second, you can right-click project in XCode/Get Info/Build/Library Search Paths. Add new paths similar to /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib. Add appropriate versions of that string for each version (2.2.1, etc) and platform (simulator or iPhoneOS). Perform a similar action for Framework Search Paths if frameworks are your problem.

其次,可以在XCode/Get Info/Build/Library Search路径中右键单击项目。添加类似于/Developer/ platform/ iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib的新路径。为每个版本(2.2.1,etc)和平台(模拟器或iPhoneOS)添加该字符串的适当版本。如果框架是您的问题,请对框架搜索路径执行类似的操作。

Third, which is more work but more reliable, is to open project.pbxproj from within MyProject.xcodeproj (Textmate is good for this). Look for "/* Begin XCBuildConfiguration section */", then "LIBRARY_SEARCH_PATHS" and "FRAMEWORK_SEARCH_PATHS". Add or modify the paths as appropriate, and save the file.

第三,开放式项目,工作量大,可靠性高。从内部pbxproj MyProject的。xcodeproj (Textmate适用于此)。查找“/* Begin XCBuildConfiguration部分*/”,然后是“LIBRARY_SEARCH_PATHS”和“FRAMEWORK_SEARCH_PATHS”。适当地添加或修改路径,并保存文件。

In any case, a pain in the butt, and I'd sure like to pin-point the cause because I've had this happen a couple of times. Project builds fine, then just up and refuses to do so with what seems to be little reason.

在任何情况下,都是一种痛苦,我肯定会把原因说出来,因为我已经经历过好几次了。项目构建得很好,然后就开始了,并拒绝这么做似乎没什么理由。

#8


5  

If your app is meant to run on the device, make sure you are not trying to run in it on the simulator. May sound obvious, but check anyway.

如果你的应用程序是要运行在设备上,确保你没有试图在模拟器上运行它。听起来很明显,但还是要检查一下。

#9


4  

"Edit Project Settings" and find "Search Paths" There is a field for "Framework Search Paths". delete all!!

“编辑项目设置”和“查找路径”有一个“框架搜索路径”字段。删除所有! !

#10


4  

It just happened here to me as well. Thanks to a great partner we found the answer. Your Xcode may be pointing to the simulator ..change it to a IOS device instead ..built smooth after ....

这也发生在我身上。多亏了一位伟大的合作伙伴,我们找到了答案。你的Xcode可能指向模拟器。把它改成IOS设备。建成后顺利....

#11


1  

Run the file command on the framework from Terminal:

从终端运行框架上的文件命令:

file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library /Frameworks/UIKit.framework/UIKit

You should get back a message telling you which architectures the UIKit binary is compatible with. If you don't see "i386" listed, then you've somehow managed to remove the i386 version of UIKit, which will mean that you can't build for the simulator.To fix that, you'll have to re-install the SDK.

您应该得到一条消息,告诉您UIKit二进制文件与哪些体系结构兼容。如果您没有看到“i386”列表,那么您已经设法删除了UIKit的i386版本,这意味着您无法为模拟器构建。要解决这个问题,您必须重新安装SDK。

If you get some other error, hopefully it'll help you figure out what the actual problem is.

如果你有别的错误,希望它能帮助你找出真正的问题。

#12


1  

I just want to let you know that In my case, I was having the same problem, I realized that I had an older Xcode folder called Xcode3.1.3 I just rename it because it was an older version and that did the magic for me.

我只是想让你们知道,在我的案例中,我遇到了同样的问题,我意识到我有一个更老的Xcode文件夹,叫做Xcode3.1.3,我只是重新命名它,因为它是一个旧版本,它为我做了魔术。

#13


1  

Check your library search paths in your target settings. Sometimes goofy libraries get entered in there and this will give you a similar error.

在目标设置中检查库搜索路径。有时候一些愚蠢的库会被输入,这会给你一个类似的错误。

You can remove all entries in this section.

您可以删除此部分中的所有条目。

#14


0  

I'd just experienced something slightly different, because I work on my own library (WM_GSRecognizerLib), but the error is the same.

我只是经历了一些稍微不同的事情,因为我在自己的库(wm_gsrecognition zerlib)上工作,但是错误是相同的。

What'd happen: due to some updates, the path targeting the lib to include (.a) was from the "Debug-iphoneos" folder (where it is generated). Compiling for Generic iOS Devices worked fine, but not for simulator, complaining for the missing i386 architecture.

会发生什么:由于一些更新,要包含(a)的lib目标路径来自“Debug-iphoneos”文件夹(在那里生成)。为通用的iOS设备进行编译工作得很好,但对模拟器却不行,因为缺少i386架构。

What I did for this issue, is to also include the binaries from the "Debug-iphonesimulator" folder.

我为这个问题所做的是,也包括来自“Debug-iphonesimulator”文件夹的二进制文件。

It can help for this topic, because the explanation is here: devices require binaries for arm64/armv7/armv7s, while simulator does need i386.

它可以帮助这个主题,因为这里的解释是:设备需要arm64/armv7/armv7s的二进制文件,而模拟器需要i386。

#15


-1  

I too got the same error am using xcode version 4.0.2 so what i did was selected the xcode project file and from their i selected the Target option their i could see the app of my project so i clicked on it and went to the build settings option.

我在使用xcode版本4。2时也犯了同样的错误所以我选择了xcode项目文件从他们的目标选项中我可以看到我的项目的应用所以我点击了它然后进入了build settings选项。

Their in the search option i typed Framework search path, and deleted all the settings and then clicked the build button and that worked for me just fine,

在搜索选项中,我输入了框架搜索路径,删除了所有设置,然后点击了build按钮,这对我来说很好,

Thanks and Regards

感谢和问候