我正在使用XCTest框架对iOS应用进行单元测试。该应用程序包括GoogleMaps.framework,我已经能够将框架本身添加到测试目标,但我收到许多令人难以置信的神秘的编译错误。我确信我错过了一些简单的东西,但我还没有找到解决方案。我还跟踪了与类似问题相关的许多其他帖子的许多说明:here,here和here等等。我相信,但并不积极,将框架的资源包与测试目标联系起来存在问题。
错误是“架构x86_64的未定义符号”或“架构armv7s的未定义符号”,具体取决于我是分别尝试在模拟器或实际设备上运行测试。
这是我选择产品>时XCode给我的东西测试:
Ld /Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo- exkiohzzsvdhtddmpgulwtyrytvy/Build/Products/Debug-iphonesimulator/GuardlyTwoTests.xctest/GuardlyTwoTests normal x86_64
cd /Users/fitzgeraldsimran/Documents/iOS/Guardly_2/guardly-iphone-2
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode51-DP2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode51-DP2.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode51-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode51-DP2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Products/Debug-iphonesimulator -F/Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Products/Debug-iphonesimulator -F/Applications/Xcode51-DP2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Developer/Library/Frameworks -F/Applications/Xcode51-DP2.app/Contents/Developer/Library/Frameworks -F/Users/fitzgeraldsimran/Documents/iOS/Guardly_2/guardly-iphone-2 -filelist /Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Intermediates/GuardlyTwo.build/Debug-iphonesimulator/GuardlyTwoTests.build/Objects-normal/x86_64/GuardlyTwoTests.LinkFileList -bundle_loader /Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Products/Debug-iphonesimulator/GuardlyTwo.app/GuardlyTwo -Xlinker -objc_abi_version -Xlinker 2 -ObjC -framework QuartzCore -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework GoogleMaps -framework XCTest -framework CoreData -framework UIKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Intermediates/GuardlyTwo.build/Debug-iphonesimulator/GuardlyTwoTests.build/Objects-normal/x86_64/GuardlyTwoTests_dependency_info.dat -o /Users/fitzgeraldsimran/Library/Developer/Xcode/DerivedData/GuardlyTwo-exkiohzzsvdhtddmpgulwtyrytvy/Build/Products/Debug-iphonesimulator/GuardlyTwoTests.xctest/GuardlyTwoTests
Undefined symbols for architecture x86_64:
"_CGImageSourceCreateImageAtIndex", referenced from:
_GMSCreateCGImageWithData in GoogleMaps(GMMImageSupport.o)
"_CGImageSourceCreateWithDataProvider", referenced from:
_GMSCreateCGImageWithData in GoogleMaps(GMMImageSupport.o)
"_GLKMatrix3Identity", referenced from:
gmscore::vector::GLLineGroup::SetTransform(gmscore::math::Matrix4f const&, gmscore::base::reffed_ptr<gmscore::vector::Camera> const&) in GoogleMaps(GLLineGroup.o)
gmscore::vector::GLAlphaOnlyTextureShaderProgram::GLAlphaOnlyTextureShaderProgram(bool) in GoogleMaps(GLBasicShaderState.o)
gmscore::renderer::TextureState::TextureState(unsigned int) in GoogleMaps(TextureState.o)
gmscore::renderer::TextureState::TextureState(unsigned int) in GoogleMaps(TextureState.o)
gmscore::renderer::TextureState::TextureState(gmscore::base::reffed_ptr<gmscore::renderer::ImageData> const&) in GoogleMaps(TextureState.o)
gmscore::renderer::TextureState::TextureState(gmscore::base::reffed_ptr<gmscore::renderer::ImageData> const&, gmscore::renderer::TextureState::TextureUnit) in GoogleMaps(TextureState.o)
gmscore::renderer::TextureState::TextureState(gmscore::base::reffed_ptr<gmscore::renderer::ImageData> const&, gmscore::renderer::TextureState::TextureUnit, bool, gmscore::renderer::TextureState::Filter, gmscore::renderer::TextureState::Filter) in GoogleMaps(TextureState.o)
...
"_GLKMatrix4Identity", referenced from:
-[GMSGLVectorTile applyTransform:camera:] in GoogleMaps(GMSGLVectorTile.o)
(anonymous namespace)::PointsBehavior::Commit(gmscore::renderer::EntityRenderer*) in GoogleMaps(GMSPointsEntityProvider.o)
(anonymous namespace)::StickerBehavior::Commit(gmscore::renderer::EntityRenderer*) in GoogleMaps(GMSStickersEntityProvider.o)
(anonymous namespace)::GLTileUpdaterBehavior::UpdateAndTransformTile(objc_object*) in GoogleMaps(GMSTilesEntityProvider.o)
(anonymous namespace)::BubbleBehavior::Commit(gmscore::renderer::EntityRenderer*) in GoogleMaps(GMSBubbleEntityProvider.o)
gmscore::streetview::Panorama::Panorama(int, int, int, int, int, int) in GoogleMaps(Panorama.o)
gmscore::vector::UpdateMyLocationBehavior::Commit(gmscore::renderer::EntityRenderer*) in GoogleMaps(GLMyLocation.o)
...
"_GLKMatrix4Invert", referenced from:
gmscore::streetview::Camera::Unproject(gmscore::math::Vector2f const&, bool*) const in GoogleMaps(Camera-B046EE312980DB98.o)
gmscore::vector::Camera::UpdateInternals() in GoogleMaps(Camera-3E3856CABC8A9C74.o)
gmscore::renderer::Camera3D::SetTransform(gmscore::math::Matrix4f const&) in GoogleMaps(Camera3D.o)
gmscore::renderer::Camera3D::Transform() in GoogleMaps(Camera3D.o)
non-virtual thunk to gmscore::renderer::Camera3D::Transform() in GoogleMaps(Camera3D.o)
"std::__1::__vector_base_common<true>::__throw_length_error() const", referenced from:
std::__1::enable_if<__is_forward_iterator<gmscore::model::ModelTriangle2D*>::value, void>::type std::__1::vector<gmscore::model::ModelTriangle2D, std::__1::allocator<gmscore::model::ModelTriangle2D> >::assign<gmscore::model::ModelTriangle2D*>(gmscore::model::ModelTriangle2D*, gmscore::model::ModelTriangle2D*) in GoogleMaps(GMSArea.o)
std::__1::vector<gmscore::model::ModelTriangle2D,
并且持续很长时间......
我的单元测试代码非常简单,我只是想让它编译:
#import <XCTest/XCTest.h>
#import "MyAppDelegate.h"
@interface MyAppTests : XCTestCase
@end
@implementation MyAppTests
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testGoogleMapsAPI
{
XCTAssertEqual(YES, [[MyAppDelegate appDelegate] activateGoogleMapsAPI], @"Google API should return YES");
}
@end
谢谢!