In Xcode-ObjC, and Xcode-ObjC,

Source: Internet
Author: User

In Xcode-ObjC, and Xcode-ObjC,

You need to use a third-party library when creating a project recently. The usage Wizard of this library shows that after adding this library, you need to add the-ObjC flag to Other Linker Flags under Xcode Build Settings. This flag has never been used before, so I have studied its role.

 

The use of this flag is related to an important feature of Objective-C: category. According to the explanation, there are some conflicts between the standard static library implementation of Unix and the dynamic characteristics of Objective-C: Objective-C does not define a link symbol for each function (or method, it only creates a link symbol for each class. In this way, when classes are used in a static library to extend existing classes, the linker does not know how to integrate the original methods of the class with the methods in the category, this will cause the "selector not recognized" error when you call the method in the category, that is, the method definition error cannot be found. To solve this problem, the-ObjC flag is introduced to load all objects in the static library.

 

This can solve the problem, but in a 64-bit Mac or iOS system, the linker has a bug, the-ObjC flag cannot be used to load files only for static libraries with categories. The work und is to use the-all_load or-force_load flag to load all files in the static library, but all_load acts on all libraries, the-force_load must be followed by a specific file.

 

Related Article

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.