Fixing "missing required architecture arm in file" Error When Developing for iPadBy Ross on June 15th, 2010 in Technobabble
Tags: development, iOS, iPad, sqlite, xcode
I recently started working on a iPad app here at Long Weekend. All was going well and development was moving along a reasonable rate. One of the items we used in this app was a sqlite database, which I have used previously in iPhone apps no problem.
I added the
libsqlite3.dylib using the
Add -> Existing Frameworks... menu in XCode and continued to develop as normal. The app compiled and ran on the simulator no problem and everything was working great. I then decided to put the app on an actual iPad so I could test (and show it off to some people).
I switched the Active SDK to Device 3.2 Debug and tried to build. That’s when the trouble started.
Here’s the errors I got:
ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib/libsqlite3.dylib, file is not of required architecture ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib/libgcc_s.1.dylib, missing required architecture arm in file ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib/libSystem.dylib, missing required architecture arm in file ld: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.3.sdk/usr/lib/libobjc.A.dylib, missing required architecture arm in file
I tried a few things first and ended up with the following build settings:
iPad apps required the armv7 architecture and don’t like to be built with the armv6 architecture as well unless you are targeting a version under iOS 3.2. I wasn’t so I made sure everything was armv7. Don’t worry if you can’t see it in your drop list, just click “Other”, remove the existing selections, and add another one called armv7.
I did this all this and was pretty confident that the settings were right, but was still getting the “missing required architecture arm in file” error, so I had to look elsewhere.
If you look closely at the errors, there is one obvious issue that eluded me at first. At a glance the paths seem fine as these are system libraries that are only linked because the correctly selected framework calls for them. When I looked again, however, I noticed the path included iPhoneSimulator3.1.3.sdk but the framwork I had added was in the path iPhoneOS3.2.sdk. Why was the compiler looking in a 3.1.3 path?
I have found that if a build issue is not to be found in the Project Settings, it’s worth looking at the Active Target settings. We learned this lesson from the whole Code Signing rigamorale. If you look at the highlighted setting “Library Search Paths” you’ll notice a path that looks a lot like the offending path from our error. So I updated the Library Search Path with: “$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/lib” which is the directory that the libsqlite3.dylib is in and voila, it builds for the device.
So we’re done right? Not so fast; once I switch back to the Simulator, the issue reappears. I then decided to start fresh and made a new project, added the framework, then checked the Active Target settings. This revealed that by default, this setting isn’t there at all but the new project is building fine. I then deleted the Library Search Paths setting in my project, finally, no more errors on either Simulator or Device.
This cost my some good hours of my life and I hope this post will save you some time. Happy coding.