我注意到theos可以构建库并生成dylib,我尝试像
这样的简单代码static UIAlertView *alert_view;
static void showAlert() {
alert_view = [[UIAlertView alloc] initWithTitle:@"Welcome"
message:@"Welcome to your iPhone Brandon!"
delegate:nil
cancelButtonTitle:@"Thanks"
otherButtonTitles:nil];
[alert_view show];
[alert_view release];
}
make后我得到了一个dylib,但我尝试构建一个测试项目来使用这个dylib,失败了。 我的测试代码如
void* sdl_library = dlopen("/tmp/AlertDylib.dylib", RTLD_LAZY);
if(sdl_library == NULL) {
NSLog(@"fail load");
} else {
// use the result in a call to dlsym
void* showAlert = dlsym(sdl_library,"showAlert");
if(showAlert == NULL) {
NSLog(@"fail got function");
} else {
// cast initializer to its proper type and use
}
}
我确定我把dylib文件放在/ tmp /下,但是日志说“失败了功能”,我错过了哪些步骤?