每当 Xcode 中的应用程序停止时,是否可以让 iOS 模拟器关闭/退出?我无法在 Xcode 或模拟器中找到执行此操作的设置。如果存在的话,它将有助于加快开发进程。
要在构建停止时终止模拟器,您需要编译一个可执行文件,包括以下内容
#!/bin/sh
osascript -e 'tell app "iPhone Simulator" to quit'
Save this file then open the behaviors section of Xcode preferences, in the run completes section add your script file to the run section.
hopefully this will work for you, however this method seems to be a little spotty and is unfortunately the best way I've been able to come up with!
Good luck!
![enter image description here](https://i.stack.imgur.com/qtmCz.png)
遗憾的是您没有制作 OS X 应用程序,因为这样做非常容易。这部分是无关紧要的,但谁知道呢,你将来也许可以使用它!
- (IBAction)KillSim:(id)sender {
NSLog (@"Sim Kill Begin");
NSDictionary* errorDict;
NSAppleEventDescriptor* returnDescriptor = NULL;
NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
@"tell application \"iPhone Simulator\" to quit"];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
[scriptObject release];
if (returnDescriptor != NULL)
{
// successful execution
if (kAENullEvent != [returnDescriptor descriptorType])
{
// script returned an AppleScript result
if (cAEList == [returnDescriptor descriptorType])
{
// result is a list of other descriptors
}
else
{
// coerce the result to the appropriate ObjC type
}
}
}
else
{
// no script result, handle error here
}
NSLog (@"Sim Killed End");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)