_BSMachError XCode 7 Beta

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32341851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:09:43  来源:igfitidea点击:

_BSMachError XCode 7 Beta

xcodexcode7

提问by mattgabor

I am getting the following error when I am running my code in Xcode7 with Swift2, after presenting a view controller through a push segue:

当我在 Xcode7 和 Swift2 中运行我的代码时,我收到以下错误,在通过 push segue 呈现视图控制器后:

_BSMachError: (os/kern) invalid capability (20)
_BSMachError: (os/kern) invalid name (15)

The other SO articles had no resolution, does anyone know about this issue?

其他 SO 文章没有解决方案,有人知道这个问题吗?

采纳答案by ChrisHaze

Although this problem seems to persist as a bug and will likely be fixed, it stems from the new App Transport Securitythat has been implemented in iOS 9.

虽然这个问题似乎作为一个错误持续存在并且很可能会得到修复,但它源于iOS 9 中实施的新App Transport Security

If your application pulls data from a web server, in order to populate the View Controller that you will be presenting, you can resolve these errorsby verifying/granting access to the particular site(s) you're pulling from.

如果您的应用程序从 Web 服务器拉取数据,为了填充您将呈现的视图控制器,您可以通过验证/授予对您从其拉取的特定站点的访问权限来解决这些错误

In order to address this you will add the following to your App's .plist file:

为了解决这个问题,您需要将以下内容添加到您的应用程序的 .plist 文件中:

  • You may want to alter your ATS Exception Dictionaryto fit your needs

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>testdomain.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <false/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSRequiresCertificateTransparency</key>
                <false/>
            </dict>
        </dict>
    </dict>
    
  • 您可能想要更改您的ATS 例外词典以满足您的需要

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>testdomain.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <false/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSRequiresCertificateTransparency</key>
                <false/>
            </dict>
        </dict>
    </dict>
    

More details to this solution can be found hereor hereThe Apple Documentation for App Transport Securityis worth reading too.

可以在此处此处找到有关此解决方案的更多详细信息 The Apple Documentation for App Transport Security也值得一读。

回答by nurider

I had the same two error messages. In my case, the errors were appearing when I called [[UIApplication sharedApplication] openURL:url]after the user selected a button in an open UIAlertController. I assumed the alert was trying to close at the same time I was trying to open the URL. So, I introduced a slight delay and the error message went away.

我有相同的两条错误消息。在我的情况下,当我[[UIApplication sharedApplication] openURL:url]在用户选择一个打开的按钮后调用时出现错误UIAlertController。我假设警报试图在我尝试打开 URL 的同时关闭。所以,我引入了一个轻微的延迟,错误信息消失了。

dispatch_after(0.2, dispatch_get_main_queue(), ^{
    [[UIApplication sharedApplication] openURL:url];
});

Not sure if this helps with your particular problem, but I thought it might be helpful to share.

不确定这是否有助于解决您的特定问题,但我认为分享可能会有所帮助。

回答by user1079052

Change the Localization native development region key in your info.plist from en to United States

将 info.plist 中的本地化本地开发区域键从 en 更改为 United States

回答by ychoi

Dismissing view controller prematurely might cause this.

过早关闭视图控制器可能会导致这种情况。

[self dismissViewControllerAnimated:YES completion:NULL]; 
//<do something..>

This throws _BSMachErrors

这会抛出 _BSMachErrors

vs

对比

//<do something..>
[self dismissViewControllerAnimated:YES completion:NULL]; 

Now, the _BSMachError is gone.

现在,_BSMachError 消失了。

回答by Alexander Khitev

I make like that

我这样做

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { () -> Void in
        AnswersDataServerEntity.saveSingleDocoment(doc)
    }

回答by Mark Lummus

I got these errors when I was using the keyboard. According to this note in Apple Docs, this is somewhat expected.

我在使用键盘时遇到了这些错误。根据 Apple Docs 中的这个说明,这在某种程度上是预料之中的。

http://cocoadocs.org/docsets/Keyboard/0.3.0/

http://cocoadocs.org/docsets/Keyboard/0.3.0/

回答by Naishta

Having this statement right below IBAction Button was causing the issue.

在 IBAction Button 正下方有此声明导致了问题。

self.view.endEditing(true)

The issue was fixed in Swift 3, by commenting out the above line and handling the end editing in a different way, or can also be fixed adding the above line after all other code under IBAction.

该问题已在 Swift 3 中修复,通过注释掉上面的行并以不同的方式处理结束编辑,或者也可以在 IBAction 下的所有其他代码之后添加上面的行来修复。

回答by Paul

I had this problem while debugging and it disappeared when I removed a breakpoint in my response to the view size changing.

我在调试时遇到了这个问题,当我在响应视图大小更改时删除断点时它消失了。