如何使用Springboard Services Framework来使用SBSLaunchApplicationWithIdentifier

我想使用Springboard服务框架来使用下面的代码。

SBSLaunchApplicationWithIdentifier(CFSTR("com.apple.preferences"), false); 

但是,当我下载头文件,并在我的项目中使用它不会build立。 请让我知道如何使这项工作。

你准备用什么方法? 我的印象是从一个守护进程启动应用程序?

还有其他方法可以很容易地启动应用程序。 我发现最可靠的是使用显示器堆栈来正确启动应用程序。 其他启动应用程序的方法往往会导致问题,当你closures它,并试图重新启动,它崩溃。

使用theos,你可以做这样的事情:

 NSMutableArray *displayStacks = nil; // Display stack names #define SBWPreActivateDisplayStack [displayStacks objectAtIndex:0] #define SBWActiveDisplayStack [displayStacks objectAtIndex:1] #define SBWSuspendingDisplayStack [displayStacks objectAtIndex:2] #define SBWSuspendedEventOnlyDisplayStack [displayStacks objectAtIndex:3] // Hook SBDisplayStack to get access to the stacks %hook SBDisplayStack -(id)init { %log; if ((self = %orig)) { NSLog(@"FBAuth: addDisplayStack"); [displayStacks addObject:self]; } return self; } -(void)dealloc { [displayStacks removeObject:self]; %orig; } %end 

然后启动应用程序,执行此操作:

 id PreferencesApp = [[objc_getClass("SBApplicationController") sharedInstance] applicationWithDisplayIdentifier:@"com.apple.preferences"]; [SBWActiveDisplayStack pushDisplay:PreferencesApp]; 

但是,如果您真的想要使用该方法,则需要指定哪些错误会阻止构build它,并检查使用哪个头文件来构build它。 您还需要链接到SBS框架。