Solution to crash when saving pictures to album in IOS app

Time:2020-10-17

Environmental Science:

iPhone Version 11.0.3 ,  Xcode Version 9.0

Question:

When maintaining the app yesterday, it was found that the application crashed while saving the pictures after taking pictures. The output is as follows:

This app has crashed because it attempted to access privacy-sensitive data without a usage description.  The app’s Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

Google Translation:

This application has crashed because it attempts to access privacy sensitive data without instructions. Application’s Info.plist You must include an nsphotoliibraryaddusagedescription key with a string value that explains to the user how the application uses this data.

solve:

If you do not want to think and habitual Baidu, you will find that there are many similar problems. However, they are basically lack of “nsphotolinibrary usagedescription”, but here it is missing “nsphotolinibrary add usagedescription”.

In fact, translation has shown the problem, the reason for the collapse is info.plist Because of the lack of “nsphotolinibraryaddusagedescription” permission, you can add it yourself to solve the problem.

reason:

It is understood that the cause of the problem is that Apple has added a new permission after the ios11 system, and the permission “privacy – photo library additions usage description” needs to be added to save pictures in the future.

After testing, there is no problem saving pictures for devices that have not been upgraded to ios11, but the app will crash if the device is upgraded to ios11 and then saved. Students, please hurry to maintain it!

Figure:

Collapse display:

Add permission:

If you click “save to local” without adding permission, the app will crash. After adding permission, click “save to local” for the first time to pop up the permission pop-up window.

The solution to the crash when saving pictures to an album in the above IOS app is to edit all the content shared by you. I hope it can give you a reference and also hope you can support developeppaer more.