Create a framework for iOS in xcode 4

Source: Internet
Author: User

Preface:

The Framework can be physically used to modularize iOS programs.

Benefits:

1. If the interface between modules is well defined, modular programs have good scalability and cohesion;

2. Physical modularization facilitates management and testing of the development process, especially when the program scale is relatively large.

3. If you can use the glue language as the adhesive, the program can adapt to future changes at a very small cost.

Disadvantages:

1. Because the database is a static database, there should be no runtime loss, but it has never been tested and is uncertain.

2. I don't know whether to use more memory for loading resources. I'm not sure if I have not tried it.



 

1. Create a static library project:

 

 

2. Delete the Target in the project generated by the Wizard:

Project status before deleting the target


Project status after the target is deleted



 

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

Before Deletion


After Deletion



 

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

 

Click the Manage Schemes button in the lower left corner:


Select the old Scheme and click Delete in the lower left corner:

After the deletion is complete, click OK to return.



 

5. Add a new target.Click "Add Target ":


In the displayed dialog box, select the Bundle under Mac OS X:

For example, give the database a name,Keep the default Framework(CoreFoundation), and then click Finish.



 

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

 

Under ubuntures, change "Base SDK" to "Latest iOS", and then change "ubuntures" to "Standard ":

 

Under Deployment, change "Mac OS X Deployment Target" to "Compiler Default", change "Targeted Device Family" to required, and change it to "iPhone/iPad ", at the same time, you can modify "iOS Deployment Target" as needed, and change it to "iOS 3.0" here ":

 

In Linking, change "Dead Code Stripping" to "NO", and 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 Info of the target.Click Info:


Change "Bundle OS Type Code" to "FMWK" (Framework meaning ):

 

 

8. Modify the pre-compilation header:

Before Modification


After modification



 

9. Add a class to the Project(ViewController and Xib ):


The result is as follows:

 

 

 

10. Export related files.Select Target and click Build Phases:


Click "Add Build Phase" in the lower right corner ":


Select "Add Copy Headers" in the pop-up menu. After adding the Headers, expand "Copy Headers ":


Click the plus sign:


Select the header file to be exposed. Here we select "ClassA. h ":


Click Add:


At this point, we can see that the exported file is under the Project, so that it cannot be exposed to others, and drag it to the Public:


For more information about the Framework, see Apple's online documentation: http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html#//apple_ref/doc/uid/10000183-SW1

 

 

11. compile the project and view the result:

 

 

 

12. This is a method for manually creating the Framework. Someone has created an Engineering Template on the Internet and can directly generate a Framework project:

Https://github.com/kstenerud/iOS-Universal-Framework

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.