This article is based on the most complete iOS DIY framework tutorial (I) in history.
1. Create a static library project:
2: Get your favorite name:
3. Delete the Target in the project generated by the Wizard:
3. Delete the project folder corresponding to TestFrameWork:
5. delete a bulid Link
Select Manager Scheme in the lower left corner
Select 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"
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + CjxpbWcgc3JjPQ = "http://www.2cto.com/uploadfile/Collfiles/20140303/20140303094208126.png" alt = "\">
In the displayed dialog box, select the Bundle under Mac OS X:
In fact, this Bundle can also be selected in Ios. I have tried both of them, and it is okay. If I am not talking about it, please point it out.
For example, give the database a name, retain 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:
7. Right-click the target and choose get Info to set the following items under Build Settings.
A. Select Latest IOS (IOS 5.1) as the Base SDK)
B. Build Active Architecture Only select NO
C. Dead Code Stripping is set to NO
D. Mach-O Type is Relocatable Object File (This setting specifies the compiler to bind a relocable File. By doing so, function settings can be encapsulated in the Framework)
E. Link With Standard Libraries is NO
F. Wrapper Extension is changed to: The default bundle is changed to the framework (here, the bundle is changed to the framework. In xcode, the framework is just an extended folder. The Framework contains one or more compiled binary sources, resources, and folders. The folder is usually called "Headers" and contains all public header files)
G. Select "Standard" (armv6 armv7 [armv7s]) in the ubuntures option (an error will be reported if this is not the case)
H. Change the Bundle OS Type code value BNDL to FMWK in project Info.
Change "Mac OS X Deployment Target" to "Compiler Default" under Deployment ",
Change "Targeted Device Family" to the desired one. Here it is changed to "iPhone/iPad ",
At the same time, you can modify "iOS Deployment Target" as needed, and change it to "iOS 3.0" here ":
8. Modify the pre-compiled header: Comment out all
10. Add a class to the Project:
10. In myTestClass. H Add a method testFounction:
11. In myTestClass. Implementation Method testFounction in m:
12. Open the Build Phases tab and click Add Build Phase-Add copy Headers in the lower right corner. Then, a Copy Headers menu is displayed on the page, and the source file is added. After completion: (Compile Sources adds the. m file)
Click "Add copy Headers" in the lower right corner ":
After adding the Headers, expand "Copy Headers" and click the plus sign:
Select the header file to be exposed. Here we select "myTestClassA. h ":
Click the Add button to Add the exported file. The exported file is under the Project, so it cannot be exposed to others and moved to the Public directory:
12. Then Build & Run,
The success is very close, haha!
13. You can use the framework generated above to import it to other projects. Haha!
Find the Bulid-> Products-> Debug-iphonesimuator-> TestFrameWork. farmework in the project directory of our FrameWork.
14. Import the header file where you want to use it.
# Import
The usage is as follows:
[Html]View plaincopy
- MyTestClass * vc1 = [[myTestClass alloc] init];
- [Vc1 testFounction];
- [Vc1 release]; 15. Bulid & Run
16 additional instructions
During the Build process, you will find three options: Run Test Profile3. Generally, we use Build for run. Therefore, you only need to configure the Run option.
You can Build Dubug and Release in this Build Configuration. I personally think that this package is used in Debug mode or Release mode, the most common one is to print some logs in Debug mode, while in Release mode, we need to hide the log printing function.
But pay attention to the following issues:
If the Build Configuration of the import/export project is Release, you must set the Build Configuration of the project that references the import/export project to Release.
If the import/export Build Configuration is Debug, you need to set Build Configuration of the project that references the import/export as Debug.
That is to say, your project should be consistent with the Build Configuration of this library. (If not, please point out the error)
17. Create a common framework
1. Select the simulator Build
2. Select IOS Device Build, and you will get 2 frameworks.
3. Use the command lipo-create file1 file2-output file3, just like creating a common static library xx. a file.
Note that when we create the xx. a generic library, we use lipo-create.../xx. a ../xxx. a-output xxxx..
However, when creating the framework, you must use AA in AA. framework, such as the MyFrameWork file in MyFrameWork. framework, instead of the MyFrameWork. framework file.
For example, lipo-create.../Release-iphoneos/MyFrameWork. framework/MyFrameWork.../Release-iphonesimulator/MyFrameWork. framework/MyFrameWork
-Output ../NewFrameWork
In this case, you will get a NewFrameWork file, rename the NewFrameWork file MyFrameWork, and use this file
Replace the MyFrameWork in Release-iphoneos (iphonesimulator)/MyFrameWork. framework, and then you can use this library.
(In fact, you can export it as MyFrameWork and replace it with the exported file. Here is just an example. The. framework production process is replaced by.)