首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行测试时的目标C:未指定基类而定义的类

运行测试时的目标C:未指定基类而定义的类
EN

Stack Overflow用户
提问于 2014-01-13 09:59:27
回答 2查看 2.5K关注 0票数 6

我不知道发生了什么,因为我对objective c和IOS开发相当陌生。

当我尝试运行我的测试时,使用默认的测试框架,我得到以下错误:

代码语言:javascript
复制
        ..../Pods/Expecta/src/matchers/EXPMatchers+beCloseTo.m:4:1: 
Class 'EXPFixCategoriesBugEXPMatcher_beCloseToWithinMatcher' 
    defined without specifying a base class

下面这段代码产生了这个问题(然而它不是我的,我相信它是来自我通过pod使用的一个库的peice ):

代码语言:javascript
复制
#import "EXPMatchers+beCloseTo.h"
#import "EXPMatcherHelpers.h"

EXPMatcherImplementationBegin(_beCloseToWithin, (id expected, id within)) {
  prerequisite(^BOOL{
    return [actual isKindOfClass:[NSNumber class]] &&
        [expected isKindOfClass:[NSNumber class]] &&
        ([within isKindOfClass:[NSNumber class]] || (within == nil));
  });

  match(^BOOL{
        double actualValue = [actual doubleValue];
        double expectedValue = [expected doubleValue];

        if (within != nil) {
            double withinValue = [within doubleValue];
            double lowerBound = expectedValue - withinValue;
            double upperBound = expectedValue + withinValue;
            return (actualValue >= lowerBound) && (actualValue <= upperBound);
        } else {
            double diff = fabs(actualValue - expectedValue);
            actualValue = fabs(actualValue);
            expectedValue = fabs(expectedValue);
            double largest = (expectedValue > actualValue) ? expectedValue : actualValue;
            return (diff <= largest * FLT_EPSILON);
        }
  });

  failureMessageForTo(^NSString *{
    if (within) {
      return [NSString stringWithFormat:@"expected %@ to be close to %@ within %@",
              EXPDescribeObject(actual), EXPDescribeObject(expected), EXPDescribeObject(within)];
    } else {
      return [NSString stringWithFormat:@"expected %@ to be close to %@",
              EXPDescribeObject(actual), EXPDescribeObject(expected)];
    }
  });

  failureMessageForNotTo(^NSString *{
    if (within) {
      return [NSString stringWithFormat:@"expected %@ not to be close to %@ within %@",
              EXPDescribeObject(actual), EXPDescribeObject(expected), EXPDescribeObject(within)];
    } else {
      return [NSString stringWithFormat:@"expected %@ not to be close to %@",
              EXPDescribeObject(actual), EXPDescribeObject(expected)];
    }
  });
}
EXPMatcherImplementationEnd

我的POD文件如下所示:

代码语言:javascript
复制
platform :ios, 6.0
pod 'RestKit', '~> 0.20.0rc'

# Include optional Testing and Search components
pod 'RestKit/Testing', '~> 0.20.0rc'
pod 'RestKit/Search', '~> 0.20.0rc'


target :MTPROJTESTS do
  pod 'Expecta',     '~> 0.2.3'   # expecta matchers
  # pod 'Specta',      '~> 0.1.11'  # specta bdd framework
end

更新可可pods和预期后出现新错误:ld: library not found for -lPods-test clang: error: linker command failed with exit code 1 (use -v to see invocation)

错误:

代码语言:javascript
复制
Ld /Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Products/Debug-iphonesimulator/MYIOSPROJProjectTests.xctest/MYIOSPROJProjectTests normal i386
cd /Users/AUSER/Documents/Dev/MYIOSPROJProject/MYIOSPROJProject
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Products/Debug-iphonesimulator -F/Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Intermediates/MYIOSPROJProject.build/Debug-iphonesimulator/MYIOSPROJProjectTests.build/Objects-normal/i386/MYIOSPROJProjectTests.LinkFileList -bundle_loader /Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Products/Debug-iphonesimulator/MYIOSPROJProject.app/MYIOSPROJProject -Xlinker -objc_abi_version -Xlinker 2 -ObjC -framework CFNetwork -framework CoreData -framework CoreGraphics -framework Foundation -framework MobileCoreServices -framework Security -framework SystemConfiguration -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework XCTest -framework UIKit -framework Foundation -lPods-test -lPods-MYIOSPROJProjectTests -Xlinker -dependency_info -Xlinker /Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Intermediates/MYIOSPROJProject.build/Debug-iphonesimulator/MYIOSPROJProjectTests.build/Objects-normal/i386/MYIOSPROJProjectTests_dependency_info.dat -o /Users/AUSER/Library/Developer/Xcode/DerivedData/MYIOSPROJProject-cmxbzcbzjfbvgncspsalqnjvlova/Build/Products/Debug-iphonesimulator/MYIOSPROJProjectTests.xctest/MYIOSPROJProjectTests

我希望外面的人能提供一些线索:)

EN

回答 2

Stack Overflow用户

发布于 2014-01-19 15:42:11

关于新的链接器错误: Xcode喜欢添加用于测试的新构建目标,因此请确保所有合适的文件(例如,.m源文件、静态库、框架)都设置为包含在测试构建目标中。您可以通过在Project Navigator中选择该文件并查看file Inspector窗格中的"Target Membership“部分来完成此操作;确保选中了测试构建目标的复选框。此外,在您的项目设置中,您可以选择测试构建目标并转到构建阶段,然后查看"Link Binary With Libraries“以确保链接到适当的库。

票数 1
EN

Stack Overflow用户

发布于 2014-01-18 05:19:15

这听起来像是EXPFixCategoriesBugEXPMatcher_beCloseToWithinMatcher的基类在你的应用程序项目的前缀标题中,而不是导入到EXPFixCategoriesBugEXPMatcher_beCloseToWithinMatcher的.h文件中。你通常应该在你的类的接口文件的顶部导入基类:

代码语言:javascript
复制
#import "YourBaseClassHere.h"

@interface EXPFixCategoriesBugEXPMatcher_beCloseToWithinMatcher : YourBaseClassHere

// The rest of your class here

@end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21082802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档