Charts: Save picture crash in demos on iOS 11+

Created on 1 Mar 2018  路  9Comments  路  Source: danielgindi/Charts

As of iOS 11, Apple requires developers to declare the use of write-only photos action. Otherwise the app crashes when trying to save a pictures.

This is an issue on the ChartsDemo apps.

Steps to reproduce

  • Open the ChartsDemo-Swift app
  • Open the Bar Chart view
  • Press on Options
  • Select Save to Camera Roll
  • Notice the app crashes

Environment

Tested on iPhone 8 Plus 11.1 simulator.
I had the same issue happen to me on physical devices too.

Crash log

2018-03-01 14:07:45.963707-0500 ChartsDemo-Swift[60661:893072] [access] 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.
Message from debugger: Terminated due to signal 9

Fix

Fixing this is quite simple. Just add the following lines to the Info.plist

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Reason why you need this permission</string>

Most helpful comment

Glad to hear that :) Though the author has been inactive for quite a long time, we are lucky to have some collaborators working on it, though slowly.
General usage questions you are welcome to ask on Stack Overflow.
But for enhancements/new features, you can post here.
For advanced customizations, I'm not sure, but you can ask here I think.

Asking on SO can reduce our Github inbox size, so we can focus on something else.

All 9 comments

image
I checked, the info.plist seems already have the key.
Why crash then?

I just tried on my phone, it works expected, asking for permit, and once you allow it it will save to camera roll.

Hi @liuxuan30

I don't believe this bug was fixed. What is currently in the Info.plist is the NSPhotoLibraryUsageDescription key. Not the NSPhotoLibraryAddUsageDescription key. They are both different. On iOS 10 and prior, NSPhotoLibraryUsageDescription will be enough for iOS to open a permission request to the user, but not on iOS 11. Is your phone running iOS 11?

This is still crashing on simulators. I'll be more than happy to open a pull request to fix this if you reopen the issue

I remember it's 10.2 system. Not tested on 11 yet.
I will try find one and test again now.
This should be a quick fix if what you said is true. I can fix it in another PR

Thanks for reporting!

My pleasure! We're really pleased with your library, used on a couple commercial projects and I'm glad to see it's actively supported :)

If I had some questions on displaying more custom controls / labels where would it be appropriate to ask that?

Glad to hear that :) Though the author has been inactive for quite a long time, we are lucky to have some collaborators working on it, though slowly.
General usage questions you are welcome to ask on Stack Overflow.
But for enhancements/new features, you can post here.
For advanced customizations, I'm not sure, but you can ask here I think.

Asking on SO can reduce our Github inbox size, so we can focus on something else.

liuxuan30

Great Answer Work for me......

I remember it's 10.2 system. Not tested on 11 yet.
I will try find one and test again now.
This should be a quick fix if what you said is true. I can fix it in another PR

Great Answer Work for me......

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newbiebie picture newbiebie  路  3Comments

Shunshine07 picture Shunshine07  路  3Comments

PrashantKT picture PrashantKT  路  3Comments

JW00332 picture JW00332  路  4Comments

Bharati555 picture Bharati555  路  4Comments