59

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:

_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?

11
  • I got the same problem running Xcode Version 7.0 (7A218). Too early to find a pattern; just noticed it. Sep 12, 2015 at 20:15
  • Same here... got it now for the first time after setting a breakpoint in viewDidDisappear
    – DiogoNeves
    Sep 22, 2015 at 9:29
  • Same here, using Objc in Xcode 7.0 (7A220).
    – PatrickV
    Sep 22, 2015 at 19:58
  • Same here, getting the problem on Xcode 7 GM
    – xta
    Sep 23, 2015 at 6:05
  • 1
    I'm getting it in Version 7.2 (not beta) when I rotate my iPhone 6 iOS 9.2. I have two webViews on screen, and am not using the network (at the time of the error). My webViews don't seem to draw as fast, it's not noticeable, but I have some Javascript that measures various things that reports incorrect results at around the same time this error occurs.
    – narco
    Jan 6, 2016 at 23:12

8 Answers 8

21

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

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 errors by verifying/granting access to the particular site(s) you're pulling from.

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

  • You may want to alter your ATS Exception Dictionary to 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>
    

More details to this solution can be found here or here The Apple Documentation for App Transport Security is worth reading too.

2
  • 8
    I've made a simple test app that has no network activity whatsoever, still getting this error. Seems like it has something to do with core layout functionality. Your answer seems irrelevant.
    – NKorotkov
    Nov 11, 2015 at 9:12
  • 2
    @NKorotkov the error may spawn from multiple scenarios, see Mark L's answer
    – mattgabor
    Jan 7, 2016 at 18:28
17

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.

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.

1
  • This handled the problem for me. I was displaying a PDF using the documentInteractionController and adding the delay made the error go away. Thanks!
    – jroyce
    Feb 24, 2016 at 14:24
3

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

1
3

Dismissing view controller prematurely might cause this.

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

This throws _BSMachErrors

vs

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

Now, the _BSMachError is gone.

2

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

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

2
  • 3
    I don't think these are the Apple Docs, but docs of a third-party. Dec 18, 2015 at 16:11
  • true, this is generated using CocoaDocs, which looks similar to Apple's documentation but is user generated. It is in reference to a specific app designed by Bell App Lab
    – mattgabor
    Jan 7, 2016 at 18:30
2

I make like that

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

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

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.

0

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

1
  • Welcome to StackOverflow! For future reference, please try to post additional questions like this in the comments section, as this is not actually a solution. Thanks Jul 25, 2016 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.