-
Re: No document can be created in Swift
LCS Nov 24, 2015 11:07 PM (in response to Claude31)According to the Using Swift with Cocoa and Objective-C documentation, any non-alphanumeric characters in the module name are replaced with an underscore.
The name of the Xcode-generated header for Swift code, and the name of the Objective-C bridging header that Xcode creates for you, are generated from your product module name. By default, your product module name is the same as your product name. However, if your product name has any nonalphanumeric characters, such as a period (.), they are replaced with an underscore (_) in your product module name. If the name begins with a number, the first number is replaced with an underscore.
-
Re: No document can be created in Swift
Claude31 Nov 25, 2015 3:15 AM (in response to LCS)Thanks, I replaced dash ( - ) by underscore and it did improve: I can now create and save a document.
However, I get the following message (note: Lesson 20 Grades is the name of the application):
2015-11-25 12:01:57.714 Lesson 20 Grades[11143:4726300] -[NSDocumentController fileExtensionsFromType:] is deprecated, and does not work when passed a uniform type identifier (UTI). If the application didn't invoke it directly then the problem is probably that some other NSDocument or NSDocumentController method is getting confused by a UTI that's not actually declared anywhere. Maybe it should be declared in the UTExportedTypeDeclarations section of this app's Info.plist but is not. The alleged UTI in question is "com.mycompany.Lesson_20_Grades".
And the document that is created cannot be opened by the application. Is there a link with the above message ?
In my app info.plist, the Document OS Types is set to ???? Should I define it ?
PS: I looked at Lister example. In the info.plist, the Document Content Type UTIs is com.example.apple-samplecode.Lister (with a dash) ; how can it work ?
-
Re: No document can be created in Swift
eblu Mar 30, 2016 11:22 AM (in response to Claude31)I am having this exact problem now.
it makes no sense whatsoever. the deprecated method is not called by me, the clear, well written note has no information in it at all. My app, which used to work... stopped loading files suddenly (without recompiling btw, it just stopped working) and now It won't create files of the type I set in the project, or load any files of any kind.
this is a core data, document based, swift app. The offending code wasn't written by me. it's one of the free-of-charge features fo core data.
-
-
-
Re: No document can be created in Swift
eskimo Nov 25, 2015 1:24 AM (in response to Claude31)I have read the solution from Mark Szymczyk :
An alternative would be to use
@objc(Foo)
on your document class to have it exported to Objective-C with the nameFoo
.Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: No document can be created in Swift
Claude31 Nov 25, 2015 3:19 AM (in response to eskimo)Hi,
when I add @obj(Document) in NSDocument Class definition, I get the following execution error message
2015-11-25 12:17:41.169 Lesson 20 Grades[11222:4817041] The com.mycompany.Lesson_20_Grades type doesn't map to any NSDocumentClass.
2015-11-25 12:17:41.170 Lesson 20 Grades[11222:4817041] -[NSDocumentController openUntitledDocumentOfType:andDisplay:error:] failed during state restoration. Here's the error:
Error Domain=NSCocoaErrorDomain Code=256 "The file couldn’t be opened."
-
Re: No document can be created in Swift
eskimo Nov 26, 2015 1:11 AM (in response to Claude31)Two things:
Underscore is not valid in UTIs. You can find a list of valid characters in Uniform Type Identifiers Overview.
If, once you’ve fixed the above, you’re still having problems, please post your CFBundleDocumentTypes declaration.
Share and Enjoy
—
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
-
-
Re: No document can be created in Swift
eblu Feb 11, 2019 11:44 AM (in response to Claude31)I am still having this problem.
document based mac app this time.
worked just fine a month or 2 ago. Now it will not save out any files.
error message:
-[NSDocumentController fileExtensionsFromType:] is deprecated, and does not work when passed a uniform type identifier (UTI). If the application didn't invoke it directly then the problem is probably that some other NSDocument or NSDocumentController method is getting confused by a UTI that's not actually declared anywhere. Maybe it should be declared in the UTExportedTypeDeclarations section of this app's Info.plist but is not. The alleged UTI in question is "com.bkTools.concreteDoc".
couple notes about that:
1. the UTI is declared. It's declared as a document type and as an exported UTI type.
2. all of the code I HAVE written in regards to saving files executes without complaint. I never once call : fileExtensionsFromType. It's Apple's code doing that.
I am not happy that code that worked, now just doesn't work. I'd love it if it were some simple fix, but frankly the entire NSCoding system is falling apart, and there's nothing coming to replace it.