) IOS framework creation tutorial

Source: Internet
Author: User
IOS framework production tutorial. This is not a static package !!! We Use A work und to create IOS Framework The preceding steps are as follows:

1. Open xcode to create a" Cocoa Touch static library, and delete the existing target.

2. Right-click the project and select Add new target. In the pop-up window, find cocoa and select "loadable bundle" in the right-side window of cocoa ".
Note: Do not select Framework , Should be Framework It is on Mac OS. IOS does not support it, but IOS supports "loadable bundle (cfbundle )"

3. Right-click get info on target and set the following five items under build settings:
A. Search wrapper extension and change the default bundle Framework .
B. Modify Mach-O type to relocatable object file.
C. Disable dead Code Stripping, remove the check box!
D. Disable link with standard libraries.
E. Remove all references for "appkit" and "Foundation", delete all values of "other linker flags", and delete the value of "gcc_prefix_header!

4. Change the bundle OS type code value bndl to fmwk in the frameworks info. plist file, and change the type to fmwk under the Properties tab in the get info window of target.


5. Add your Code .
For example, we add a class
# Import <Foundation/Foundation. h>

@ Interface help: nsobject {

}

-(Void) show;

@ End

# Import "Help. H"


@ Implementation help

-(Void) show
{
Nslog (@ "framework !!! ");
}

@ End


6. Right-click "add --- new build phase --- new copy headers build phase" on the target, and a gray File Folder-copy headers.

7. Drag the. h file of the help class we just added from the top to the copy headers below, and right-click the folder-set role --- public.

8. From the above Framework Drag the. M file to the compile Sources folder under target.

9. Compile. If an error occurs, set "Other linker flags" to-objc,-all_load, and-lxml2 under build. Do not write them together. Add one item.

Note: If a large number Error , Indicating that you have not deleted the "appkit" and "foundation" references,

After compilation, refer:

Under build/debug-iphonesimulator,Framework Folder:

Use Framework

Import in new project Framework


Copy the created kibernet. Framework to the directory of the new project and select the kibernet. Framework folder.

Added

Use Framework Class:
Import header files
# Import "testframeworkviewcontroller. H"
# Import <kibernet/help. h>
@ Implementation testframeworkviewcontroller
Test in viewdid load:
-(Void) viewdidload {
[Super viewdidload];
Help * Help = [[help alloc] init];
[Help show];
[Help release];
}
Output result:

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.