Post

Replies

Boosts

Views

Activity

Reply to iOS Development: Create file failed(return domain:NSCocoaErrorDomain,code:512)
@logicat We are running into exact same issue. I was able to obtain the device from my user with an installed copy of our app, however it's an iPad 2 running iOS 9, so sysdiagnose is unavailable as I believe. Console log shows nothing helpful except my error messages. Doing some investigation, I was able to check that underlying error of a [NSData writeToFile:options:error] call is non-existent. I have Firebase (no idea where it's trying to save the file) and CocoaLumberjack logging (trying to save file at Library/Caches) both failing to save the file. Playing with time profiler here are the results of trying to create a new log file for CocoaLumberjack (if it might be helpfull to someone): 04 s	 48.9% 0 s 							-[NSData(NSData) writeToFile:options:error:] 04 s	 48.9% 0 s 							 _NSWriteDataToFileWithExtendedAttributes 03 s	 48.8% 0 s 								_NSCreateTemporaryFile_Protected 03 s	 48.8% 1.00 ms 								 -[NSFileManager _URLForReplacingItemAtURL:error:] 00 ms	 32.0% 0 s 									__49-[NSFileManager _URLForReplacingItemAtURL:error:]_block_invoke 640.00 ms	 30.2% 640.00 ms 									 mkdir00 ms		1.7% 1.00 ms 									 -[NSURL(NSURL) fileSystemRepresentation] 00 ms		0.5% 0 s 										malloc_zone_malloc 00 ms		0.5% 0 s 										+[NSData(NSData) dataWithBytesNoCopy:length:] 10.00 ms		0.4% 1.00 ms 										CFURLGetFileSystemRepresentation00 ms		0.0% 0 s 										objc_object::rootAutorelease2() 00 ms		0.0% 0 s 										-[NSURL(NSURL) _cfurl] 00 ms		0.0% 1.00 ms 										NSAllocateCollectable 00 ms		0.0% 1.00 ms 									 objc_msgSend 00 ms		8.8% 1.00 ms 									-[NSString initWithFormat:] 90.00 ms		4.2% 2.00 ms 									+[NSURL(NSURL) fileURLWithPath:isDirectory:]00 ms		1.5% 2.00 ms 									-[NSString(NSPathUtilities) stringByAppendingPathComponent:] 00 ms		0.8% 0 s 									-[NSBundle localizedStringForKey:value:table:] 00 ms		0.5% 2.00 ms 									CFRelease 00 ms		0.1% 0 s 									NSTemporaryDirectory 00 ms		0.0% 2.00 ms 									objc_object::rootAutorelease2() 00 ms		0.0% 0 s 									-[NSURL getResourceValue:forKey:error:] 00 ms		0.0% 1.00 ms 									-[__NSCFString release] 00 ms		0.0% 1.00 ms 									-[__NSCFConstantString autorelease] 00 ms		0.0% 1.00 ms 									+[NSString allocWithZone:] 00 ms		0.0% 1.00 ms 									_Block_object_dispose 00 ms		0.0% 1.00 ms 									-[NSObject autorelease] 00 ms		0.0% 1.00 ms 									+[NSObject alloc] 00 ms		0.0% 1.00 ms 								lstat However with all that, I have no clue what causes the issue. Were you able to resolve it?
Sep ’20
Reply to iOS Development: Create file failed(return domain:NSCocoaErrorDomain,code:512)
If someone still interested in the solution. We had an exact same problem as TS. During investigation it turned out our /tmp folder was filled up with empty folders, in the form of "(A Document Being Saved by $APPNAME)", caused by 3rd party framework (couchbase-lite to be exact), since it was using NSItemReplacementDirectory to create temporary directory, but never removing it. Once the number of those directories gets to 1000, the OS won't let you create any other directory with NSItemReplacementDirectory or any other file with NSDataWritingAtomic. So the solution for us was cleaning those directories. I'm almost certainly sure all of those problems lie in the field of OS limits, so I'd check total number of files on disk (by downloading container for example) or number of open files in your app. I'd love that Cocoa would give some form of defined error for this, but for now we have to deal with what we have.
Sep ’20