The iOS encapsulation feature generates a static library. Framework

Source: Internet
Author: User

In the implementation of the iOS modular development process, the fixed business module can be the static library.

This article will create a simple project based on Xcode9.2 that teaches you how to create your own framework, with the goal of making the framework simple and easy to learn. This approach makes it easy to share your code, reuse it in multiple projects, and hide implementation details to control the exposed header files.

1. Open Xcode and create a new project. Do not select "Application" and select "Framework & Library". Select First, then next.

2. Create a related function class

I have created a SayHello class here.

3. Implementing Functional Classes

I wrote a SayHello method in the SayHello class and implemented the method

4. Changing parameters

Under Targets, select the project and change several parameters under Build settings.

5. Increase armv7s

Under architectures, add armv7s and select. Set build Active Architecture only to No.

6. Set headers

Drag the header file you want to expose to public, hide it under private or project, and, of course, the hidden header file can no longer be referenced.

You then need to introduce all of the. h that you want to expose in TestFramework.h (must be public, otherwise it cannot be referenced).

7. Start packaging the Framework

1> Check Simulator, compile program

2> Check the test machine, compile the program

3> finding the framework file in the Finder

Select the framework shown in the diagram and right-click the show in Finder.
Find the test file shown in, one is Debug-iphoneos (real machine), one is under the Debug-iphonesimulator (simulator).

The 4> uses a terminal command to combine two frameworks into an emulator and a framework that can be used by a real machine.

Open the console input lipo-create Iphoneos under Testframework path simulator testframework The path-output the new path, thus completing the merger of the emulator and the real machine version, The testframework under the new path is your merged file, change the name of the file to the same name as the test that you did not merge, put it under the Framework folder, and replace the original Testframework file.

5> the modified framework copy and save it, and this is the framework we made.

The iOS encapsulation feature generates a static library. Framework

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.