nickoneill / PermissionScope

Intelligent iOS permissions UI and unified API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_BSMachError: (os/kern) when going to Settings

trozware opened this issue · comments

If permission is denied and the "Show Me" dialog button is tapped to go to Settings, the console shows 2 errors:

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

This can be solved by using dispatch_after or dispatch_async on the main queue to open the Settings URL.

Ah, thanks for the tip @trozware! I'll work this into an upcoming release.

Maybe related to the project's "Localization native development region" in info.plist: http://stackoverflow.com/a/33465083/844907.

Anyhow, I cannot comment on the above ("en" is the default and should work).

For me it looks like an iOS bug, it is trigger by UIApplication.sharedApplication().openURL(settingsUrl!) when invoked by a handler.

Now the fun part, "fixing" it:

Current Call:

    let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString)
    UIApplication.sharedApplication().openURL(settingsUrl!) // error raised with this call

Solution: Explicitly invoke openURL on the main queue.

    dispatch_async(dispatch_get_main_queue()) {
        UIApplication.sharedApplication().openURL(settingsUrl!)
    }

Not what I want to see when invoking openURL, but this actually fixes the warning "for us". It's likely still logged in the iOS Console Logs, but Apple's fault, Apple's log.

Edit: Simplified fix.

@nickoneill I'm having the same issue where app crashes after any of the app permissions changes (have tried camera, microphone, and location) while the app is in the background e.g. after pressing "Show Me" on the showDeniedAlert. Same error message as @trozware.

I've tried @winkelsdorf 's fix of invoking openURL on the main queue, but that only removed the console error. App still crashed. This is what my "Show Me" code looks like w/ the fix:

        alert.addAction(UIAlertAction(title: "Show me".localized,
            style: .Default,
            handler: { action in
                NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("appForegroundedAfterSettings"), name: UIApplicationDidBecomeActiveNotification, object: nil)

                let settingsUrl = NSURL(string: UIApplicationOpenSettingsURLString)
                dispatch_async(dispatch_get_main_queue()) {
                    UIApplication.sharedApplication().openURL(settingsUrl!)
                }
        }))

I've also tried the localization "en" to "United States" fix in info.plist with no effect.

Anything I am doing wrong?

Update: App crash seems to be only with the debugger on. Running the app w/out debugger and switching permissions while it is in background will cause the app to not crash but restart.

@yichengsun Yes - the crash isn't an issue with PermissionScope but as-designed for iOS. Changing certain permissions in the settings screen will terminate apps that have requested those permissions. This particular issue is related to fixing the warning only.

gotcha

commented

@nickoneill is there a solution at this point or will it just always crash?

There is no solution @otymartin, this is expected behavior from the OS. The situation is unchanged from 12 days ago.

commented

@nickoneill Yea it crashes while app is connected via USB but works fine on its own.

Closing as PS isn't to blame for this issue