I have a swift project that depends on an objective-c++ static lib. When I compile the static lib alone, there is no error. But when I add the lib as a sub project to a swift project and compile it, I got the following error:
Undefined symbols for architecture x86_64: "___gxx_personality_v0", referenced from: +[obj_photo open] in libphoto.a(photo.o) Dwarf Exception Unwind Info (__eh_frame) in libphoto.a(photo.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
The objective-c++ file looks like this
// -- Obj-C++, photo.mm
#include "photo.hpp"
#import "photo.h"
#import <UIKit/UIKit.h>
#import <Photos/Photos.h>
#import <Photos/PHAsset.h>
#import <Photos/PHFetchOptions.h>
@implementation obj_photo
+ ( bool )open
{
PHFetchOptions *options = [[PHFetchOptions alloc] init];
PHFetchResult *fetchResult = [PHAsset fetchAssetsWithOptions:options];
return true;
}
@end
bool photo::open_photo()
{
return [obj_photo open ];
}
And in the swift file, I called the open_photo()
The weird thing is if I remove the following line:
PHFetchResult *fetchResult = [PHAsset fetchAssetsWithOptions:options];
I don't get the link error.
Any clues?