可能重複:
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的絕佳信息,並提供大量示例。 –