Thursday, October 13, 2016

How do I prevent files from being backed up to iCloud and iTunes from my iOS app using Swift or ObjectiveC



Objective C:

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]);
   
    NSError *error = nil;
    BOOL success = [URL setResourceValue:[NSNumber numberWithBool: YES]
                                  forKey: NSURLIsExcludedFromBackupKey error: &error];
    if(!success){
        NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
    return success;
}

Swift 3.0:

    func addSkipBackupAttributeToItemAtURL(filePath:String) -> Bool
       
    {
       let URL:NSURL = NSURL.fileURL(withPath: filePath) as NSURL
        assert(FileManager.default.fileExists(atPath: filePath), "File \(filePath) does not exist")
        var success: Bool
       
        do {
            try URL.setResourceValue(true, forKey:URLResourceKey.isExcludedFromBackupKey)
            success = true
        } catch let error as NSError {
           success = false
          print("Error excluding \(URL.lastPathComponent) from backup \(error)");
       }
        return success
    }

Sunday, October 9, 2016

Xcode 8 iOS Simulator Activity Logging Tracing


Xcode 8 iOS application run on simulator we see lots of debugging messages, which are call Activity tracing.
Now we are learning, how to Activity logging tracing enable and disable:


Editor Scheme
















argument setting















Now are add environment add (+):
name:OS_ACTIVITY_MODE
value:disable
activity mode set










Now have a look your simulator debugging section, system logging is not showing, If want to deactivate this feature just uncheck, not to remove OS_ACTIVITY_MODE.