📜 ⬆️ ⬇️

New iOS 5 File Policy and Wacker History



Good day, habrasoobschestvo!

I decided to split this article into two parts - the first will be about the NEP New File Policy and the cleaning of the favorite Documents folder, i.e. useful iOS-developer information (it seems they haven’t written about it yet on Habré). The information is very useful if you want to save nerves, time and money when filling in an update / new application on the AppStore, so I recommend reading it to everyone.
')
In the second, I will talk about the war with the first line of Epple technical support and watchman syndrome, but it is rather narrative and does not need to be read.

Where to write files now?


In any tutorial / manual for iOS 3.x-4.x it was written in English in white - create a method like

+ (NSString *) pathForDocuments { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); return [paths objectAtIndex:0]; } 

And write everything there - the base, cache, pictures downloaded from the Internet - in general, all that pleases. With the introduction of the iCloud service in iOS 5.0, Apple changed the policy due to the fact that both iTunes and iCloud make full backups of the Documents folder

Let me explain with an example - for example, you bought an iPhone and your favorite child, and after long tears, threats and persuasion, an iPad. A happy child immediately installed Angry Birds, but what a bad luck - I went through the school under the desk as much as two level packs, and on my home ipad, with which it is so wonderful to roll under a blanket after the end, while the dad does not see, you need to go through everything again.

But do not worry, baby! Wonderful iCloud synchronized your Documents folder, and now the newly opened Golden Eggs are available to you and under the covers! Now in HD.

If your application works according to this principle, then nothing needs to be changed. As stated in the rules of Apple, the content created by the user (user-generated content) is the most holy and Orthodox type of data and is subject to synchronization. But consider another example.

Such a phenomenon, in particular, is observed with Lingvo dictionaries. According to Apple’s commandments, the content that can be programmatically recreated or downloaded again from the Internet is strictly forbidden to be placed in Documents (for this, Reject is supposed). Instead, they should be placed in Library / Caches, from which the system, if there is not enough disk space, will immediately demolish them. The script is more common than you might think - it is worth downloading a couple of German HD movies on the iPad for evening viewing from your favorite, and the German-French dictionary is like it never happened - you will have to download it over 3G on the way to work. In the underground.

Naturally, the developers began to be outraged - the user does not want to use the program, from which the content, inflated with expensive megabytes of cellular tariff disappears. To do this, already in 5.0.1, Apple added the attribute Do Not Backup - you should put it on any file or folder in Documents, and iCloud, along with iTunes, will ignore them. At the same time, the system will not have the right to delete them if there is a shortage of free space, i.e. everything will remain as in the old fashioned way. In the code it looks like this (taken from an official source ):

 #include <sys/xattr.h> - (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL { const char* filePath = [[URL path] fileSystemRepresentation]; const char* attrName = "com.apple.MobileBackup"; u_int8_t attrValue = 1; int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0); return result == 0; } 


BUT - essential but - the need to store them in Documents will still need to be proved during a review (the point about the fact that without these files the user experience of the application collapses, needs to be justified). Of course, the reviewers do not add up to all - I witnessed how 2 weeks ago they missed an application that violated their rules, but the size of the files was scanty - no more than ten kilobytes. If your application needs dozens or even hundreds of megabytes - wait for quibbles and attacks, even if you update, and do not flood the application from scratch. Although it happens that after five or more days of waiting Apple doesn’t launch your application at all before appruv - thanks to Apple for that.

That's all for useful information, be sure to read the official rules - there are few letters, but they will save you a lot of nerves.

How to do


But all the problems could have been avoided if they just added a new folder to the file system, without affecting the old ones. For example, they would create a synchronized folder, where they would order to place saved games, favorite pages of readers and credits to the mail - and everyone who needs it would add the necessary pair of methods. Here is with Steve ...

How to deal with Reject


This will be useful only to those who have already encountered this problem. So, I come to work early in the morning and I see that the application has been registered. I read the holy tables to which the reviewer referred - and indeed, violated the commandments No. 1 and No. 2. But, after reading # 4, I understand that there is a loophole after all. A couple of minutes to add a code, 2 hours to QA testing, and we resubmit the application, accompanying it with a comment that we need our files “. Which, by the way, was pure truth.

Two days later, the second redjection comes in from Apple in the style:
Thank you for your reply.
// quote from the second paragraph about the inadmissibility of non-user-generated content

The customer was anally anxious, but I decided to take them in vain - I wrote out in detail, half a page, the purpose of each file, each small daddy, asked not to refer to clause 2, but clause 4. The customer also added a new answer after 3 days :
Thank you for your reply.
// quote from the second paragraph about the inadmissibility of non-user-generated content

The customer panicked, every day, 3 times I began to receive letters of content:

I don’t take it lightly.
But your refusal is disappointing and frustrating.

Or better yet
I'm not going to pay for lost time. And every client will be deducted from such invoices. You leave me no choice.

In general, thousands of them, but is not the point.

Given the speed of responses from Apple (every 2-3-4 days), the situation was heating up. The impression was that the reviewer was referring to the fourth paragraph of the tablets, focusing on the copy-paste of the first three.

It should be added that we wrote to the Resolution Center, describing our situation in different words, but each time we received the same devil-may-care answer. I don’t remember exactly who had the idea, but we wrote the same thing, with attached correspondence, to technical support , and after 3 days we suddenly got apruv.

Having read
Yay! WE ARE SO HAPPY AND EXCITED. THANKS FOR ALL YOUR HARD WORK! (EVEN WITH THOSE IDIOTS IN THE REVIEW PROCESS)
with peace of mind I went to drink beer with valerian.

Summary

Good luck to you and your applications, and may an appruv arrive with you!

Source: https://habr.com/ru/post/137711/


All Articles