iOS Development Static library generation

Source: Internet
Author: User

First, simply say: library is a collection of program code, is a way to share code

Divided into open source libraries (SD,MI,AFN) and closed repositories (no concrete implementations are visible)

Closed Source Library is divided into static library and dynamic library

Static libraries:. A and. Framework

Dynamic libraries:. Dylib and. Framework

The difference between static and dynamic libraries in use

Static libraries: When linked, the static library is completely copied to the executable file, and multiple copies are used multiple times.

Dynamic Library: Link is not copied, the program is dynamically loaded into memory by the system, for program calls, the system is loaded only once, multiple programs are shared, saving memory

Note: You cannot upload appstore using a dynamic library of your own making

Next, we'll talk about making. A method

The first step: Create a new project with the following options:

Then the next step is to create a new project.

After opening the project, kill the claimed. h and. m files as follows

Part II: Drag the class that needs to be encapsulated into the project

Then select the. h file that needs to be exposed, and the. m file is automatically compiled into a. a file

Select the real device, then command+b compile, the libmjrefresh.a file changes from red to black

Successful, the show in Finder is the library you need.

It should be noted here: the choice of the real machine running out of the real machine running the required. A file, can only run on the real machine, run the simulator will be error.

Because the CPU structure of the phone and the difference between the computer caused.

Workaround:

Merge true Machine command +b out. A and simulator command +b out. A

Merging static libraries makes it possible for both simulators and real machines to work

Lipo-create/users/gti/desktop/debug-iphoneos/libjtk.a/users/gti/desktop/debug-iphonesimulator/libjtk.a-output/ users/gti/desktop/libjtk.a

Lipo-create: Fixed command

/USERS/GTI/DESKTOP/DEBUG-IPHONEOS/LIBJTK.A Real Machine ran out of the location of the. A file this location select the. A file directly onto the terminal to OK

/USERS/GTI/DESKTOP/DEBUG-IPHONESIMULATOR/LIBJTK.A Simulator run out of the location of the. a file

Output fixed command line

/USERS/GTI/DESKTOP/LIBJTK.A the location and name of the final file of the merge OK

Use. A

How to use the. A

Drag the. A,. h, resource files directly into other projects

iOS Development Static library generation

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.