Create and add Libary instances in Xcode

Source: Internet
Author: User

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:

 
 
  1. //HelloWorld.h  
  2. #import <Foundation/Foundation.h> 
  3. @interface HelloWorld : NSObject {}  
  4. -(void)helloWorld;  
  5. @end  
  6. //---------------//  
  7. HelloWorld.m  
  8. #import "HelloWorld.h"  
  9. @implementation HelloWorld  
  10. -(void)helloWorld{  NSLog(@"hello world");  
  11. }  
  12. @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:

 
 
  1. #import "TempTestAppDelegate.h"  
  2. #import "HelloWorld.h"  
  3. @implementation TempTestAppDelegate  
  4. @synthesize window;  
  5. #pragma mark -  
  6. #pragma mark Application lifecycle  
  7. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
  8. // Override point for customization after application launch.  HelloWorld *helloworld = [[HelloWorld alloc] init];    
  9. [helloworld helloWorld];     
  10.  [self.window makeKeyAndVisible];        
  11.  return YES;}#pragma mark -#pragma mark Memory management- (void)dealloc {     
  12.   [window release];      
  13.   [super dealloc];}  
  14. @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!

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.