iOSでEXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) が発生する
iOS 10(シミュレーター)で「EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)」でアプリが強制終了する。
Xcode8にはこのメッセージが出ている。
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
どうやら、 Photo Libraryを使うにはアプリに“Privacy - Photo Library Usage Description”の設定が必要なようだ。
NSPhotoLibraryUsageDescription “Privacy - Photo Library Usage Description” Specifies the reason for your app to access the user’s photo library. See NSPhotoLibraryUsageDescription for details. Cocoa Keys Cocoa Keys
ということでInfo.plistにNSPhotoLibraryUsageDescription
を入れてみたところエラーは解消した。
- Info.plist
<key>NSPhotoLibraryUsageDescription</key>
<string>for photo edit and store.</string>