14

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.

Community
  • 1
  • 1
Mani
  • 17,549
  • 13
  • 79
  • 100
  • sound is good. why not accepted my answer – codercat Jan 28 '14 at 05:34
  • @iDev need more explanation. But Your answer will helpful more for future users. You may update your answer with helpful example which will make more upvote to you :) You have provided two answers make it as one. It will more useful.. – Mani Jan 28 '14 at 09:12

6 Answers6

19

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

hichris123
  • 10,145
  • 15
  • 56
  • 70
codercat
  • 22,873
  • 9
  • 61
  • 85
  • I just wanted to add to this, since this is the answer that covers the iOS6 requirement - you really don't generally need to make an y code changes to support both 32 and 64 bit, as long as you use NSInteger and NSUInteger instead of int or uint... a simplification, but it's generally true for most applications. – Kendall Helmstetter Gelner Jan 24 '14 at 19:30
  • @iDev Is this true? We can take this build with xocde 5.0.1? Because I'm using 5.0? – Mani Jan 25 '14 at 05:10
5

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.
codercat
  • 22,873
  • 9
  • 61
  • 85
  • Little bit confusion. Could you please provide example code for 1 and 2? – Mani Jan 25 '14 at 04:55
  • what confusion with your self. – codercat Jan 26 '14 at 04:15
  • 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. – codercat Jan 26 '14 at 05:03
  • I've referred that document, so no doubt about point 1 and point 2.. If we want to take 64-bit binary for IOS7, at the same time same build would support for 32-bit in IOS6. what would be the architecture? – Mani Jan 27 '14 at 05:00
  • including 64-bit architecture – codercat Jan 27 '14 at 07:20
2

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

Mani
  • 17,549
  • 13
  • 79
  • 100
Retro
  • 3,985
  • 2
  • 17
  • 41
  • I'm using Xcode5.0. But If I'm trying to set `“Standard Architectures (including 64-bit).”`, I cann't set deployment target as earlier than IOS7? – Mani Jan 18 '14 at 06:14
  • First Xcode with IOS 7.0 sdk may be a issue, did you try new version 5.0.3 i guess will do for you – Retro Jan 18 '14 at 06:16
  • Are you using Xcode 5.0.3? I have set Base sdk as 7.0? Is there any need to change base sdk? – Mani Jan 18 '14 at 06:22
  • What should be as base sdk? I cann't change to any other than IOS 7? – Mani Jan 18 '14 at 06:30
  • Base sdk is ios 7 latest you should use – Retro Jan 18 '14 at 06:34
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/45523/discussion-between-mani-and-retro) – Mani Jan 18 '14 at 06:35
0

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)".

Dracuuula
  • 313
  • 2
  • 15
0

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.

Timur Kuchkarov
  • 1,155
  • 7
  • 21
  • You are wrong. We can able to select "Standard architectues including 64-bit(armv7, armv7s, armv8)" for architectures when deployment target is later than ios 5.1? Check with Xcode 5.0.2.. – Mani Jan 27 '14 at 04:55
0

create an app that targets both the 32-bit and the 64-bit runtime environments:

https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html

user3279053
  • 187
  • 1
  • 10