29

I keep getting this error. I'm uploading via ftp to a server. It works fine and uploads completely while running in the simulator, but when I provision it on my iPhone, it says: Error Occurred. Upload failed: The operation couldn’t be completed. (Cocoa error 260.)

Any suggestions? I've been debugging and researching for hours on end and can't figure this out. I've tried cleaning targets, resetting device, resetting xcode.

One thing I narrowed down was:

NSError *attributesError = nil;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:self.filePath error:&attributesError];
if (attributesError) {
    [self failWithError:attributesError];
    return;
}

In the device attributesError is true, in the simulator it is false

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Chris
  • 7,270
  • 19
  • 66
  • 110
  • I thought the Apple documentation somewhere states that it is not a good habbit to check the error value. You should instead check if `fileAttributes` is nil. – v1Axvw Feb 04 '11 at 05:57

6 Answers6

61

I've tried cleaning targets, resetting device, resetting xcode.

Blind pounding on random targets is never a good debugging technique. At best, you'll fix the problem and not know how. At worst, you'll break something else.

Instead, find out what the problem is. For a “Cocoa error”, you'll want to look in FoundationErrors.h and CoreDataErrors.h (and AppKitErrors.h when not targeting Cocoa Touch). The former file gives the name for Cocoa error 260:

NSFileReadNoSuchFileError = 260,                        // Read error (no such file)

You're unable to get the attributes of that file because it doesn't exist (on your device).

You may want to edit your question to include the code that creates the path that you store into self.filePath.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • You did exactly what you said: you gave the answer and said how to solve other ones ourselves. :-p (By the way, I knew that I had to search that way, but I didn't think about it at the moment. I thought Googling was way faster — and it is.) Thanks! – Constantino Tsarouhas Jan 08 '12 at 18:46
  • 1
    Thanks for your nice moral ! "At best, you'll fix the problem and not know how. At worst, you'll break something else." Thanks really. – Arpit B Parekh Apr 18 '12 at 04:52
  • @Peter Hosey Very well explained! Very nice guidance! – Developer May 20 '15 at 08:45
  • If you've come here like me and your error code comparison isn't working, make sure you're comparing against `NSFileReadNoSuchFileError` and not `NSFileNoSuchFileError`. – commscheck Oct 02 '18 at 03:08
8

enter image description here

This solution resolves my problem i hope it will helps you out.

Burhan Ahmad
  • 728
  • 5
  • 13
5

I know Peter Hosey already has solved this question, but I want to add something. If you want to find your error quickly, you can use a simple command in the terminal to locate it's definition:

ief2s-iMac:Frameworks ief2$ cd /System/Library/Frameworks
ief2s-iMac:Frameworks ief2$ grep '260' $(find . -name "*Errors.h" )
  • cd to your frameworks directory
  • grep all the files ending with 'Errors.h' for the error code:

Change the '260' with the error code you want. The above command returns the following:

ief2s-iMac:Frameworks ief2$ grep '260' $(find . -name "*Errors.h" )
./CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h:  midiDupIDErr                  = -260, /*duplicate client ID*/
./CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h:  kECONNREFUSEDErr              = -3260, /* Connection refused           */
./Foundation.framework/Versions/C/Headers/FoundationErrors.h:    NSFileReadNoSuchFileError = 260,                        // Read error (no such file)
ief2s-iMac:Frameworks ief2$ 

You could of course better specify it by doing a grep on 'Error = 260':

ief2s-iMac:Frameworks ief2$ grep 'Error = 260' `find . -name "*Errors.h"`
./Foundation.framework/Versions/C/Headers/FoundationErrors.h:    NSFileReadNoSuchFileError = 260,                        // Read error (no such file)
ief2s-iMac:Frameworks ief2$ 

I hope this can help you with your further development, ief2

v1Axvw
  • 3,054
  • 3
  • 26
  • 40
  • 2
    You should use `-w` in order to search for 260 as a “whole word”, not a substring of something else. You don't want matches for 2600, 1260, 260.35, etc. I also prefer to use -F (fixed string) when I don't specifically want to search for a regular expression. Finally, if you use zsh, you can do the search in one line: `grep -RFw 260 /System/Library/Frameworks/**/*Errors.h` – Peter Hosey Feb 03 '11 at 22:13
  • Good tips! I'm not really a heavy grep user, but those tips seam quite useful. Especially the `-w` flag. I was trying to use the '\W' special character from the perl syntax, but that wasn't working. And unfortunally I'm using bash, so a `find` command seamed the best option to me. – v1Axvw Feb 04 '11 at 05:51
  • For some reason, I keep hating using the Terminal or any other UNIX shell. :-p I just can't get working with it. So, my alternative route was to actually open that header file and search. – Constantino Tsarouhas Jan 08 '12 at 18:48
1
+(DataManager*)getSharedInstance{
if (!sharedInstance) {
    sharedInstance = [[super allocWithZone:NULL]init];
    [sharedInstance copyDatabaseIntoDocumentsDirectory];
}
return sharedInstance;

}

-(void)copyDatabaseIntoDocumentsDirectory{

// Set the documents directory path to the documentsDirectory property.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
self.documentsDirectory = [paths objectAtIndex:0];

// Keep the database filename.
self.databaseFilename = DATABASE_FILENAME;

// Check if the database file exists in the documents directory.
destinationPath = [self.documentsDirectory stringByAppendingPathComponent:self.databaseFilename];

if (![[NSFileManager defaultManager] fileExistsAtPath:destinationPath]) {
    // The database file does not exist in the documents directory, so copy it from the main bundle now.
    NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseFilename];
    NSError *error;
    [[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:destinationPath error:&error];

    // Check if any error occurred during copying and display it.
    if (error != nil) {
        NSLog(@"%@", [error localizedDescription]);
    }
}

}

Note : error 260 : meaning the file could not be found at the path you specified (once again create DB and then add your project).

Venkatesh G
  • 354
  • 1
  • 4
  • 10
1

In my case my 260 error was due to a folder in the path Being camelCase.

In the simulator it worked fine under OSX. However on an iOS Device the case became very important.

I.E. I was referencing a folder called ``@"/Data/somethings/"``` On disk this was /data/somethings/

You have to maintain a consistency of uppercase / lowercase for iOS. So I had to make sure it was always referred to as /data/somethings/

Danoli3
  • 3,203
  • 3
  • 24
  • 35
0

This error can be removed vey quickly. Please do not drag and drop the database file into the project. Go to "Add files" option and then import the file. I tried this and error was gone..