加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – OCUnit中无法识别的导入文件

发布时间:2020-12-14 17:52:45 所属栏目:百科 来源:网络整理
导读:我正在使用XCode 3.2.3和iOS 4.0上的OCUnit在我的iPhone应用程序上进行单元测试.我已成功设置我的测试环境以适当地传递和失败基本测试,但是当我导入自己的文件时(在这种情况下,“UserAccount.h”,它无法编译并告诉我: “_OBJC_CLASS _ $_ UserAccount”,引
我正在使用XCode 3.2.3和iOS 4.0上的OCUnit在我的iPhone应用程序上进行单元测试.我已成功设置我的测试环境以适当地传递和失败基本测试,但是当我导入自己的文件时(在这种情况下,“UserAccount.h”,它无法编译并告诉我:

“_OBJC_CLASS _ $_ UserAccount”,引自:

然后它说“未找到符号”.这让我感到某种链接器错误,但我不知道发生了什么.我已多次建造和清理所有目标,但无济于事.这是我的测试代码:

#import "SomeTestCase.h"
#import "UserAccount.h"

@implementation SomeTestCase

 - (void)testUserAccount
 {
 // UserAccount.m //

 UserAccount *testAccount = [[UserAccount alloc] initWithUsername:@"" password:@"" deviceToken:@""];
 [testAccount registerNew];
 NSLog(@"USERID = %@",testAccount.userID);
 STAssertEquals([testAccount login],NO,@"Failure: Login should fail with blank username and password."); // should fail with no username or password

 UserAccount *testAccount2 = [[UserAccount alloc] initWithUsername:@"user" password:@"" deviceToken:@""]; 
 STAssertEquals([testAccount2 login],@"Failure: Login should fail with blank password.");// should fail with no password

 UserAccount *testAccount3 = [[UserAccount alloc] initWithUsername:@"" password:@"pass" deviceToken:@""]; 
 STAssertEquals([testAccount3 login],@"Failure: Login should fail with blank username.");// should fail with no password

 }

@end

任何建议将不胜感激.
谢谢!

-Matt

解决方法

我猜想UserAccount.m尚未添加到测试目标中.这将导致“未找到符号”错误.我看到有多个目标的时间,其中Xcode识别标题,即使实现文件不是目标的一部分.

如果这不起作用,请尝试使用Xcode>清空缓存清空Xcode缓存….

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读