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?

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
mattgabor
  • 2,064
  • 6
  • 25
  • 38
  • I got the same problem running Xcode Version 7.0 (7A218). Too early to find a pattern; just noticed it. – Frederick C. Lee Sep 12 '15 at 20:15
  • Same here... got it now for the first time after setting a breakpoint in viewDidDisappear – DiogoNeves Sep 22 '15 at 09:29
  • Same here, using Objc in Xcode 7.0 (7A220). – PatrickV Sep 22 '15 at 19:58
  • Same here, getting the problem on Xcode 7 GM – xta Sep 23 '15 at 06:05
  • I also get the same warning using obj c in Xcode 7. How to solve it ? – Hardik Shekhat Sep 24 '15 at 10:48
  • I can also consistently reproduce this error by rotating the screen while the on-screen keyboard is up. Xcode 7.0.1, iOS 9.0.2. – j.f. Oct 08 '15 at 21:14
  • I also have the same issue. No pattern yet. Comes and goes. Not consistent. – Mehmet Oct 14 '15 at 15:39
  • Well, i got the same problem, Xcode 7.1.1, Swift 2.1 – Asinox Nov 15 '15 at 03:49
  • 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 06 '16 at 23:12
  • I got this message when I present a view inside alertView handler block . – Kiran P Nair Mar 26 '16 at 09:04
  • I got same error when appear keyboard, my xcode version is Xcode 7.3.1(7D1014). and my project is based on phonegap, jquery mobile. – sirius2013 Jun 07 '16 at 17:11

8 Answers8

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.

Community
  • 1
  • 1
ChrisHaze
  • 2,800
  • 16
  • 20
  • 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 '15 at 09:12
  • 2
    @NKorotkov the error may spawn from multiple scenarios, see Mark L's answer – mattgabor Jan 07 '16 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.

nurider
  • 1,555
  • 1
  • 18
  • 21
  • 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 '16 at 14:24
3

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

user1079052
  • 3,803
  • 4
  • 30
  • 55
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.

ychoi
  • 31
  • 2
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/

Mark Lummus
  • 740
  • 8
  • 17
2

I make like that

 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { () -> Void in
        AnswersDataServerEntity.saveSingleDocoment(doc)
    }
Alexander Khitev
  • 6,417
  • 13
  • 59
  • 115
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.

Naishta
  • 11,885
  • 4
  • 72
  • 54
0

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

Paul
  • 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 – cdomination Jul 25 '16 at 11:37