Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8260193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:02:38+00:00 2026-06-08T03:02:38+00:00

I cannot seem to get the backup attribute parameter working from my code. No

  • 0

I cannot seem to get the backup attribute parameter working from my code. No matter what I seem to do, the method returns false with “Unknown Error -1”. I have tried different iterations of the skip-backup method, but below is the latest I’m using, based on another post I found:

- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];
    const char* attrName = "com.apple.MobileBackup";
    if (&NSURLIsExcludedFromBackupKey == nil) {
        // iOS 5.0.1 and lower
        u_int8_t attrValue = 1;
        int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
        return result == 0;
    } else {
        // First try and remove the extended attribute if it is present
        int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
        if (result != -1) {
            // The attribute exists, we need to remove it
            int removeResult = removexattr(filePath, attrName, 0);
            if (removeResult == 0) {
                NSLog(@"Removed extended attribute on file %@", URL);
            }
        }

        // Set the new key
        return [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:nil];
    }
}

My call to the method looks like the following (it always prints “not successful” during runtime):

if ([self addSkipBackupAttributeToItemAtURL:[NSURL fileURLWithPath:filePath]]) {
    NSLog(@"success!");
} else {
    NSLog(@"not successful");
}

And the filePath is the NSString path to the documents folder’s image. I logged an example of an image path as follows:

/var/mobile/Applications/B3583D06-38BC-45F0-A027-E79997F0EC60/Documents/myImage.png

In my app, it’s looping through all the (numerous) files I push out there, and it’s adding this attribute. It fails on each and every one of them. I need to be able to get this working, due to a hard requirement of offline capabilities for these dynamically-driven files. I don’t see that many others are having this issue, so that tells me I may be missing something obvious here, lol.

I found this post: Why was my application still rejected after excluding files from iCloud backup using this code?

And that looks promising as to what my issue could be, but there are not really any details about how to specifically resolve (it just recommends to use /Library instead of the docs folder?).

Thanks to anyone in advance who can help with this!
-Vincent

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:02:39+00:00Added an answer on June 8, 2026 at 3:02 am

    In order to fix this, I ended up just having to create a folder within the /Documents directory, and then I changed the app to point all the files to that sub-folder.

    So in my AppDelegate, before anything has loaded up-front, I added code like the following:

    NSString *tempDir = [documentsDirectory stringByAppendingString:@"/tempfiles"];
    [[NSFileManager defaultManager] createDirectoryAtPath:tempDir
                          withIntermediateDirectories:NO
                                           attributes:nil
                                                error:nil];
    NSURL *tempDirPathURL = [NSURL URLWithString:tempDir];
    if ([[MainControl controlSystem] addSkipBackupAttributeToItemAtURL:tempDirPathURL]) {
            NSLog(@"did add attribute!");
    } else {
        NSLog(@"adding attribute failed! :(");
    }
    

    And when I did that, it actually got into the ‘did add attribute’ log statement with no issues! I have no idea why this didn’t work at the individual file level, but at least this works, and it’s actually a better solution, since now I didn’t have to loop through hundreds of files to add the attribute, and I only had to add it in one place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Rails and I cannot seem to get past this error.
I cannot seem to get this date picker working at all. I know it
I cannot seem to get the quotes around this statement right. No matter what
I am new to using procedures and cannot seem to get mine working. I
I am trying to get this code to work but cannot seem to get
I have a this URL and I cannot seem to get the code below
I cannot seem to get a message from drupal_set_message when a user registers on
I cannot seem to get this working. I need South to do migrations for
I cannot seem to get hold of the parent varible from the child template,
Hey all, I cannot seem to get a simple ajax working between a php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.