简体   繁体   中英

Can't build iOS/iPhone app as anything other than i386

I am completely new to the iOS/iPhone/XCode world, so if you guess is between something rather complex and something so simple that everyone should know, I'd go with the simple answer. :-)

Okay, so I have inherited an iPhone project that we had outsourced to another company. My only objective right now is to be able to build the dang thing. I set up XCode 4.2 and installed the proper SDKs. I loaded up the project and everything seems good to this point. However, when I build, I get errors from what I believe to be the linking stage of the build. I'm not entirely sure because the statuses change quickly when building. The error I get is the following:

来自XCode构建的错误

From what I have been able to find online, it seems that one of the libraries I am using was not compiled for the i386 platform. To start, this doesn't make sense to me because the libraries that I am using (where these errors are coming from) are currently included as sub-projects and produce .a files which I thought were arch-independent (am I wrong here??). Also, I can't find anywhere in the project where I've instructed XCode to build to an i386 architecture. This is what I've done so far:

  • Made sure that the file in which these errors arose was included into the "Compile Sources" section of the Build Phase tab (the .m file)
  • Set my architectures to armv6 and armv7 and set the Build Active Architecture Only to no . (See images below)

Main Project Config 主项目构建配置

Sub-Project Config 子项目配置



Event when I build using the release configuration, I still get this error and I'm not sure why. Everything that I am looking at in my build config seems to indicate that I should be building everything in an arm architecture.

You are getting errors because you messed with the architecture settings. You should not fix those towards ARM code but allow i386 as well.

Right now, one of more of your (sub)-projects build ARM code only, resulting into a linker error once you try to build a simulator version. That is happening because your Architecture settings are not as they should be.

Note your setting for Any iOS SDK , that one is incorrect as it builds only ARM code. Remove those settings entirely by using the backspace key on your keyboard after selecting that specific setting (single-click).

And this is how it should be: 在此输入图像描述

$(ARCHS_STANDARD_32_BIT) resolves to ARMV7 when building device specific code and i386 when building simulator specific code. Including ARMV6 code as per my screenshot is only needed if you plan to serve the results to older iOS devices (iPhone 3G and below).

Once those settings are active in all (sub)-projects , everything should work smoothly.

For creating a universal library out of a project, useful if you plan to distribute a static library to other developers, use LIPO .

Example:

lipo input_library_1.a input_library_2.a -create -ouput output_library.a

Lets say input_library_1 was i386 specific (simulator) and input_library_2 was ARM specific (device), this will join them into a universal version usable for both simulator and device.

It seems like you have been trying to link to static library built for devices(armv6 or armv7). When your building for the simulator the architecture will be i386. So you getting all these nasty linking errors. Solution is to include the library compiled for simulator as well in your project.

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