如下面的例子
#import "ViewController.h"
#import <objc/runtime.h>
#import <dlfcn.h>
@interface AADeviceInfo : NSObject
- (id)serialNumber;
@end
@interface MyAADeviceInfo : AADeviceInfo
- (id)serialNumber;
@end
@implementation MyAADeviceInfo
- (id)serialNumber
{
id sn = [super serialNumber];
NSLog(@"SN is %@", sn);
return sn;
}
@end
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)getSNButtonPressed:(UIButton *)sender
{
void *openedAA = dlopen("/System/Library/PrivateFrameworks/AppleAccount.framework/AppleAccount", RTLD_NOW);
if (NULL == openedAA)
{
NSLog(@"!!!! Open AppleAccount failed !!!!");
return;
}
}
@end
The errors are:
Undefined symbols for architecture armv7:
“OBJC_METACLASS$_AADeviceInfo”, referenced from:
OBJC_METACLASS$_MyAADeviceInfo in ViewController.o
“OBJC_CLASS$_AADeviceInfo”, referenced from:
OBJC_CLASS$_MyAADeviceInfo in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
如果将framework拖进去,直接提示找不到framework。
ld: framework not found AppleAccount
clang: error: linker command failed with exit code 1 (use -v to see invocation)