Leopard: fileExtensionsFromType: deprecation breaks saving with extension

  • My problem seems to entangle Cocoa and Xcode, but I'm trying this list
    first.

    I am running Xcode 3.0 on Leopard.

    When I try to save my application's document, the document does not
    get the proper extension. An extensive diagnostic (below) appears in
    the debugger console. The document, including type, UTI, and
    extension, is declared properly in the Properties tab of the Target
    Info. (Or at least, properly as of Tiger, and to the full extent that
    window permits.)

    I also cannot open old documents that had the correct extension. (Yes,
    saving worked before, and I can't determine what went wrong.)

    My question, in brief, is: How do I get the behavior I believe I am
    specifying?

    — F

    The document class implements dataOfType:error: .

    Here is the doc-type list from my application's Info.plist file:

    ==============
        <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeExtensions</key>
                <array>
                    <string>myappfile</string>
                </array>
                <key>CFBundleTypeIconFile</key>
                <string></string>
                <key>CFBundleTypeName</key>
                <string>MyApp Data File</string>
                <key>CFBundleTypeOSTypes</key>
                <array>
                    <string>mypF</string>
                </array>
                <key>CFBundleTypeRole</key>
                <string>Editor</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string>org.manoverboard.myapp.file</string>
                </array>
                <key>NSDocumentClass</key>
                <string>MyDocument</string>
            </dict>
        </array>
    ==============

    When I try to save my application's document, the console fills with

    ==============
    -[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
    "org.manoverboard.myapp.file".
    ==============

    So I have "a UTI that's not actually declared anywhere?" I declare it
    as a document attribute in Info.plist, and had not thought it
    necessary to declare it elsewhere.

    My UTI string appears nowhere but in the document declaration in
    Info.plist. I don't send fileExtensionsFromType: .

    The message says I should declare my UTI in
    UTExportedTypeDeclarations. But Xcode does not provide a UI for
    creating or editing that list.

    I'm using this project as a teaching example. Please tell me I don't
    have to tell my pupils to hand-edit Info.plist.

    I am out of ideas.

    How can I avoid this diagnostic, and get the extension declared for
    this document type (and UTI)?
  • On Friday, November 09, 2007, at 12:49PM, "Fritz Anderson" <fritza...> wrote:

    > When I try to save my application's document, the document does not
    > get the proper extension. An extensive diagnostic (below) appears in
    > the debugger console. The document, including type, UTI, and
    > extension, is declared properly in the Properties tab of the Target
    > Info. (Or at least, properly as of Tiger, and to the full extent that
    > window permits.)
    >
    > I also cannot open old documents that had the correct extension. (Yes,
    > saving worked before, and I can't determine what went wrong.)
    >
    > My question, in brief, is: How do I get the behavior I believe I am
    > specifying?

    The easiest thing to do is delete LSItemContentTypes from your Info.plist.  Alternately, compiling against the 10.4 SDK should give you the 10.4 behavior.  For those of us who added LSItemContentTypes and tried to use UTIs in Tiger, the situation in NSDocument/NSDocumentController sucks; I finally just removed LSItemContentTypes.

    Personally I think the number of deprecated methods in NSDocument/NSDocumentController is out of control, since your open/save/export code paths change depending on OS, SDK, and existing overrides.

    [...]

    > The message says I should declare my UTI in
    > UTExportedTypeDeclarations. But Xcode does not provide a UI for
    > creating or editing that list.

    You have to hand-edit Info.plist to add it, as far as I know.

    --
    adam
  • On $BJ?@.(B 19/11/10, at 6:06, Adam R. Maxwell wrote:

    >
    > On Friday, November 09, 2007, at 12:49PM, "Fritz Anderson" <fritza...>
    >> wrote:
    >
    >> When I try to save my application's document, the document does not
    >> get the proper extension. An extensive diagnostic (below) appears in
    >> the debugger console. The document, including type, UTI, and
    >> extension, is declared properly in the Properties tab of the Target
    >> Info. (Or at least, properly as of Tiger, and to the full extent that
    >> window permits.)
    >>
    >> I also cannot open old documents that had the correct extension.
    >> (Yes,
    >> saving worked before, and I can't determine what went wrong.)
    >>
    >> My question, in brief, is: How do I get the behavior I believe I am
    >> specifying?
    >
    > The easiest thing to do is delete LSItemContentTypes from your
    > Info.plist.  Alternately, compiling against the 10.4 SDK should give
    > you the 10.4 behavior.  For those of us who added LSItemContentTypes
    > and tried to use UTIs in Tiger, the situation in NSDocument/
    > NSDocumentController sucks; I finally just removed LSItemContentTypes.
    >
    > Personally I think the number of deprecated methods in NSDocument/
    > NSDocumentController is out of control, since your open/save/export
    > code paths change depending on OS, SDK, and existing overrides.
    >
    > [...]
    >
    >> The message says I should declare my UTI in
    >> UTExportedTypeDeclarations. But Xcode does not provide a UI for
    >> creating or editing that list.
    >
    > You have to hand-edit Info.plist to add it, as far as I know.
    Well, I hand-edtited it and still had the same problem.
    I just dumped (deleted) the UTI and all worked fine.
    Where did you place UTExportedTypeDeclarations in the plist file btw?

    Andre

    >
    > --
    > adam
  • On Nov 9, 2007, at 7:55 PM, <listposter...> wrote:

    > On 平� 19/11/10, at 6:06, Adam R. Maxwell wrote:
    >
    >>
    >> On Friday, November 09, 2007, at 12:49PM, "Fritz Anderson" <fritza...>
    >>> wrote:
    >>
    >>> When I try to save my application's document, the document does not
    >>> get the proper extension. An extensive diagnostic (below) appears in
    >>> the debugger console. The document, including type, UTI, and
    >>> extension, is declared properly in the Properties tab of the Target
    >>> Info. (Or at least, properly as of Tiger, and to the full extent
    >>> that
    >>> window permits.)
    >>>
    >>> I also cannot open old documents that had the correct extension.
    >>> (Yes,
    >>> saving worked before, and I can't determine what went wrong.)
    >>>
    >>> My question, in brief, is: How do I get the behavior I believe I am
    >>> specifying?
    >>
    >> The easiest thing to do is delete LSItemContentTypes from your
    >> Info.plist.  Alternately, compiling against the 10.4 SDK should
    >> give you the 10.4 behavior.  For those of us who added
    >> LSItemContentTypes and tried to use UTIs in Tiger, the situation in
    >> NSDocument/NSDocumentController sucks; I finally just removed
    >> LSItemContentTypes.
    >>
    >> Personally I think the number of deprecated methods in NSDocument/
    >> NSDocumentController is out of control, since your open/save/export
    >> code paths change depending on OS, SDK, and existing overrides.

    ...and lest this grumpiness be misinterpreted, I prefer working with
    UTIs over other identifiers, and the changes to UTIs are great for
    10.5-only apps.  I'm just starting to wish there was a new NSDocument
    class instead of one with 20 deprecated methods that sometimes get used.

    >>> The message says I should declare my UTI in
    >>> UTExportedTypeDeclarations. But Xcode does not provide a UI for
    >>> creating or editing that list.
    >>
    >> You have to hand-edit Info.plist to add it, as far as I know.
    > Well, I hand-edtited it and still had the same problem.
    > I just dumped (deleted) the UTI and all worked fine.
    > Where did you place UTExportedTypeDeclarations in the plist file btw?

    At the end of the file, not that it matters in the dictionary :).  It
    looks like this:

    <key>UTExportedTypeDeclarations</key>
    <array>
    <dict>
      <key>UTTypeConformsTo</key>
      <array>
      <string>public.plain-text</string>
      </array>
      <key>UTTypeDescription</key>
      <string>BibTeX Database</string>
      <key>UTTypeIconFile</key>
      <string>bibDocIcon.icns</string>
      <key>UTTypeIdentifier</key>
      <string>net.sourceforge.bibdesk.bib</string>
      <key>UTTypeTagSpecification</key>
      <dict>
      <key>public.filename-extension</key>
      <array>
        <string>bib</string>
      </array>
      </dict>
    </dict>
    <dict>
    <!-- another type here... -->
    </dict>
    </array
  • On $BJ?@.(B 19/11/10, at 13:33, Adam R. Maxwell wrote:

    >
    > On Nov 9, 2007, at 7:55 PM, <listposter...> wrote:
    >
    >> On $BJ?@.(B 19/11/10, at 6:06, Adam R. Maxwell wrote:
    >>
    >>>
    >>> On Friday, November 09, 2007, at 12:49PM, "Fritz Anderson" <fritza...>
    >>>> wrote:
    >>>
    >>>> When I try to save my application's document, the document does not
    >>>> get the proper extension. An extensive diagnostic (below) appears
    >>>> in
    >>>> the debugger console. The document, including type, UTI, and
    >>>> extension, is declared properly in the Properties tab of the Target
    >>>> Info. (Or at least, properly as of Tiger, and to the full extent
    >>>> that
    >>>> window permits.)
    >>>>
    >>>> I also cannot open old documents that had the correct extension.
    >>>> (Yes,
    >>>> saving worked before, and I can't determine what went wrong.)
    >>>>
    >>>> My question, in brief, is: How do I get the behavior I believe I am
    >>>> specifying?
    >>>
    >>> The easiest thing to do is delete LSItemContentTypes from your
    >>> Info.plist.  Alternately, compiling against the 10.4 SDK should
    >>> give you the 10.4 behavior.  For those of us who added
    >>> LSItemContentTypes and tried to use UTIs in Tiger, the situation
    >>> in NSDocument/NSDocumentController sucks; I finally just removed
    >>> LSItemContentTypes.
    >>>
    >>> Personally I think the number of deprecated methods in NSDocument/
    >>> NSDocumentController is out of control, since your open/save/
    >>> export code paths change depending on OS, SDK, and existing
    >>> overrides.
    >
    > ...and lest this grumpiness be misinterpreted, I prefer working with
    > UTIs over other identifiers, and the changes to UTIs are great for
    > 10.5-only apps.  I'm just starting to wish there was a new
    > NSDocument class instead of one with 20 deprecated methods that
    > sometimes get used.
    >
    >
    >>>> The message says I should declare my UTI in
    >>>> UTExportedTypeDeclarations. But Xcode does not provide a UI for
    >>>> creating or editing that list.
    >>>
    >>> You have to hand-edit Info.plist to add it, as far as I know.
    >> Well, I hand-edtited it and still had the same problem.
    >> I just dumped (deleted) the UTI and all worked fine.
    >> Where did you place UTExportedTypeDeclarations in the plist file btw?
    >
    > At the end of the file, not that it matters in the dictionary :).
    > It looks like this:
    >
    > <key>UTExportedTypeDeclarations</key>
    > <array>
    > <dict>
    > <key>UTTypeConformsTo</key>
    > <array>
    > <string>public.plain-text</string>
    > </array>
    > <key>UTTypeDescription</key>
    > <string>BibTeX Database</string>
    > <key>UTTypeIconFile</key>
    > <string>bibDocIcon.icns</string>
    > <key>UTTypeIdentifier</key>
    > <string>net.sourceforge.bibdesk.bib</string>
    > <key>UTTypeTagSpecification</key>
    > <dict>
    > <key>public.filename-extension</key>
    > <array>
    > <string>bib</string>
    > </array>
    > </dict>
    > </dict>
    > <dict>
    > <!-- another type here... -->
    > </dict>
    > </array>

    I see, thanks!

    Andre
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today