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:
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.
Related
I'm trying to build an ad-hoc build with test flight.
I have the OS Device selected and am trying to create an archive.
However I get the following warning.
(null): iPhone/iPod Touch: application executable contains unsupported
architecture(s): armv7s (-19031)
I have the following settings for my test flight target.
I can build fine for release.
It looks like you're using an old version of the TestFlight library.
The iPhone 5 uses a new processor (A6), with a modified instruction set (AMRv7s).
Since you are building your app with that architecture too, all linked libraries also needs to support it.
TestFlight provides a new version (1.1) of its library, with support for that specific architecture.
So simply download the new version of the library, link against that, and you'll be fine.
Your "Release" target is compiling and linking fine, because no symbol from the TestFlight library is actually used. But if you need TestFlight support for the iPhone 5, just update to the latest version of the library.
This warning is perfectly normal when you use an armv7 device to archive your application.
Think about it, you make an archive that includes the armv7s architecture (which is what we want) and the warning tells you that your armv7 device does not support that architecture (which totally makes sense).
To prove that even further, just hook up an iPhone 5 and try archiving and you will see that the warning will go away.
As far as I can tell Xcode 4.5 will not currently allow you to create Archive builds that include armv7s.
My project uses two 3rd party libraries (Dropbox and Flurry) and I reverified I had the latest iOS 6 builds included. I verified that all my other frameworks (and libsqlite3.0.dylib) were all located in the iOS 6.0 area. None of this helped.
I then created a brand new empty project from scratch and attempted an Archive build and received the exact same error. So after wasting 6 hours trying to fix this, I am tentatively concluding it is not possible to get rid of the warning.
Based on comments else where, apparently, it is not necessary to build for armv7s to run on an iPhone 5.
Any information to the contrary of anything I have posted here would be appreciated.
All you need to do is remove armv7s from the valid architectures.
Same question has been asked several ties I think.
I was displayed the same warning message when I archived in preparation for Ad-Hoc testing.
(null): iPhone/iPod Touch: application executable contains unsupported
architecture(s): armv7s (-19031)
I have removed armv7s as recommended above and the warning went away. What repercussion are there in doing this? What is armv7s supporting?
With semingly no changes to any settings or code from yesterday, what may have caused this warning to pop up?
I am trying to update my app to work with the iPhone5, which entails ensuring that it is compiled for armv7 and armv7s architectures. I have updating my build settings in my project and have recompiled all statically linked libraries with these settings as well. So it now compiles and links successfully.
However, upon running it on a device (iPad) running iOS6 (though of course only supporting the armv7 architecture) I get an immediate crash with this output:
dyld: vm_protect(0x00001000, 0x003BB000, false, 0x07) failed, result=2 for segment __TEXT in /var/mobile/Applications/....[name/location of my app]....
I also get this in the trace window:
dyld`dyld_fatal_error:
0x2fe400c4: trap
0x2fe400c8: nop
I have no iPhone5 to test the armv7s portion of the binary. Of course I will test it on a real device before releasing into the wild, but I'd like to be able to continue work using my current armv7 iPad/iPhone running iOS6 in the meantime. I am using the recently released Xcode 4.5.
So, anyone have any idea what is going on, or possibly have the same problem?
Redownloading and subsequently recompiling one of the libraries I was including fixed the problem. Apparently either I had changed something incorrectly in the build configuration for the library when adding the armv7s architecture, or some part of the library's project became corrupted somehow. (The affected library was the Freetype2 library as included with the FTGLES2 Xcode project.)
You probably accidentally disabled dynamic linking when you statically recompiled the libraries (resulting in a -static flag being passed to clang when compiling).
Fix by switching "Enable linking with shared libraries" to "Yes" (the default) in the LLVM compiler language settings. (This removes GCC_LINK_WITH_DYNAMIC_LIBRARIES = NO from the project file).
it's me again with my iOS trouble. I've finally managed to build the master branch of this XML-RPC framework https://github.com/eczarny/xmlrpc which produced an XMLRPC.framework for me. I managed to include that framework in my iOS project, all good, but when I build it...
ld: warning: ignoring file /Users/kovshenin/Library/Developer/Xcode/DerivedData/XMLRPC-emidbddzjlofthfgowywcfscewgd/Build/Products/Development/XMLRPC.framework/XMLRPC,
file was built for unsupported file format which is not the architecture being linked (i386)
So I went back to the XMLRPC project and tried to select different Base SDKs and Architectures for the target, but with no luck, seems like it's only building it for 64-bit Intel. Even tried the iOS SDK which gives me a "The selected run destination is not valid for this action." error.
Sorry again for my "newbish" talk, but the official dev forums can't seem to help me out. Thanks!
P.S. I'm using Xcode 4.
Architecture is related to the processor on which you are running your code. If you are building for the simulator, then you are building for your Mac, which is Intel, i386. If you are building for a physical iOS device, then you are building for arm6 or arm7, depending on how new the devices are. Fourth generation iPhone 4 and iPad were the first arm7 devices.
As far as setting the build settings, I'd recommend taking a look at the build settings. In Xcode. Here's a screenshot:
Click on your project, then on your build. Under the architectures section, you can configure your architectures as necessary. You should note though, that the original developer would have to have built it for the simulator as well as the device, or you won't be able to run it on the simulator.
It looks as though the library may not fat meaning it'll only build for the device, and not for the simulator. Connect your device and select it in the drop down, then build again and see if the error disappears.
I'm getting the following error when including static libraries:
missing required architecture i386 in
file
This worked 30 seconds previously, and only failed when I upgraded to Xcode 3.2.3. I've used "file" command to check - and, yes, XCode is building completely the wrong architecture (armv6 + armv7 instead of i386).
This seems to be a major bug in latest Xcode, where Apple has re-written the build / compile / link settings. There's a note in the release notes saying very vaguely that they've "Changed it" because it used to be "confusing". This is not helpful.
The build settings for the library VERY clearly say:
"Valid architectures: i386"
There's no confusion here - Xcode is building something other than what the target says it should.
The question is: how do you un-break this? How do you force Xcode to do what it's supposed to? I've re-installed Xcode from scratch, cleaned everything, and manually inspected the build files. There's nothing wrong (and, of course, it worked perfectly in xcode 3.2.2)
After considerable research, I believe the answer is:
"this is now impossible - Apple has deliberately hard-coded XCode to ignore build settings"
However, I've come up with a script that automatically builds ALL platforms of a project (which you HAVE to do with static libraries - you don't have much choice now, because Apple has disabled Targets), and the script could easily be modified to do all targets, instead of all platforms:
Build fat static library (device + simulator) using Xcode and SDK 4+
Right click on your Target app under Targets and make sure that the Base SDK is set to iOS.
I have searched for hours however I still have no clue what is wrong with my configuration.
My project uses a self-written libray (myLib). This library is compiled to work only for simulator and it works perfectly there.
What do have to change so it compiles for my iPhone Device as well?
This is my current warning:
ld: warning: in /.../myLib.a, file is not of required architecture
This is my configuration (of myLib.a)
I found a lot of articles explaining the reason for this error however I could not find a solution:
The simulator runs on an x86
architecture, while the device uses an
ARM architecture.
What do I have to change to get my library working on my iPhone?
Thanks
Edit:
What I did so far:
Cleaned both projects
Set library to 'Device' (3.1)
Built the library
Dragged the .a file of my library into my application
Result:
This works in simulator but setting the active sdk to device still raises a file is not of required architecture error.
I also tried mahboudz ( thanks for your support) link.
It explains howto built the project using a shell script.
However XCode keeps complaining that the library file is of the wrong architecture and the build fails.
This has to be a really stupid beginners mistake.
You need to add both .a files,the one built for the device (build/$config-iphoneos)and the one built for the sim (build/$config-iphonesimulator) to the new project. Make sure you name them differently before dropping them in. This is how admob and similar offering ship their static libs.
You need to compile your library for Intel so the Simulator can use it (which I gather you have done already), and then compile it for ARM, so it can run on the iPhone. Then you have to merge the two libraries. There are different ways to accomplish that, or make it more automatic.
Here are some links to help you:
http://blog.stormyprods.com/2008/11/using-static-libraries-with-iphone-sdk.html
http://www.clintharris.net/2009/iphone-app-shared-libraries/
I've met the same problem too. But seems you don't need to drag two .a files into the app project to solve this problem. This is what I did:
Drag the static library project into app project's framework group
"Get Info" for the target in app project
Set the direct dependency of static library
Make clean all unnecessary builds(for example the simulator build) in the static library project
Build in the app project