7

With the iPhone 5 and other armv7s devices now appearing, there are compatibility problems with existing (closed-source) 3rd-party frameworks such as Flurry which are built without this newer architecture.

One option is to wait until they release a new build, but I was hoping there might be a compiler flag or something I can use in my Xcode project that would let the linker know not to expect armv7s architecture from this framework, and use the armv7 instead. Does anything like this exist?

coneybeare
  • 33,113
  • 21
  • 131
  • 183
  • 10
    **Stack Overflow does not close or delete questions because of NDAs between third parties**. Moderators are not here to enforce agreements between two separate third parties. Regardless of whether or not it is NDA, if it is a practical, answerable question and meets Stack Overflow quality guidelines, then the question stays open and undeleted. – casperOne Sep 13 '12 at 14:02
  • 1
    Hey Matt. Just wanted to give you a quick update that Flurry released 4.0.3 with support for armv7s on Friday, Sep 14th. There was a follow-up release 4.0.4 yesterday, Sept 17th, to remove some compiler warnings. – Anthony W Sep 18 '12 at 14:01
  • Thanks, I got it minutes after it was released. – coneybeare Sep 18 '12 at 15:00

2 Answers2

10

It's not possible to load a framework which doesn't include the targeted architecture.

What you could do is only ship a armv7 app until the frameworks are updated. The app will still work on the iPhone 5, just don't use the latest performance optimizations it offers.

Or if you could live without the framework on the new architecture you could weak link it. But then you need to check in your code if it is loaded everywhere you use stuff from the framework.

catlan
  • 25,100
  • 8
  • 67
  • 78
6

There used to be a linker flag in GCC, allow_sub_type_mismatches, which would let you mix and match ARM architecture versions in linked libraries, but they seem to have taken that away in recent versions of Xcode.

However, this can actually be hacked around in a different way; make a copy of the framework, view its contents, open up the actual code library file inside of it in a hex editor, and do the following replace all:

CEFAEDFE 0C000000 09000000

to

CEFAEDFE 0C000000 0B000000

What you're basically doing is changing the header inside of each code object to identify it as ARMv7s rather than an ARMv7 code - the instruction sets are backwards compatible (or seem to be, anyway), so it should run fine even with this hack, though I have to admit that we won't know that for certain until we actually get a chance to test it on an iPhone 5.

Anyway, once you've modified the framework, simply add both versions to your project and link to the appropriate one from each architecture. You might also be able to create a new single framework by using lipo to merge the modified and original libraries.

Ertebolle
  • 2,322
  • 2
  • 18
  • 22
  • 2
    This is exactly what I did and show how here - http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/ . – mattjgalloway Sep 16 '12 at 11:09
  • Cool - certainly streamlines the process to have an automated script for it, plus it eliminates the possibility of accidentally changing a CEFAEDFE 0C000000 09000000 that wasn't related to the Mach-O header. – Ertebolle Sep 16 '12 at 16:20
  • 1
    What do you mean, "taken away in LLVM"? It's a linker flag, for the Great Prophet Zarquon's sake! Nothing to do with the compiler, and it does indeed work, though it's probably the worst possible way to solve this issue (hint: the proper way is to opt out of ARMv7s by removing it from the Architectures build setting). – Pierre Lebeaupin Sep 18 '12 at 19:07
  • Sorry, I should have said "recent versions of Xcode" (now corrected) - happened to correspond with the switch to LLVM as the default compiler, IIRC, so I lumped those together in my mind. We actually used to use this flag to support some old ARMv6 libraries in ARMv7, but they broke it a few Xcode releases ago. It didn't seem to work in 4.5 either in our testing at least - are you sure it actually works for you? Opting out of ARMv7s is an option, but if your app happens to have a lot of performance-sensitive floating-point code (ours does) it's probably worth trying to support it. – Ertebolle Sep 18 '12 at 21:30