SBApplicationController import 失敗 無法complie 拿到executable file name

需求: 解決錯誤訊息,進而成功取得BundleExecutable

OBJC_CLASS$_SBApplicationController”, referenced from:
objc-class-ref in demoApp.m.a4bf09cc.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
环境: ios 8.1.2

操作步骤:
我的應用程式不是tweak,只是越獄application,我嘗試想使用SpringBoard裡面的方法:

NSString *appStoreString = [[SBApplicationController.sharedInstance applicationWithBundleIdentifier:@"com.apple.AppStore"] displayName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:appStoreString message:nil delegate:target cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];

看到幾個網站的教學是將SpringBoard資料夾放到theos/include的路徑底下,但是我無論怎麼去import不同大大提供的headers檔進去我的theos/include裡面,總是出現少了哪個哪個檔案的錯誤訊息,我已經試著下載三個不同的headers來源限制在ios 8.1,還是無法complie成功,也無法使用SBApplicationController裡的方法取得executable id. 想請問各位大神,要如何在非tweak, 非hook的一般root越獄app使用springboard的方法?

我知道可以使用AppList去取得“類似”的資訊但不是我要的,我最只能從以下方法得到/private/var/mobile/Containers/Bundle/Application/xxxxxxxxxx/TargetApp.app。但我只希望得到TargetApp這個executable file的name而已,在valueForKey我自己嘗試輸入可能得值,只可得到path, displayName, displayIdentifier。
請大大可以告訴小弟要輸入哪個valueForKey的值可以直接拿到executable name?

NSString *testBundlePath = [ALApplicationList.sharedApplicationList valueForKey:@"path" forDisplayIdentifier:@"com.Addcn.house591"];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:testBundlePath message:nil delegate:target cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];

再麻煩各位大神了

參考網站:
https://stackoverflow.com/questions/13327435/theos-springboard

你不能在一个进程里调用另一个进程的方法;
要达到你的目的,可以在SpringBoard里写个监听器,当你的App需要调用SpringBoard里的某个方法时,向SpringBoard发一个notification,监听器收到这个notification后去调用方法;调用结束后,从返回值中提取出需要的信息,再通过notification的回复发送给你的App

1 个赞

懂了!我观念错误,SpringBoard是一个application,当然不能由我的application 进程去呼叫他的进程的方法。监听器的做法大大您的意思应该是去写一个tweak去hook做一个监听器?这手法俺可能需要花三天学习一下。谢谢大大的解释~豁然开朗

刚刚不得已只好尝试土炮的方法,结果是成功了,但不太简洁,我po在我的回覆底下当作是勉强的方桉 供其他同学参考。

以下是我最后终于搞定的解法 (卡了两天半)我不是很满意这麽繁杂的写法(尤其是那87的字元位置),但透过狗神解说,了解我自己当前的进程不可能直接呼叫SB的进程方法后,已无后路。至少拿到想要的结果,在这裡提供给各位同学参考,欢迎交流。

使用此段代码必须套用AppList相关档桉,参考网址在此:
http://iphonedevwiki.net/index.php/AppList

NSArray *sortedDisplayIdentifiers;
NSDictionary *applications = [[ALApplicationList sharedApplicationList] applicationsFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"isSystemApplication = FALSE"]
onlyVisible:YES titleSortedIdentifiers:&sortedDisplayIdentifiers];

NSMutableArray *exeBundleIDArr = [NSMutableArray array];
NSEnumerator *enumerator = [applications keyEnumerator];
NSString *key;
while ((key = [enumerator nextObject])) {
    NSString *identifier = key;
    NSString *exeBundleIDPath = [ALApplicationList.sharedApplicationList valueForKey:@"path" forDisplayIdentifier:identifier];
    NSString *exeBundleIDFileName = [exeBundleIDPath substringFromIndex:87];
    NSRange r1 = [exeBundleIDFileName rangeOfString:@".app"];
    NSString *exeBundleID = [exeBundleIDFileName substringToIndex:r1.location];
    [exeBundleIDArr addObject:exeBundleID];
}

这个结果会是一个NSArray裡面拥有所有你当前安装的app store apps 的 当前executable bundle id