Methods and frequently asked questions about third party libraries referenced in IOS programming (reproduced)

Source: Internet
Author: User

Original: http://www.th7.cn/Program/IOS/201407/244585.shtml

Method One: Copy all the source files directly into the project

This approach is to copy all the source files from the third-party class library to the project, and drag all the. h and. m files directly into the Xcode project.

Attention:

1. If a third-party class library references some system-brought class libraries, additional references to those class libraries are required in the project.

2. If arc is enabled for the current project and the referenced third-party class library does not use arc, then the Targets - Build parses of the project information is also required

Find the. m file for the third-party class library and add the -fno-objc-arc tag to them.

3. For an arc-not-enabled project with a reference to a third-party class library that uses arc, you need to add a -fobjc-arc tag to the third-party class library's. m file.

In addition, a compiler directive __has_feature (OBJC_ARC) can be used in the source code to detect whether the project uses arc,

See Http://clang.llvm.org/docs/LanguageExtensions.html#langext-has-feature-has-extension for details.

Method Two: Reference. xcodeproj generate a static link library and reference

First, copy the static library and header files that will be referenced to the project's file path, and then, in the project's targets–summary–linked frameworks and Libraries , or in the targets–build Phases–link Binary with Libraries adds a static link library reference generated by a third-party class library. Next, you also need to include the header file path of the third-party class library in the User header Search Paths parameter of the targets–build settings–search Paths , which can be an absolute path such as:/ Users/libpath, or it can be a relative path (as opposed to the current project folder) such as: /**。 Typically set to: "$ (project_dir)/usr (where usr is a self-built folder under the project). There are a lot of xcodeproj files on the Internet, many of which are also available online. Xcodeproj, and it is red, I feel there. There are many things under xcodeproj, all introduced, too redundant, not necessary.

Attention:

1. If the third-party class library encapsulates some resources in the. bundle file, then the. bundle file needs to be dragged into the project with. Xcodeproj.

2. Some static link library references may also require additional markup, added in the other Linker Flags parameter of targets–build settings–linking :-OBJC , –all_load this type of tag.

3. The current project and the third-party class library use additional third-party class libraries at the same time, which requires some extra processing to compile successfully: in the referenced

The. Xcodeproj project of the third-party class library

Compile Sources and Copy Headers in –targets–build phases Remove the duplicate. m and. h files.

4. Some systems referenced by third-party class libraries have their own class libraries, and if there are no references in the project, they can also cause compilation errors, and you will also need to reference some of the system's own class libraries referenced by the third-party class library in your project.

For example, a third-party class library that references Quartzcore.framework, and quartzcore.framework that are not referenced in a project can cause compilation errors, and you need to reference quartzcore.framework in your project as well.

Method Three: Manage third parties with Cocoapods

When you develop an iOS app, you'll often use many third-party open source libraries, such as jsonkit,afnetworking and more. Maybe a class library to use other class libraries, so to use it, you have to have to download another class library, and other class libraries to use other class libraries, "The descendants of Endless also", this may be a more special case. In short, the meaning of small, manual one by one to download the required class library is very troublesome. Another common scenario is that the class libraries you use in your project are updated, and you have to re-download the new version and rejoin the project, which is a hassle. If there are any tools to solve these annoying problems, it will be "good." So, you need to CocoaPods.

Cocoapods should be the most popular class library management tool used by iOS, the two annoying problems, through cocoapods, only need a single line of command to completely solve, of course, if you have to set it up correctly. Importantly, most of the well-known open source class libraries support cocoapods. So, as an iOS programmer, mastering the use of cocoapods is essential to our basic skills.

For detailed use of cocoapods, see:

Http://code4app.com/article/cocoapods-install-usage

Content Reference Links:

Http://mobile.51cto.com/iphone-407056.htm

Methods and frequently asked questions about third party libraries referenced in IOS programming (reproduced)

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.