Explore the impact of different versions of SDK on iOS programs, sdkios

Source: Internet
Author: User

Explore the impact of different versions of SDK on iOS programs, sdkios
PDF: http://pan.baidu.com/s/1eq8dvdo:
The same Code is compiled using sdks of different versions, which affects the values in the MachO header, so that the program shows different appearances.
Code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    UIScreen *mainScreen = [UIScreen mainScreen];    CGRect frm = [mainScreen bounds];    UIWindow *win = [[UIWindow alloc] initWithFrame:frm];    win.backgroundColor = [UIColor blueColor];    self.window = win;    [win release];    [self.window makeKeyAndVisible];    return YES;}



Problem: the code above is very simple and does not have any function. It is compiled by xcode v4.6.3 and v5.0.2 respectively and then installed on the iOS8 device, but the performance is different, it mainly refers to the difference between iOS6 and iOS7 about the status bar, for example :__________
The Code is the same, but different sdks are used for compilation. What is the difference?
Note:
Xcode version: 4.6.3 VS 5.0.2 device: iPhone 5S, iOS 8.0 Executable File Name: APIDiff-SDK61 represents the executable file APIDiff-SDK70 compiled with iOS SDK 6.1 represents the executable file IPA file name compiled with iOS SDK 7.0: APIDiff-SDK61.ipa indicates the installation package APIDiff-SDK70.ipa compiled by iOS SDK 6.1 indicates the installation package compiled by iOS SDK 7.0
Analysis:

Analysis 1: Confirmation is caused by executable programs

Verification Method:

Replacing the executable program in the APIDiff-SDK70.ipa with the executable program in the APIDiff-SDK61.ipa,

Then use the codesign command to re-sign,

Package, install it on your phone, and find that the status bar is transparent,

The difference is indeed in the executable program.


Re-signature method:
Codesign-f-s "Certificate Name" -- resource-rules Payload/*. app/ResourceRules. plist Payload/*. app



Analysis 2: Compare binary differences
In an executable file, the first thing that comes to mind is to use a binary comparison tool to see the difference between the two. The result is as follows:


We can see that the difference is too big. This is meaningless and this path is not feasible.

Analysis 3: Compare code differences
Since binary is meaningless, we can compare the disassembly code to see if the compiler has done anything,


We can see that the code is almost the same. The specific difference is also caused by different versions of compilers. The logic is the same, so it is not the code that causes different program appearances. In addition, the Code does not read any global variables, indicating that it is not because the default values in the UIKit are compiled into the program, which leads to different appearance of the status bar.

Analysis 4: compare the effects of the UIKit version number on the program

Since there is no difference in the code,

First, we will consider whether the program looks different because of different UIKit versions.

Although the program is a dynamic link UIKit,

And there is only one version of the UIKit library on the device,

But we still need to verify it.

First, determine the differences between the two, such:



We can see that there are indeed differences between the two versions, but the compatible versions are both 1.0. In theory, it is not because of this program difference. The theory is theory. We are currently using exclusion to determine the cause of the problem, but we still need to verify it. Verification Method: Change the UIKit version in the APIDiff-SDK61 to 2903.23.0. Modification method: the offset of this value in the binary file is 0x6EC. Pay attention to the minor problem. After modification, re-sign and package and install it on your mobile phone. The status bar does not change. This is not because of the difference in the UIKit version number.

Analysis 5: Use MachOView to compare items one by one

It's a bit difficult to get here,

The problem is there, but we cannot find the cause.

That's the most primitive tool: physical labor, using MachOView for a comparison.

From "_ LINKEDIT"

---> "LC_DYLD_INFO_ONLY"

---> "LC_LOAD_DYLINKER"

---> "LC_VERSION_MIN_IPHONEOS"

There is a difference in the reserved value in "LC_VERSION_MIN_IPHONEOS:


Feeling it is possible that this is the cause of the problem, verification: Modify the APIDiff-SDK61, offset address 0x69C, change the value to 00070000, re-signature, package installed on the phone, found that the status bar becomes transparent, the problem is here!

TODO: How does this difference affect the appearance of the program?
This difference affects the appearance of the program, possibly because:

1. This attribute is read in UIKit.

The possibility is extremely small. UIKit is just a library,

The above differences are first obtained by the loader,

Far away from UIKit.


2. SpringBoard and related services.

Highly probable,

①: SpringBoard services have drawing responsibilities;

②: Click the icon on the desktop. The program is started by SpringBoard.



However, I do not intend to continue the verification. Here I have satisfied my desire to explore, and more eager brothers can continue to analyze. Pai_^



Can iOS programs developed using the old version of xcode and SDK run on the new version of iOS?

This is not easy to say. It is better to test it. If there is no problem, it should be able to run. Of course, the test is the most important.
OS X 10.5 should preferably support xcode3.2.6, xcode4 and later versions.
Hope to help you.

What is the relationship between the SDK and Xcode in ios development? Which of the following experts can help you answer this question?

Maybe you are not familiar with ios development,
The relationship between the operating system and the software is the relationship between the operating system and the software. The operating system provides a platform for the application. You can use the software to implement the software functions. Xcode provides a platform for the SDK. You can use the SDK for programming.
XCode is just an IDE tool for development. You can also use XCode for development.
The SDK is an API and a class and method used in your programming project. It is developed by Apple and you can call it.
[Source: Shanghai ITCH training]

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.