XcodeCreate and addLibaryInstance operations are the content of this article, mainly introduces howXcodeCreate customLibaryAnd howLibaryAdd to project.
1. Create "Libary"-> "Cocoa Touch static libary" project "LibaryTest ";
2. Create a "HellowWorld" class:
- //HelloWorld.h
- #import <Foundation/Foundation.h>
- @interface HelloWorld : NSObject {}
- -(void)helloWorld;
- @end
- //---------------//
- HelloWorld.m
- #import "HelloWorld.h"
- @implementation HelloWorld
- -(void)helloWorld{ NSLog(@"hello world");
- }
- @end
3. Create a "Window-based Application" project "TempTest ";
4. Create a new Group named "Dependencies" under TempTest ";
5. Under "Dependencies", "Existing Files ...",
Select "LibaryTest. xcodeproj" and click "Add ",
In the pop-up panel, select the "Relative to project" option of "Reference Type", and then confirm.
6. In the Dependencies Details window, select LibaryTest. a, and click to enlarge ):
7. in LibaryTest. right-click the "get info" window on xcodeproj and we can see that the relative path to the current project is ".. /LibaryTest. xcodeproj ". open the "get info" Window of the current project, Search for the head in build, and find the "Header Search Paths" item. Double-click this option ".. /LibaryTest ,:
Click OK. In the current project (TempTest), classes and methods in LibaryTest should be prompted normally.
8. After TempTestAppDelegate. m is modified, the Code is as follows:
- #import "TempTestAppDelegate.h"
- #import "HelloWorld.h"
- @implementation TempTestAppDelegate
- @synthesize window;
- #pragma mark -
- #pragma mark Application lifecycle
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch. HelloWorld *helloworld = [[HelloWorld alloc] init];
- [helloworld helloWorld];
- [self.window makeKeyAndVisible];
- return YES;}#pragma mark -#pragma mark Memory management- (void)dealloc {
- [window release];
- [super dealloc];}
- @end
"Command + B" Compilation, no problem. after "LibaryTest" is modified, compilation is still normal, but the "Command + R" operation may be faulty. so far, we have added LibaryTest to the current project, but it will not compile the LibaryTest library when compiling the current project. therefore, we also need to add the dependency on LibaryTest in the current project.
9. Open the "get info" Window of TempTest under Targets. Select the genaral tag and add the dependency on LibaryTest in "direct dependencies.
Summary:XcodeCreate and addLibaryI hope this article will help you with the introduction of instance operations!