iOS makes its own framework

Source: Internet
Author: User

This article reprinted to http://blog.csdn.net/chen505358119/article/details/9190731

The code we write in iOS is sometimes reluctant to be seen, it may be encapsulated, and a static library can be generated as typical. A, and

Apple comes with a library of the same suffix called. Framework libraries, which are recommended for personal use. The framework, because. A not only to add it, but also to

Add the corresponding header file to the project.

1. Create a new static library project. File--new--project, in the pop-up box, select the Cocoa touch Static library in Ios--framework&library. Click Next. Enter product name, here is LIBZW.

2. Delete the target in the project generated by the wizard:

Project status after deleting target

3. Delete the project folder corresponding to the old target:

Before deletion:

Before deleting, note that the delete here will pop up the prompt box, to select "Delete Reference only"

After deletion as

4. Delete the compilation settings for the old target (Product menu | Edit Scheme command):

Click on the Manage Schemes button in the lower left corner: after deletion as

Click OK to return

5. Add a new target and click on the add target below

In the popup dialog box, select Bundle under Mac OS x.

For example, give the library a name, keep the default framework (Corefoundation), and click Finish.

6. Modify the project settings for the new target. Select the corresponding target in targets, build setting page: Under Architectures, set the "Base SDK"

Change to "lastest IOS" and change "architectures" to "standard":

Under Deployment, change "Mac OS X Deployment Target" to "compiler Default" and change "targeted Device Family" to

Required, this is changed to "Iphone/ipad", and you can modify the "iOS Deployment Target" as needed, and change to "ios 4.3" here:

In linking, change "Dead Code stripping" to "no", change "Link with standard Libraries" to "no", change "Mac-o Type" to "relocatable Object" File ":

In packaging, change "Wrapper extention" to "framework":

7, modify the target's Info. Click Info:

Change "Bundle OS Type Code" to "fmwk" (the meaning of the Framework):

8. Modify the precompiled header:

9. Drag a tool class into a project, or create a new class specifically, I'm not going to say much.

10. Export the relevant files. Select target, click Build Phases, and then click "Add Build Phase" in the lower right corner

Select "Add Copy Header" in the pop-up menu, and after adding it, expand "Copy Headers" with public, Priviate, project three subkeys below:

Then click on the + sign below to select the header file from the project and click the Add button to complete the Add. At this point, we see that the exported header file

Project, so you can't expose it to someone else and drag it under public:

Then compile the emulator and iOS device mode separately, and it will generate libzw.framework

Maybe there is a life in the debug mode, then you should change the fourth step of the build configure to release mode, and then generate it again,

The framework of the simulator and iOS device are separate,

How do you know if the framework supports the emulator or the real machine? You can use the command, CD to Libzw.framework inside, you will see inside the LIBZW, and then execute Lipo-info LIBZW

If i386 is the support for the real machine

If the ARMV7 support emulator

So how do you get it together?

Execute command command lipo-create xxxx/libzw xxxxx/libzw-output libzw

You will see a new libzw in the Debug-iphoneos sibling directory, which indicates that the support simulator is supported by the real machine, if you do not believe you can execute the command

Lipo-info LIBZW you will see that there are armv7 and i386 in it, and then replace it with Release-iphoneos in Libzw.framework directory,

At this point the libzw.framework can be used simultaneously in both the real machine and the simulator, so that's all.

Forwarding Address: http://blog.csdn.net/fengsh998/article/details/8290687

iOS makes its own 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.