Description of the compilation parameter-OBJC

Source: Internet
Author: User

Today, when the Friends of the League to share, the error caused the system crashes. Weibo SDK compile time error, need in buildsetting in other linker, add-OBJC, note O and C uppercase.

Some third-party libraries have a category for the system library classes,

At this point, you need to use the compile parameters:-OBJC, so that the third-party library of the System class extension method can be used in the project.

However, after using-OBJC, there are two problems:

1, undefined symbols

2. Duplicate symbol

Undefined symbols describes a library in the project that does not introduce a third-party library reference.

If you do not add the-OBJC parameter, you will not get an error at compile time, but the runtime uses a method that does not reference the library, and the system crashes.

The problem is well solved. As long as the missing library is found, the introduction of the project is possible.

The problem with duplicate symbol is not solved, which means that the class name in the third-party library and the class name in the project, or the names of the classes in the other third-party libraries.

The most common example of this class, such as reachability, if the third-party library references, their own project also quoted, will be reported duplicate symbol.

If the referenced third-party library has no source code, you can only rename the name class in your project.

To deal with the above problem, if you want to make a library, pay attention to two points:

1, avoid the system class plus category, so that others use your library, do not add OBJC parameters can also use your library.

2, if the library used in other third-party source code, especially with the more common, such as reachability, must be

These classes are renamed, and the most common practice is to prefix the class names. To avoid the problem of duplicate symbol when others use your library.

Description of the compilation parameter-OBJC

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.