LoginSignup
0
0

More than 3 years have passed since last update.

macOSでカメラを使うアプリを作るとき、'com.apple.security.device.camera' entitlementエラーが出たら

Posted at

macOSでカメラを使うアプリを作るとき、以下のようなエラーが出ることがある。

2020-08-03 22:26:56.800910+0900 Day9[16262:644033] Metal API Validation Enabled
2020-08-03 22:26:56.904507+0900 Day9[16262:644432] [access] This app has crashed because it has a hardened runtime and attempted to access privacy-sensitive data without an entitlement indicating its intent to access this data. The app must have the 'com.apple.security.device.camera' entitlement.
(lldb)

これは、カメラを使うアプリはセキュリティの制限があり、それをあらかじめ指示しなくてはならないからである。

  • Xcodeから、Cmd-1→infor.plist→右クリックしてAdd Row→Keyのところをダブルクリックして「NSCameraUsageDescription」と入力。自動的に「Privacy - Camera Usage Desciption」に変わる。
  • Valueをダブルクリックして任意のメッセージを入れる。「カメラからの画像を表示します。
  • Xcodeから、Cmd-1→MyApp→TARGETS→MyApp→Signing & Capabilities→All→Hardend Runtime→Cameraの左をcheck
  • Cmd-Rすると、「“MyApp.app”からカメラにアクセスしようとしています。」と、さきほどのメッセージと共に聞いてくるので「OK」

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0