BSMachError on granting access to camera

2019-02-20 02:56发布

问题:

This is a mystery to me and I hope you can help me out...

I have made an app that has got a QR-scanner and when accessing it on a fresh install on my iphone an alert is shown subsequently. The problem is that the camera image freezes up and I am unable to scan any QR-codes...

This problem goes away once I run the application from xcode again...

This is what's printed out in the console:

_BSMachError: port 13403; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"

Note that I have added NSCameraUsageDescription to Info.plist.

Thanks for your help!


UPDATE: I've tried adding NSPhotoLibraryUsageDescription and other similar permissions to the Info.plist file, as well as changing the localization native development region from EN to US (as solution read in other threads) but still no luck...


UPDATE #2:

I created a new project yesterday, reusing the same code and the "QR-scanner view" works just fine!

Question: Could it be some form of conversion-related issue?

The project was created in Swift 2.2 and converted to the new syntax of Swift 3 just recently. That is the only real difference regarding the issue that I can think of...

Happy to hear your thoughts on this matter!

回答1:

It might be occurring due to missing permissions. Try adding the below in Info.plist keys like NSPhotoLibraryUsageDescription



回答2:

Found the problem!

The issue suddenly occurred in my new project as well, so I started debugging! While running the app I checked out the Debug View Hierarchy (the 3D snapshot function in the console menu)...

So it turned out that there was a second instance of the UI running on top of another one - This is the reason why my camera-view appeared to have frozen.

Cause: I have a slide-out menu (from tutorial: http://dennissuratna.com/slide-out-navigation-swift/) set in my app and had added login and registration-views (from tutorial: https://www.youtube.com/watch?v=PKOswUE731c) to the project. Now I found out that the second instance of the UI was created after logging into the app and thereby causing the problem. Removing the connections to the login and reg-views solved the issue, so now I just have to find out where to make the proper implementations for it all to work as desired.

NOTE: The BSMachError-message is still printed out in the console whenever I run a fresh install of the app on my iPhone. The "error" is printed in the console when the alert for granting access to the camera is shown on screen.
The app runs as expected, without any problems, so I think it's safe to say that the
BSMachError-printout should be viewed as a printout and not an actual error that would cause a potential crash.



回答3:

Xcode 8.2.1, iOS 10.2.1

Just ran into the same issue. Please make sure you have a message entered for NSCameraUsageDescription and NSPhotoLibraryUsageDescription.

To easily find these keys select "Show Raw Keys & Values" from the Editor menu.

Hope this helps.

Cheers.