简体   繁体   中英

How Single App Binary Supports 64-bit and 32-bit Apps

We can see apple announcement here. . According to this doc, we can submit same binary with supporting 32-bit and also 64-bit. I found one stack overflow answer here . But According to this answer, we should set deployment target as IO7+ . But apple doc said, you can submit this with IOS 7 and IOS 6 support? My question is, How can we generate binary with supporting 32-bit and 64-bit by deployment target IOS6+?

Note: I'm using xcode 5.0

Update: Question above is fixed by using xcode 5.0.2 . But I get confused how can I make code for 32-bit as well 64-bit. I know one thing, we must do code for two separately in some times. But How can I do? . for example, if one method in deprecated in ios6 means, we provide code for ios 6 and ios7 also. In same case also followed here or do some other technic for this.

Xcode can build your app with both 32-bit and 64-bit binaries included so it works across all devices running iOS 7. If you wish to continue to support iOS 6 then you will need to build for 32-bit only. Next month we will be making changes that will allow you create a single app binary that supports 32-bit on iOS 6, as well as 32-bit and 64-bit on iOS 7.

Converting Your App to a 64-Bit Binary

At a high level, here are the steps to create an app that targets both the 32-bit and the 64-bit runtime environments:

1.Install Xcode 5.0.1.

2.Open your project. Xcode prompts you to modernize your project. Modernizing the project adds new warnings and errors that are important when compiling your app for 64-bit.

3.Update your project settings to support iOS 5.1.1 or later. You can't build a 64-bit project if it targets an iOS version earlier than iOS 5.1.

4.Change the Architectures build setting in your project to “Standard Architectures (including 64-bit).”

5.Update your app to support the 64-bit runtime environment. The new compiler warnings and errors will help guide you through this process. However, the compiler doesn't do all of the work for you; use the information in this document to help guide you through investigating your own code.

6.Test your app on actual 64-bit hardware. iOS Simulator can also be helpful during development, but some changes, such as the function calling conventions, are visible only when your app is running on a device.

7.Use Instruments to tune your app's memory performance.

8.Submit an app that includes both architectures for approval.

The remainder of this chapter describes problems that frequently occur when porting a Cocoa Touch app to the 64-bit runtime environment. Use these sections to guide your own efforts to investigate your code.

From https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html#//apple_ref/doc/uid/TP40013501-CH3-SW1

iOS apps rely on a low-level application binary interface and coding conventions established by the Objective-C language and the system frameworks. Starting with iOS 7, some iOS devices use 64-bit processors and offer both a 32-bit and a 64-bit runtime environment. For most apps, the 64-bit runtime environment differs from the 32-bit runtime environment in two significant ways:

In the 64-bit runtime, many data types used by Cocoa Touch frameworks (as well as the Objective-C language itself) have increased in size or have stricter memory alignment rules. See “ Changes to Data Types .” The 64-bit runtime requires proper function prototypes to be used when making function calls. See “ Changes to Function Calling .”

application binary interface (ABI)

Other Changes to the 64-Bit Runtime

The 64-bit ARM instruction set is significantly different from the 32-bit instruction set. If your app includes any assembly language code, you need to rewrite it to use the new instruction set. You also need a more detailed description of the 64-bit calling conventions in iOS, because the conventions do not exactly match the ARM standard. For more information, see iOS ABI Function Call Guide .

At a high level, to make your code 64-bit clean, you must do the following:

  1. Avoid assigning 64-bit long integers to 32-bit integers.
  2. Avoid assigning 64-bit pointers to 32-bit integers.
  3. Avoid pointer and long integer truncation during arithmetic operations (or other arithmetic problems caused by the change in integer types).
  4. Fix alignment issues caused by changes in data type sizes.
  5. Ensure that memory structures that are shared between the 32-bit and 64-bit runtimes share a similar layout.
  6. Rewrite any assembly language code so that your code uses the new 64-bit opcodes and runtime.
  7. Avoid casting variadic functions to functions that take a fixed number of parameters, or vice versa.

At a high level, here are the steps to create an app that targets both the 32-bit and the 64-bit runtime environments:

Install Xcode 5.0.2 (I have done with this only, maybe higher is better)

Open your project. Xcode prompts you to modernize your project. Modernizing the project adds new warnings and errors that are important when compiling your app for 64-bit.

Update your project settings to support iOS 5.1.1 or later. You can't build a 64-bit project if it targets an iOS version earlier than iOS 5.1.

Change the Architectures build setting in your project to “Standard Architectures (including 64-bit).”

Update your app to support the 64-bit runtime environment. The new compiler warnings and errors will help guide you through this process. However, the compiler doesn't do all of the work for you; use the information in this document to help guide you through investigating your own code.

Test your app on actual 64-bit hardware. iOS Simulator can also be helpful during development, but some changes, such as the function calling conventions, are visible only when your app is running on a device.

Use Instruments to tune your app's memory performance. Submit an app that includes both architectures for approval.

The remainder of this chapter describes problems that frequently occur when porting a Cocoa Touch app to the 64-bit runtime environment. Use these sections to guide your own efforts to investigate your code.

Follow the guide for supporting the 32 and 64 bit architecture by apple

The program xcode 5 compiled contained two binary code:32-bit and 64 bit.In the 32-bit system will call the 32-bit code.In the 64-bit system will call the 64-bit code. At the same time, think about same program only have 32-bit code, the 64-bit system contained two framework:a 32-bit, a 64-bit.When the 64-bit system running the 32-bit program will call the 32-bit framework for the underlying support, running the 64-bit program will call the 64-bit framework for the underlying support.More detail you can see Apple's official documentation "64-Bit transition Guide for Cocoa Touch".

Use xcode 5 can be easily compiled program into 64.The basic procedure is as follow.

  1. Set the support device into 'ios7'

  2. The "Architectures" in "Build Setting" changed to "Standard Architectures (including 64-bit)".

As for first part of question - Base SDK should be "Latest iOS SDK" which is iOS 7.0. Minimum deployment target should be iOS 6.0 or you won't be able to select "Standard architectues including 64-bit(armv7, armv7s, armv8)" for architectures. After you select these settings your app will be built for either 32 bit and 64 bit.

As for update - after switching to 32/64bit archs, analyze your project and fix new warnings that can appear. Then test your app on real 64 bit device(iPhone 5s/iPad Air/iPad mini retina). If your app uses iCloud, test synchronization between 32 and 64 bit devices. Helpful info is in Apple's guide (summary from there is in @iDev answer).

EDIT

Actually yes, minimum is 5.1.1, but you should either set it manually or set deployment target lower than 6.0 and when you select architectures to incl. 64bit Xcode will ask you to set it as 5.1.1. Anyway I'm not sure why you'd want to support 5.1.1 specifically if you want to use 64bit archs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM