The creation of the iOS Framework Universal Library

Source: Internet
Author: User

This article was modified on the basis of the most complete iOS DIY framework detailed tutorial (i) in history

1. Create a new Static library project:

2: Take your favorite name:

3. Delete Target from the project generated by the wizard:

3, delete the testframework corresponding project folder:

5: Delete bulid-connected items

Select the lower left corner manager Scheme

Select Scheme and click the minus sign in the lower left corner to delete:

When the deletion is complete, click OK to return.

5, add a new goal. Click "Add Target"
< yo? " http://www.2cto.com/kf/ware/vc/"target=" _blank "class=" Keylink ">vcd4kpha+cjxpbwcgc3jjpq=="/HTTP/ Www.2cto.com/uploadfile/Collfiles/20140303/20140303094208126.png "alt=" \ ">

In the pop-up dialog box, select Bundle under Mac OS X:

In fact, this bundle choose iOS also line, I have tried all 2 kinds of, is OK, if I say wrong please point out.

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

6. Modify the project settings of the new target. Select the corresponding target in TARGETS, Build Settings page:

On 7.target, right-click Get Info to set the following items under Build settings

A.base SDK Select latest iOS (iOS 5.1)

B.build Active Architecture only select No

C.dead Code stripping set to No

D.mach-o Type is a relocatable Object file (This setting specifies that the compiler makes a file bundle that can be relocated, by doing so, the function settings can be wrapped within the frame)

E.link with standard Libraries No

F.wrapper extension modified to: The default bundle is changed to the framework (here the bundle is modified to the framework, in Xcode, the framework is just an extended folder. The framework contains one or more compiled binary sources, resources, and some folders. The folder is usually called "Headers" and contains all the common header files)

G. Select Standard (ARMv6 armv7[armv7s) in the architectures option (no such compilation will cause an error)

H. Project info Change the value of bundle OS Type code BNDL to: FMWK

Under Deployment, change "Mac OS X Deployment Target" to "Compiler Default",

Change "targeted Device Family" to desired, and change it here to "Iphone/ipad",

At the same time, you can modify the iOS Deployment Target as needed, and change to "iOS 3.0" here:

8, modify the precompiled header: just comment out all

10. Add a class to the project :




10, in Mytestclass. H Add a method testfounction:


11, in Mytestclass. The implementation method in M Testfounction:


12. Open the Build Phases tab, click on the Add Build phase–add copy Headers in the lower right corner, and then the interface will come up with a copy Headers menu and add the source file. After completion: (Compile Sources Add. m file)

Click "ADD copy Headers" in the lower right corner:

When you are finished adding, expand Copy Headers: Click the plus sign:

Select the header file that needs to be exposed, here we select "MyTestClassA.h":

Click the Add button to complete the add: At this point, we see the exported file under Project, so that it is not exposed to others to use, and move it to public:

12. Then build & Run,

The success is very close, haha!

13. The following can be used to import the framework we generated above to other projects to use, haha!

Find the bulid->products->debug-iphonesimuator->testframework.farmework of our framework's engineering catalogue

14. Under where you want to import the header file

#import

Use the following:

[HTML] view Plaincopy

    1. mytestclass* Vc1=[[mytestclass Alloc]init];
    2. [Vc1 testfounction];
    3. [VC1 release]; 15.bulid&run

      16 Additional Instructions

      In the build, you will find that there is a run Test Profile3 option, generally we use the build for run, so you just need to configure the run this option.

      This build Configuration selection Dubug and release can build successfully, personally understand: This package is used in debug mode or Release mode, the most common is in the debug mode we print some logs, In release mode we need to hide the function of the print log.

      But there are some minor problems to note:

      If the export library build configuration is release, then the build of the project referencing this export library needs to be set to release.

      If the export library build configuration is debug, then the build of the project referencing this export library needs to be set to debug.

      This means that your project is as consistent as possible with the build Configuration of this library. (if that's not true, please indicate the error)

      17 Making a common framework

      1. Select Simulator Build

      2. Select iOS Device build, so you will get 2 framework

      3, and the production of general Static library xx.a file, the same command lipo-create file1 file2-output file3

      In particular, we are using lipo-create when we make the XX.A Universal library. /xx.a. /xxx.a-output xxxx.a

      But the framework was created using a aa.framework AA, such as the Myframework file in Myframework.framework, not myframework.framework the file.

      Like Lipo-create. /release-iphoneos/myframework.framework/myframework. /release-iphonesimulator/myframework.framework/myframework

      -output. /newframework

      This you will get a newframework file and then rename this newframework file myframework, use this file to

      Release-iphoneos (iphonesimulator)/myframework.framework Myframework replaced, then you can use the library.

      (In fact, you can export the time, export to Myframework, and then replace with this exported file, here is just an example,.) framework production than. A more than a replacement step)

The creation of the iOS Framework Universal Library

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.