iOS how compatible apps for 32-bit systems and 64Bit systems

Source: Internet
Author: User

Apple released IPhone5S moment, 64 app bit went to the front. At the time I saw Apple's official data released by Ios7.x's SDK to support 64-bit applications. The built-in application is already 64-bit.

I remember I had a 16-bit system when I was in touch with the computer, and the pointer was 16-bit addressable. When using TURBOC, also according to the size of the application of the choice is tiny mode or other. Later, for a very long time, 32-bit model programming was used. 4 G is a boundary condition that is firmly remembered. Now, 64 people have come to the front.

Just like the 16-bit turn 32-bit. The hardware is definitely the first to launch. The SDK will also follow. Then a variety of third-party applications will be gradually followed up. This process generally needs to last for some time. After the launch, the Apple was in a 32-bit and 64-bit transitional period for a very long time. But. With the October Apple announced. From February 1, 2015 onwards, upload appstore applications are required to support ARM64, detailed information please poke

Id=10202014a "> here.

So I started looking at how 32-bit apps turn into 64-bit apps.

1. Basic knowledge

Xcode 5.0.1 supports compiling binary for 32-bit and 64-bit

Support 32-bit and 64-bit at the same time. We need to choose the minimum deployment target for IOS 5.1.1

64-bit binary must be executed on a CPU that supports 64-bit. and the minimum OS version number requirement is 7.0.3

2. Basic steps to make your app compatible with 64-bit

Install Xcode5.0.1 or later--in fact, the Xcode version number that can now be submitted AppStore is at least 5.1.1

Open Project in Xcode. Compile. Fixed errors and warnings, especially for 32-bit and 64

In Project setting, change the SDK used by the smallest application to the 5.1.1 or higher version number.

Set the architectures parameter to "standard architectures (including 64-bit)."

This allows your app to support 64-bit CPUs, fix compiler errors and warnings again, and be aware that some issues with the compiler are not warning

Test your application on a 64-bit real-world machine

Use instruments to view the status of memory usage


3. Changes from 32-bit to 64-bit

3.1 Changes in data types

This is mainly the number of bytes in the language built-in type and the difference in byte alignment.

In the 32-bit era, the IPL32 specification was used, and after 64 bits, it was changed to the LP64 specification.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2frdwxhzmx5/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

In addition to these, there are floating-point types

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2frdwxhzmx5/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

In the data type, the Nsinteger is equal to int at 32 bits, which is equivalent to long at 64 bits, and this data structure is used very widely, very many nonstandard times will be used directly and int substitution, in 32 bit is no problem, but at 64 bit. This is the hidden danger. CGFloat also has the same problem, so the code must be carefully checked for changes.

As for alignment, suppose that an offset is used to access the struct's items, then a careful examination is required and the rest is good. Of course, if you use malloc, check the allocated memory size, too. The suggestion is to use sizeof more to help with the calculation.

Also, for the stored files. For example, files stored on icloud. You can't be sure whether it's a 32-bit app or a 64-bit app that goes to the interview. Then please make sure that the interpretation of the data content is identical.


3.2 Changes on the method call

64-bit applications require that all functions have prototypes, which in itself is a good coding habit

The shape of the function must be completely consistent with the prototype. In particular, avoid a number of undefined function pointer Modeling (printf Class)

In 64-bit systems, calling functions and 32-bit systems is different at execution time. The basic difference is that when you pass the parameters of a function that has a variable number of parameters, let's look at the following code:

int fixedfunction (int a, int b); int variadicfunction (int a, ...); int main{    int value2 = fixedfunction (5,5);    int value1 = variadicfunction (5,5);}
The first function is to pass in a fixed number of 2 parameters, and the second function is variable in number of parameters. In use, 2 parameters are also passed in. In a 32-bit system, the pass-through of the two functions is very similar, and in a 64-bit system, they are quite different.


3.3 Different of the compilations

Because it is a different set of instructions. The Assembly will of course be different. Only our general application does not use the assembly, so this one is less experienced.


4. Third-party libraries

At last. Third-party libraries that we use in our projects will definitely need to support 64-bit systems. Otherwise it would be useless.

So you need to check the third-party libraries that you use when you upgrade. See if a 64-bit version number has appeared.


Apple's current system (IOS7/IOS8), the 32-bit framework and the 64-bit framework coexist, so assuming that all applications are 64-bit, the system will voluntarily not load the 32-bit framework, so that less resource-intensive, In addition, there are advantages to the speed of execution. Other words. You will feel that the phone executes a little faster.

After the application is compatible with 64-bit systems, the memory footprint will definitely become a bit more, but the performance also has a corresponding promotion.


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

iOS how compatible apps for 32-bit systems and 64Bit systems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.