407

I upgraded Xcode version and when using external static libraries, I get this message:

ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /file/location for architecture armv7s clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there any way to bypass this and add support to the library if the developer of the library hasn't updated their library yet?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dafna Elazazer
  • 4,083
  • 2
  • 13
  • 6

8 Answers8

419

If you want to remove the support for any architecture, for example, ARMv7-s in your case, use menu Project -> Build Settings -> remove the architecture from "valid architectures".

You can use this as a temporary solution until the library has been updated. You have to remove the architecture from your main project, not from the library.

Alternatively, you can set the flag for your debug configuration's "Build Active Architecture Only" to Yes. Leave the release configuration's "Build Active Architecture Only" to No, just so you'll get a reminder before releasing that you ought to upgrade any third-party libraries you're using.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nicholas
  • 5,770
  • 1
  • 20
  • 30
  • nice solution but is there a way to add support without compiling the library ? – user513790 Sep 13 '12 at 09:33
  • 11
    you don't have to recompile the library. you can remove this flag from the project that is using the library. – Nicholas Sep 13 '12 at 09:57
  • I guess that the app will not work on the iPhone 5 then, am I right ? – Dimillian Sep 13 '12 at 11:34
  • 4
    It will work, since old apps that have not been compiled with armv7s support have to run as well. But you will loose some specific optimizations. This should be a temporary workaround anyway. – Nicholas Sep 13 '12 at 12:46
  • Can you explain this in more detail? Or is there something else I need to do? I have both Architectures and Valid Architectures set to armv7 but still have this problem. – MaxGabriel Sep 13 '12 at 17:46
  • 2
    Dropbox framework has been updated for this issue see https://forums.dropbox.com/topic.php?id=90014 – railwayparade Sep 17 '12 at 06:31
  • 1
    For some projects, the problem might be the Architectures setting, and not the valid architectures setting. The meaning of $(ARCHS_STANDARD_32_BIT), despite being labeled as "Standard (armv7)" now appears to include armv7s also. Removing $(ARCHS_STANDARD_32_BIT) in favor of an explicit armv7 did the trick for me. – LoriHC Sep 18 '12 at 12:47
  • 6
    Removing armv7s from the Valid Architectures list worked for me, however so did removing it from Architectures. In both cases, however, I would get `No architectures to compile for (ARCHS=i386, VALID_ARCHS=armv7).` from the linker which I could only solve by adding `i386` to the Valid Architectures list. – levigroker Sep 18 '12 at 17:36
  • My project only supports armv7 and armv7s (not armv6) as 'valid architectures', yet getting this error when building for Device in SDK 6. (Using libOAuth.a) – Nicolas Miari Sep 20 '12 at 08:16
  • Oh, sorry; didn't read all the comments before commenting. I too removed armv7 **s** and now it's working – Nicolas Miari Sep 20 '12 at 08:18
  • What is 'armv7s' anyway? Nothing to do with the iPhone 4S I guess? ;) – Nicolas Miari Sep 20 '12 at 08:26
  • 6
    No, armv7s is the instruction set of the A6 processor that is being used in the iPhone 5. Since the A6 is backwards compatible, it will still run the armv7 instruction set. – Nicholas Sep 20 '12 at 09:41
  • thank for this answer, but i don't understand i have to remove the armv7s only in the setting of the static library, or also for the Main Project Target? – Piero Sep 22 '12 at 09:31
  • but theres only one flag in my project. not sure whether they r for build or for release – OMGPOP Sep 28 '12 at 13:25
  • I just set Build Active Architecture Only" to Yes . Now my project is running successfully. – iPhoneDev Oct 01 '12 at 06:54
  • for me I had to remove armv7s and set "Build Active Architecture Only" to No and it worked. – mafiOSo Oct 16 '13 at 23:02
190

I've simply toggled "Build Active Architecture Only" to "Yes" in the target's build settings, and it's OK now!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Blasco73
  • 2,980
  • 2
  • 24
  • 30
  • 1
    @Blasco73 Do you even know that you are awesome? You should. Here goes, You sir, are awesome! – thandasoru Dec 24 '12 at 07:09
  • 16
    How can this be a good solution. It removes the error, but you only get build for the current arch, not all on the market... – esbenr Mar 21 '13 at 09:57
27

Try to remove armv7s from project's "Valid architecture" to release from this issue for iOS 5.1 phone

Arthur Jen
  • 271
  • 2
  • 3
13

I just posted a fix here that would also apply in this case - basically, you do a hex find-and-replace in your external library to make it think that it's ARMv7s code. You should be able to use lipo to break it into 3 static libraries, duplicate / modify the ARMv7 one, then use lipo again to assemble a new library for all 4 architectures.

Community
  • 1
  • 1
Ertebolle
  • 2,322
  • 2
  • 18
  • 22
5

Flurry Support for iPhone 5 (ARMv7s) As I mentioned in yesterday’s post, Flurry started working on a version of the iOS SDK to support the ARMv7s processor in the new iPhone 5 immediately after the announcement on Wednesday.

I am happy to tell you that the work is done and the SDK is now available on the site.

RAZ
  • 577
  • 3
  • 5
4

use menu Project -> Build Settings ->

then remove armv7s from the"valid architectures". If standard has been chosen then delete that and then add armv7.

Panky
  • 169
  • 1
  • 9
1

In case this happens to someone. I built my own library to use with a third party code. While I was building it to deliver, I accidentally left my iPhone 4S plugged in, and so Xcode built my library only for the plugged architecture instead of following the project settings. Remove any plugged in devices and rebuilt the library, link it, and you should be all right.

Hope it helps.

Raphael Ayres
  • 864
  • 6
  • 16
0

In my case, I was linking to a third-party library that was a bit old (developed for iOS 6, on XCode 5 / iOS 7). Therefore, I had to update the third-party library, do a Clean and Build, and it now builds successfully.

Jay Imerman
  • 4,475
  • 6
  • 40
  • 55