"iOS Development-115" Static library production and third-party framework iOS Universal Framework,debug and release

Source: Internet
Author: User
Tags uikit

(1) Concept Introduction

We usually use the most in the project is open-source third-party library, this library is open source, we can not only use, but also to view the source code can even modify the source code.

--The source library is closed source, and the closed source library is divided into dynamic library and static library. Dynamic libraries are files that end in the. dylib or. Framework. Is the library that Apple has provided to us. Developers cannot use self-made dynamic libraries in their projects, or they cannot upload to AppStore.

So, for closed-source libraries, we are mainly talking about static libraries. The static library looks like a user gets a file with a lot of header files. H + resource bundle + compiled binaries. A (. framework). Those files that are not exposed are compiled into the. A or. Framework. If you are protecting intellectual property, you can use a static library.

——. A static library requires a combination of. h files and resource bundles for use by users. and the build. Framework word contains. h and resource files that can be used directly by the user.

-If the library involves resources such as pictures, you can use them in bundles that have the same name as the. A or. Framework. Create a new file and modify the suffix to bundle.

--The static library can be copied multiple times, resulting in redundancy, but there is no way to use a self-made dynamic library (no duplicate copy).


(2) The main steps of making. A static library

--Choose a static library, name it, and drag and drop the. h and. m Files of the library you need to make.


--drag and drop in the bulid phrase to increase or decrease a headers. It is recommended to increase or decrease this headers, and then drag and drop, we will be open to find headers has automatically added our header files. Then drag and drop the header files that need to be exposed to public. Then click Run to generate the. a library.


--but what we generate is typically a library for use on the emulator, and if you need to use it on a real machine, you need to select the following iOS device and run it again.


--in fact, we can find our files under the ~/library/developer/xcode/deriveddata/project name + a bunch of characters (you can find the path on Xcode>window>organizer).


--Find the path will generally find that there are two folders, the first one is the real machine, the second is the simulator.


-If you need to combine the two, you can use the terminal command line Lipo. The middle two files are the two. A files that we need to merge, and the last one is the merged file name that we need to output (name it yourself, but preferably the same)

Lipo-create debug-iphoneos/libhelloworld.a debug-iphonesimulator/libhelloworld.a-output libHELLOWORLD.a
found that the folder has more than one file, the file size is the sum of the size of the above two files.

-If you need someone else to use it, pack this. A file and our header file (in usr/local/include) for someone else or yourself.


--1: If the Uikit framework is used, we need to add a PCH file and use the Uikit framework in all of the project files. See the previous chapter for the use of PCH files.

--Encountered Issue 2: If the codesign error:code signing is required for product type ' Unit Test Bundle ' in SDK ' IOS 8.0 ', the answer to this question is here. You only need to modify the content on the diagram below.


--3: If the file we are compiling contains a category category file, the error will generally occur (the error that cannot be found for the method is unrecognized selector sent to instance), However, the Xcode6 and iOS8 configurations are no longer present today, as the software automatically helps us set up, and if not set in the build setting, the other Linker frags in linking is set to-OBJC.



(3) making. The static library of the Framework, its own setup is cumbersome, you can use the third-party library iOS Universal Framework.

The benefit of the framework is that many steps have been set up for us. Because there are really many steps and tedious, no need to remember, just need to know how to find the tutorial settings.

For more information: Open source framework: Ios-universal-framework


(4) DEBUG, the advantage is that Xcode opens a lot of services to monitor the error, let the programmer to adjust the trial, but the performance. RELEASE, the advantage is the opposite. The item name we clicked has an edit Scheme option, which can be found after opening:


--When we upload AppStore, the default is release mode when using Package archive in Xcode's product. When we chose run, we found that the default parameter was debug.




Therefore, it is recommended that:

-- when generating a static library, you can adjust the parameters of the above run to release, which saves memory and runs faster.

--in peacetime with run debugging, after the operation of the normal debug, before the release of the program can modify the parameters of the run to release, and then run a simulation of the release, because sometimes under debug normal, under release will crash, both of the sensitivity of the error is different.


"iOS Development-115" Static library production and third-party framework iOS Universal Framework,debug and release

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.