Xcode 5 and iOS 7: Architecture and Valid architectures

129,146

Solution 1

Set the architecture in build setting to Standard architectures(armv7,armv7s)

enter image description here

iPhone 5S is powered by A7 64bit processor. From apple docs

Xcode can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 7 or later.

Note: A future version of Xcode will let you create a single app that supports the 32-bit runtime on iOS 6 and later, and that supports the 64-bit runtime on iOS 7.

From the documentation what i understood is

  • Xcode can create both 64bit 32bit binaries for a single app but the deployment target should be iOS7. They are saying in future it will be iOS 6.0
  • 32 bit binary will work fine in iPhone 5S(64 bit processor).

Update (Xcode 5.0.1)
In Xcode 5.0.1 they added the support to create 64 bit binary for iOS 5.1.1 onwards.

Xcode 5.0.1 can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 5.1.1 or later. The 64-bit binary runs only on 64-bit devices running iOS 7.0.3 and later.

Update (Xcode 5.1)
Xcode 5.1 made significant change in the architecture section. This answer will be a followup for you. Check this

Solution 2

My understanding from Apple Docs.

  • What is Architectures (ARCHS) into Xcode build-settings?
    • Specifies architecture/s to which the binary is TARGETED. When specified more that one architecture, the generated binary may contain object code for each of the specified architecture.
  • What is Valid Architectures (VALID_ARCHS) into Xcode build-settings?

    • Specifies architecture/s for which the binary may be BUILT.
    • During build process, this list is intersected with ARCHS and the resulting list specifies the architectures the binary can run on.
  • Example :- One iOS project has following build-settings into Xcode.

    • ARCHS = armv7 armv7s
    • VALID_ARCHS = armv7 armv7s arm64
    • In this case, binary will be built for armv7 armv7s arm64 architectures. But the same binary will run on ONLY ARCHS = armv7 armv7s.

Solution 3

You do not need to limit your compiler to only armv7 and armv7s by removing arm64 setting from supported architectures. You just need to set Deployment target setting to 5.1.1

Important note: you cannot set Deployment target to 5.1.1 in Build Settings section because it is drop-down only with fixed values. But you can easily set it to 5.1.1 in General section of application settings by just typing the value in text field.

Solution 4

When you set 64-bit the resulting binary is a "Fat" binary, which contains all three Mach-O images bundled with a thin fat header. You can see that using otool or jtool. You can check out some fat binaries included as part of the iOS 7.0 SDK, for example the AVFoundation Framework, like so:

% cd  /Developer/Platforms/iPhoneOS.platform/DeviceSupport/7.0\ \(11A465\)/Symbols/System/Library/Frameworks/AVFoundation.framework/

%otool -V -f AVFoundation                                                                     9:36
Fat headers
fat_magic FAT_MAGIC
nfat_arch 3
architecture arm64     # The 64-bit version (A7)
    cputype CPU_TYPE_ARM64
    cpusubtype CPU_SUBTYPE_ARM64_ALL
    capabilities 0x0
    offset 16384
    size 2329888
    align 2^14 (16384)
architecture armv7        # A5X - packaged after the arm64version
    cputype CPU_TYPE_ARM
    cpusubtype CPU_SUBTYPE_ARM_V7
    capabilities 0x0
    offset 2359296
    size 2046336
    align 2^14 (16384)
architecture armv7s       # A6 - packaged after the armv7 version
    cputype CPU_TYPE_ARM
    cpusubtype CPU_SUBTYPE_ARM_V7S
    capabilities 0x0
    offset 4407296
    size 2046176
    align 2^14 (16384)

As for the binary itself, it uses the ARM64 bit instruction set, which is (mostly compatible with 32-bit, but) a totally different instruction set. This is especially important for graphics program (using NEON instructions and registers). Likewise, the CPU has more registers, which makes quite an impact on program speed. There's an interesting discussion in http://blogs.barrons.com/techtraderdaily/2013/09/19/apple-the-64-bit-question/?mod=yahoobarrons on whether or not this makes a difference; benchmarking tests have so far clearly indicated that it does.

Using otool -tV will dump the assembly (if you have XCode 5 and later), and then you can see the instruction set differences for yourself. Most (but not all) developers will remain agnostic to the changes, as for the most part they do not directly affect Obj-C (CG* APIs notwithstanding), and have to do more with low level pointer handling. The compiler will work its magic and optimizations.

Solution 5

Simple fix:

Targets -> Build Settings -> Build Options -> Enable Bitcode -> No

Works on device with iOS 9.3.3

Share:
129,146

Related videos on Youtube

Crazy Yoghurt
Author by

Crazy Yoghurt

Updated on July 05, 2022

Comments

  • Crazy Yoghurt
    Crazy Yoghurt almost 2 years

    I'm starting new project in Xcode 5. I want to develop application using iOS SDK 7 but with deployment target iOS 5.0. As soon as I create new project in Xcode and try to change deployment target to 5.0, I've got this message:

    Applications including an arm64 slice are not compatible with versions of iOS
    prior to 6.0
    Adjust your Architectures build setting to not include arm64 in order to deploy
    to releases prior to iOS 6.0.
    

    So changed architectures to Standard (no 64bit). I compiles, runs but I do not really understand what just happend.

    What's the difference between Architectures and Valid architectures settings in Xcode project Build Settings?
    If I set Architectures to exclude 64-bit what happens when I run my app on 64-bit iPhone or iOS Simulator (I know it works, I'm just curious what hapens underneath)?
    Can you explain big mess with new 64-bit architecture?

    enter image description here

  • Crazy Yoghurt
    Crazy Yoghurt almost 11 years
    As I've written in my question, I have already done it. My question is more about what does it change and what happens underneath.
  • Crazy Yoghurt
    Crazy Yoghurt almost 11 years
    about edit: So it's just about included binaries? With Architecture set to exclude 64-bit, iPhone 5S will run 32-bit binary?
  • trojanfoe
    trojanfoe almost 11 years
    about edit: I think the minimum deployment target must be iOS 6.0, not iOS 7.0. @CrazyYoghurt Yes, as with Mac - 64-bit machines can run 32-bit binaries, else a 64-bit machine would have nothing to run when first introduced.
  • Anil Varghese
    Anil Varghese almost 11 years
    currently to work the app on 5s and other devices with iOS7 deployment target should be iOS 7.0
  • Crazy Yoghurt
    Crazy Yoghurt almost 11 years
    @Anil but I want my app to be compatible with iOS ver. >= 5.0
  • trojanfoe
    trojanfoe almost 11 years
    @CrazyYoghurt Then you must drop arm64.
  • Anil Varghese
    Anil Varghese almost 11 years
    as @trojanfoe said drop arm 64. Your app will work on all the device
  • Crazy Yoghurt
    Crazy Yoghurt almost 11 years
    @Anil last update: that's what I wanted to know. So with Architecture set to exclude 64bit and Deployment Target of iOS 5.0, Xcode will generate only 32bit binaries, which will run on all devices with iOS ver >= 5.0.
  • Anil Varghese
    Anil Varghese almost 11 years
    ya... you can go ahead
  • Morrowless
    Morrowless over 10 years
    I think the OP is out of date on the minimum target for fat binaries. Xcode 5.0 explicitly tells me it must be iOS6 or greater, not 7.
  • Morrowless
    Morrowless over 10 years
    Oh, but the docs say "Xcode 5.0.1 can build your app with both 32-bit and 64-bit binaries included. This combined binary requires a minimum deployment target of iOS 5.1.1 or later." I'm confused. Did they lower the requirements in 5.0.1?
  • Ade
    Ade over 10 years
    Nope, still confuses the hell outta me :S
  • DanMoore
    DanMoore about 10 years
    what is the "resulting list" ??
  • JScarry
    JScarry about 10 years
    "In Xcode 5.0.1 they added the support to create 64 bit binary for iOS 5.1.1 onwards." I’d like to deploy to iPads running 5.1.1 but that is not a choice—only 5.1. Is there any way to edit the deployment target?
  • Slipp D. Thompson
    Slipp D. Thompson almost 10 years
    @DanMoore The result of the set intersection.
  • rob5408
    rob5408 over 8 years
    It would make sense if I could find a reason why I'd build for an architecture that I don't want to run on.