可能重复:
Automatically close iOS Simulator when application is stopped in Xcode接近iPhone模拟器
就像标题所说,是有可能的Xcode应用程序内停有代码,并在完成后关闭模拟器?我问的原因是,如果我忘记手动关闭模拟器并让Xcode在模拟器运行时运行,由于CPU周期要求运行模拟器,Macbook变热。
可能重复:
Automatically close iOS Simulator when application is stopped in Xcode接近iPhone模拟器
就像标题所说,是有可能的Xcode应用程序内停有代码,并在完成后关闭模拟器?我问的原因是,如果我忘记手动关闭模拟器并让Xcode在模拟器运行时运行,由于CPU周期要求运行模拟器,Macbook变热。
使用AppleScript的关闭模拟器:
tell application "/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
quit
end tell
而且从你的应用程序启动它是这样的:
NSString * pstrScript= @"tell application \"/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app\"\nquit\nend tell";
if(!pstrScript)
{
NSLog(@"Error ReadAlbumArtitunesOperation::runWIthParameters:: if(!pstrScript)\n");
return nil;
}
_script = [[NSAppleScript alloc] initWithSource:pstrScript];
if(!_script)
{
NSLog(@"ERROR ReadAlbumArtItunesOperation:: runWithParameters:: if(!_script)\n");
return nil;
}
NSAppleEventDescriptor* desc= [_script executeAndReturnError:&_errorInfo];
if(_errorInfo)
{
NSLog(@"Couldn't run script: err=%@",[_errorInfo description]);
}
使用AppleScript的+1。 Automator和相关技术非常优秀 –
对AppleScript也是+1,但是您应该编辑它以在/Xcode.app中显示最新的模拟器位置。 –
谢谢你。我在我的机器上使用了iOS模拟器的位置。因此,任何使用此功能的人都无法使用,请找到iOS Simulator并将该路径替换为/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app – mark
http://stackoverflow.com/questions/9490238/automatically-close-ios -simulator-when-application-is-stopped-in-xcode –
查看http://macosxautomation.com/获取关于Mac OS X Automator的绝佳信息,并提供大量示例。 –