加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在Xcode中停止应用程序时自动关闭iOS模拟器

发布时间:2020-12-14 17:30:11 所属栏目:百科 来源:网络整理
导读:每当应用程序在 Xcode中停止时,是否可以关闭/退出iOS模拟器?我无法在Xcode或Simulator中找到设置.如果存在,它将有助于加快开发过程. 解决方法 要在构建停止时终止模拟器,您需要编译包含以下内容的可执行文件 #!/bin/shosascript -e 'tell app "iPhone Simul
每当应用程序在 Xcode中停止时,是否可以关闭/退出iOS模拟器?我无法在Xcode或Simulator中找到设置.如果存在,它将有助于加快开发过程.

解决方法

要在构建停止时终止模拟器,您需要编译包含以下内容的可执行文件

#!/bin/sh
osascript -e 'tell app "iPhone Simulator" to quit'

保存此文件,然后打开Xcode首选项的行为部分,在运行完成部分将脚本文件添加到运行部分.
希望这对你有用,但是这种方法似乎有点不稳定,不幸的是我能想出的最好的方法!
祝好运!

你不是在制作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");


}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读