프로젝트 구성시 iCloud에 관한 설정을 신경쓰고 하지 않다보면 Appstore에 등록하는 

과정에서 iCloud 관련(QA1719) 문제로 Reject가 당하는 경우가 발생한다.


아래 email은 data storage guidelines 를 따라지 않았다는 사유이고, 내용을 자세히 보면

documents폴더에 데이터를 넣는 과정에서 iCloud와 문제가 생길 수 있다는 내용이다.


We found that your app does not follow the iOS Data Storage Guidelines, which is required per theApp Store Review Guidelines.

In particular, we found that on launch and/or content download, your app stores 4.13MB. To check how much data your app is storing:

- Install and launch your app
- Go to Settings > iCloud > Storage & Backup > Manage Storage 
- If necessary, tap "Show all apps" 
- Check your app's storage

The iOS Data Storage Guidelines indicate that only content that the user creates using your app, e.g., documents, new files, edits, etc., should be backed up by iCloud. 

Temporary files used by your app should only be stored in the /tmp directory; please remember to delete the files stored in this location when the user exits the app.

Data that can be recreated but must persist for proper functioning of your app - or because customers expect it to be available for offline use - should be marked with the "do not back up" attribute. For NSURL objects, add the NSURLIsExcludedFromBackupKey attribute to prevent the corresponding file from being backed up. For CFURLRef objects, use the corresponding kCFURLIsExcludedFromBackupKey attribute. 

For more information, please see Technical Q&A 1719: How do I prevent files from being backed up to iCloud and iTunes?. 



 
#include <sys/xattr.h>
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
        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;
    } else { // iOS >= 5.1
        NSError *error = nil;
        [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
        return error == nil;
    }
} 


iOS 5.0 이전 버전까지는 iCloud에 관한 설정을 신경쓰지 않아도 되기 때문에 상관없지만, 이후의 버
전에서는 apple의 정책에 맞게 데이터 관리를 해 주어야 한다.

혹시 iCloud를 사용한다면 다른 포스팅을 찾아보기를 바란다.

만약, iCloud를 사용하지 않는다면 아래와 같은 메서드를 추가해 줌으로써 해결이 가능하다.


위 코드의 사용방법은 자신이 코드상에서 documents 폴더에 접근하여 작업하는 부분에서 path를 설

정할 때, 그 path를 NSURL형태로 바꾸어 addSkipBackupAttributeToItemAtURL 메서드에

넣어주면 해당 경로는 iCloud 백업을 사용하지 않게된다.


코드에서 보면 iOS5.0.1과 iOS5.1 두가지로 나위어져 있다.

2012년 4월 이전까지는 5.0.1에 관련된 사항만 넣어주면 해결이 되었지만, iOS5.1버전이 나오면서

조금 다른 방법이 추가 되었다. 그래서 두가지를 모두 사용할 수 있도록 코드가 작성되어있다.

참고로 xattr.h는 iOS5.0.1버전에 setxattr이라는 메서드를 사용하기 위해 호출되는 것이므로 5.0.1

이전 버전에 대한 처리를 하지 않을 경우에는 import하지 않아도 된다.




반응형