2012-07-12 61 views
0

我做了一个使用委托模式的类,并将其放入静态库中。然后,我创建了一个演示应用程序来测试库。演示只是有一个单一的视图控制器,并在.h文件中,我有这样的:代表静态库中Xcode不工作

@interface ViewController : UIViewController <AuthenticationDelegate> 

@property (nonatomic, retain) IBOutlet UITextField *usernameTextField; 
@property (nonatomic, retain) IBOutlet UITextField *passwordTextField; 

@end 

当我编译,我得到该文件的第一行一个错误,指出正确的:

Cannot find protocol declaration for 'AuthenticationDelegate'.

但是,对于同一视图控制器.m文件,我有:

#import "Authentication.h" 
#import "ViewController.h" 

文件“Authentication.h”是我的静态库的唯一的头文件,它也宣布委托类:

@class AuthenticationProvider; 
@protocol AuthenticationDelegate <NSObject> 

@optional 

- (void)provider:(AuthenticationProvider *)provider didReplyWithResponse:(AuthenticationProviderResponse)response; 

@end 

我哪里错了?

更新:

如果我把#import "Authentication.h在ViewController.h,我得到这个:

Undefined symbols for architecture i386: 
    "_OBJC_CLASS_$_AuthenticationProvider", referenced from: 
     objc-class-ref in ViewController.o 
ld: symbol(s) not found for architecture i386 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我得到的,当我从ViewController.m删除#import "Authentication.h也。

+0

如果您引用AuthenticationDelegate在视图控制器头文件试试#import "Authentication.h",你需要把进口存在。 – jtomschroeder 2012-07-12 18:13:57

+0

@ j.tom.schroeder我试过,但我得到了错误,我更新我的问题。 – woz 2012-07-12 18:18:29

回答

1

类中的.h文件中,而不是你.m文件

+0

我试过了,但是我收到错误,我刚更新了我的问题。 – woz 2012-07-12 18:17:35

+0

好吧,这是进步 - 现在这是一个链接阶段的错误,而不是编译阶段..看起来像你的静态库没有被链接。将它添加到你的“链接二进制库”构建阶段。 – nielsbot 2012-07-12 18:19:41

+0

好的,太棒了!我认为它很接近。但我还有另一个错误,这可能与此无关。当我编译时,我得到:'ld:warning:忽略文件... /认证演示/身份验证演示/ libAuthentication.a,文件是为了归档而构建的,而不是被链接的架构(i386)'。我现在正在努力,但目前还没有运气。 – woz 2012-07-12 18:34:41