Methods and FAQs for referencing third-party libraries in IOS Programming
Method 1: Copy all source files to the project.
In this way, all the source files of the third-party class library are copied to the project, and all the. h and. m files are directly dragged to the XCode project.
Note:
1. If a third-party class library references some built-in class libraries in the system, you need to reference these class libraries in the project.
2. If the current project enables ARC, and the referenced third-party class library does not use ARC, you needTargets-Build Parses
Find the. m file of the third-party class library and add-Fno-objc-arcMark.
3. if you reference a third-party class library that uses ARC for a project that has not enabled ARC, add the. m file of the third-party class library.-Fobjc-arcMark.
In addition, you can use a compiler command in the source code._ Has_feature (objc_arc)To check whether the project uses ARC,
For details, see http://clang.llvm.org/docs/languageextensions.html?langext-has-feature-has-extension.
Method 2: reference. xcodeproj to generate static Link Library and Reference
First, copy the static library and header file to the file path of the project.Targets-Summary-Linked Frameworks and LibrariesOrTargets-Build Phases-Link Binary With LibrariesAdd a reference to the static Link Library generated by a third-party class library. Next, you needTargets-Build Settings-Search PathsOfUser Header Search PathsThe header file path of the third-party Class Library added to the parameter can be an absolute path such as/Users/libpath or a relative path (relative to the current project folder) such :../**. It is usually set to "$ (PROJECT_DIR)/usr" (usr is the self-built folder under the project ). There are a lot of delays on the Internet. xcodeproj file. xcodeproj, And it is red. there are a lot of things in xcodeproj, all of which are introduced in. They are too redundant and unnecessary.
Note:
1. If a third-party class library encapsulates some resources in the. bundle file, the. bundle file must be dragged together with. xcodeproj to the project.
2. Some static Link Libraries may need to be referenced.Targets-Build Settings-LinkingOfOther Linker FlagsAdd:-Objc,-All_loadThis type of tag.
3. The current project and third-party class libraries use other third-party class libraries at the same time. In this case, additional processing is required to compile successfully:Third-party class library. xcodeproj Project
-Targets-Build PhasesInCompile SourcesAndCopy HeadersRemove duplicate. m and. H files.
4. Some built-in class libraries referenced by third-party class libraries may cause compilation errors if they are not referenced in the project. In this case, you also need to reference some built-in class libraries referenced by third-party class libraries in the project.
For example, if a third-party class library references QuartzCore. framework, but QuartzCore. framework is not referenced in the project, compilation errors may occur. You must also reference QuartzCore. framework in the project.
Method 3: Third-party management with Cocoapods
Many third-party open-source libraries, such as JSONKit and AFNetWorking, are frequently used when you develop iOS applications. A class library may use other class libraries. to use it, you must download other class libraries. Other class libraries also use other class libraries ", this may be a special case. In short, it is very troublesome to manually download the required class libraries one by one. Another common situation is that the class libraries used in your project are updated. You must download the new version and add it to the project again, which is very troublesome. If you have any tools to solve these annoying problems, it will be "easy to understand ". So you need CocoaPods.
CocoaPods should be the most commonly used and famous class library management tool for iOS. The two annoying problems mentioned above can be completely solved through cocoaPods with only one line of commands, the premise is that you must set it correctly. Most famous open-source libraries support CocoaPods. Therefore, as iOS programmers, it is essential to master the use of CocoaPods.
For details about how to use cocoapods, see:
Http://code4app.com/article/cocoapods-install-usage
Content reference link:
Http://mobile.51cto.com/iphone-407056.htm