Xcode-OBJC,-all_load,-force_load

Source: Internet
Author: User

Http://www.cnblogs.com/yashi88/p/3551947.html

Recently in the work of a project, need to use a third-party library, the use of the Library in the wizard, in particular, after the addition of the library, you need to add in the Xcode build settings other Linker flags added-OBJC flag, this flag has not been used before, So I did a special study of its role.

The use of this flag is related to an important feature of OBJECTIVE-C: category. As explained here, there are some conflicts between the standard static library implementation of UNIX and the dynamic nature of Objective-c: Objective-c does not define a link symbol for each function (or method), it creates a link symbol for each class. This way, when you use categories in a static library to extend an existing class, the linker does not know how to integrate the methods in the original class with the method in the category, causing you to invoke the method in the category with "selector not recognized", which means that the method definition error is not found. In order to solve this problem, the-OBJC flag is introduced, and its function is to load all the object-related files in the static library.

This can solve the problem, but in the 64-bit Mac system or iOS system, the linker has a bug, will cause only a class of static libraries can not use the-OBJC flag to load the file. The workaround is to use the-all_load or-force_load flag, which is to load all the files in the static library, but All_load works on all the libraries, and the-force_load must specify the specific file later.

Understand this, I know, this third party library must have defined some categories to expand the existing classes, open the header file, it is found that this is true.

Xcode-OBJC,-all_load,-force_load

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.