I'm trying to make sure to cover all my bases with regard to ALAssetsLibrary failing for whatever reason. In looking through the possible errors that could occur when calling:
- (void)enumerateGroupsWithTypes:usingBlock:failureBlock;
i noticed that ALAssetsLibraryDataUnavailableError, but there isn't much information about what might cause this. I want to show an error screen accordingly.
Any insight would be appreciated. Thanks!
I encountered the ALAssetsLibraryDataUnavailableError in 3 cases:
When using the simulator and switching between iPhone and iPad simulator.
On the device, when the photo library was corrupt or in an inconsistent state.
After performing an iOS upgrade without having synced to iTunes.
I would recommend to display a message to the user, you run into this error, recommending:
1. To open the photos app...this usually fixes an inconsistent library.
2. If that doesn't help to reboot the Device and sync with iTunes one time.
Cheers,
Hendrik
Ok I found out another peculiar circumstance where this error appears:
Trying to save an UIImage to photo roll/photo album using UIImageWriteToSavedPhotosAlbum.
iOS asks the user for permission to access the photo library - the user denies(!)
In the completionSelector, the supplied NSError then contains ALAssetsLibrary ALAssetsLibraryDataUnavailableError.
You would think that the error would be something else like ALAssetsLibraryAccessUserDeniedError or ALAssetsLibraryAccessGloballyDeniedError. But it's not. It's just ALAssetsLibraryDataUnavailableError.
This was tested on iPhone 5, iOS 6.0.1. Maybe it's not an error, or it is and they will fix it someday.
Anyway, the "fix" is to have the user go into Settings→Privacy→Photos→have your app turned on here. The localized fix suggestion message is WRONG - it suggest to open the Photos app. No other information about the error given. Anyway, the user should probably know that he/she pushed the "Deny" button - still they might have done so by mistake and later they would have no idea what is going on.
Related
I am currently working on code to log a user's behavior in the app and to report crashes and the sequence leading up to them. I have one big problem, I do not know how to make my app detect if it has crashed. Does anybody know how to do this in swift? Your help would be much appreciated!
I don't think there is currently a way to do this. When your app crashes it ceases to function and all processes stop. Usually any crash and diagnostic data is sent via the user settings panel.
Edit: There is an helpful post here: https://stackoverflow.com/a/8242215/4891259
Hope that helps.
Our apps are live on the app store.
I wish to recognise crashes of out of memory that some users are getting.
I understand there is no way to 100% recognise an out of memory crash.
Is there any way to recognise these crashes(with a pretty large probability) by doing some logic in the applicationDidReceiveMemoryWarning? (I am not talking about finding it in xcode during development time, i am talking about code that will recognise the out of memory crash from actual users and will log something to file)
While I was looking for any service or library that give me OOM tracking, I could only find this article from Facebook engineering:
https://code.facebook.com/posts/1146930688654547/reducing-fooms-in-the-facebook-ios-app/
The idea is to deduce the reason why the app needs to be launch, checking different aspects (like if the app was at background, if there is an app/OS update,...).
Discarding all the other possible reason that can force the previous app exit, you can know if the reason is a background out of memory or a foreground out of memory.
It would be nice to have a library that implements the Facebook article procedure. But nowadays I couldn't find any, probably there is some reason that make this difficult or may be impossible to add it as an sdk.
If anyone knows any service, please share it with everyone with a comment or a new answer.
Edit:
I have discovered this github (https://github.com/jflinter/JRFMemoryNoodler) with an implementation of the Facebook post procedure. I haven't tried yet, but we will deploy it in our apps to try it.
Look out for the applicationWillTerminate message in your app delegate. This is called if you app is terminated by the system (due to e.g. low memory), but not if the user leaves the app in the usual way by pressing the home key. Note: if your app is in the background and memory runs out, your app gets killed without any messages being sent to it.
YMMV, especially with older versions of iOS, and it's worth researching to ensure that the above is accurate.
The images at this blog post are quite informative (although slightly dated).
For more info, see How to know whether app is terminated by user or iOS (after 10min background)
Firstly Analyse your application by clicking on the Product at the top menu bar of your Xcode and click on Analyse section it will show you the number of leaks on in the application and can take you to the place where leaks occurred. This is how you can find the memory leak and rectify it.
Secondly it above does not worked then see to the view controller where crash occurred and check whether you have left any object to release.
Hope this might help you to resolve your problem.
Should all NSLog() calls be deleted in the final app for iTunes?
In my iOS app, I've got lots of NSLog() for debug.
Should I conditionally code them out before uploading to iTunes?
This is for an app for: iPhone, iPod, iPad
Thanks.
I'll answer the OP's question in the title about where the logs are stored on the device. NSLog() uses the ASL (Apple System Logger). Programmatically, you can only read the last 256 entries (which is what Xcode shows in the Organizer, for example).
However, if you want to access the full files, they are stored in:
/private/var/log/DiagnosticMessages
When you look into that directory (note: device must be Jailbroken), you'll find a long list of *.asl files.
I found a tool to parse those files, but I haven't tried it yet, so YMMV:
Parsing Apple System Log (ASL) files on iOS and OSX for Fun and Evidence (and a Python script to do it for you)
You don't have to remove all of them; in fact, they can be useful if your app crashes on a user's phone and you want them to send you a crash log. When a user syncs his/her phone, the crash log is located in the folder
~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
If you have NSLog()s you may gain useful information just as you would when debugging. As the others pointed out, don't overdo it, but it they could end up being useful.
Yes, We should remove all the NSLog() calls before uploading to iTunes. That is done mainly for better performance.
Even if u dont remove them, no problem. It will be approved. But if u have lot NSLog() s, the that will def. affect the performance.
Try using this for your NSLogs:
#define DEBUG
#ifdef DEBUG
NSLog(#"Your tests outputs");
#endif
Not all. You should keep the error logs. That will make it easy to locate if there is any error or crash.
Its possible to see NSLog messages using Organizer too.
You dont need to remove NSLogs if they added against DEBUG mode. So even if your app crashes and if it contains user personal data, it will be removed by ios. So do not worry about user data and NSLog. Refer https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AnalyzingCrashReports/AnalyzingCrashReports.html
Still if you want you can use this PJiOSAppConsole in your application. It will keep logs in your application only. You can use it at runtime by adding snippet in #ifdef then remove whenever you want to go to live. Easy to integrate and use.
We have the loaded the app in the itunes but it got rejected because of following issues...
How to overcome the crashing reports while loading initially
This is the message from apple's site...
"Here is how we found this crash: 1) Launch application while connected to cellular or WiFi network connection. 2) Tap on the Find My Location button. 3) Application produces a crash."
can anyone help me out.
Thanks in advance...
Have you followed Apple's advice at all and tried to reproduce the crash? Do that, and check all the methods related to the Find My Location Button. Good things to look for - double releases, nil objects, infinite loops, that you're targeting the right iOS etc. Beyond stating the obvious, no one here can help you until you help us!
i am integrating twitter in my iphone music application.i.e when a user clicks a song and then he click on the twitter tab the login page of twitter should be opened and when he enters his username and password and then he clicks on the post button the song name and the comment he has entered in the textview should be posted to his twitter id.
the problem is that when i am clicking on the post button on the command it is showing as posted but then suddenly the program stops giving me an error of “EXC_BAD_ACCESS”.
Please help in solving the problem
You can use Instruments with the Zombie template to find the solution to this bug. You're probably trying to message a deallocated object.
EDIT: On the WWDC Session video's there is a video with a nice and good explanation how to find these kind of bugs. You must be a registered developer to access these videos though.
May I recommend using ShareKit for Social Media integration ?
http://getsharekit.com/ I've used this myself and it's by far the easiest solution of integrating social media interaction in your app.
Hope this helps.
I wrote a blog that gives several approaches to finding EXC_BAD_ACCESS
http://loufranco.com/blog/files/debug-iphone-crash-EXC_BAD_ACCESS.html
Here is what is happening -- Your program is running a line of code that tries to read or write to a memory location that hasn't been mapped for your application. The most likely reason for this is that you have a bug that is corrupting memory or you are sending messages to deallocated objects.
It is very likely that the line of code that is running is not the bug -- it happened sometime before this.
I strongly recommend a Build and Analyze and scan-build, because it finds these kinds of bugs a lot. It will likely flag a lot of code in your project -- you should address each problem because it's likely a real problem that will cause a leak or crash.
After that, try suggestion #4 in the blog which will instruct the simulator to never deallocate any objects -- once an object is in the state where it would be deallocated, it will warn you if anyone sends it a message. This would have caused EXC_BAD_ACCESS, but now gives a good description of what is happening.
Obviously, you need to turn this off in the real application (or have a lot of leaks).