4

I'm trying to define a GPX document type so that I can open gpx file types from other applications. I've followed Apple's Technical Q&A on this topic.

I've also tried solutions that I found that edited the plist file directly. None of them have worked. I still don't see my application in the "Open In" menu when I try to open a gpx file. I'm pretty sure I'm missing something here. I just don't have any idea what it is. Please help.

    <key>UTImportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.xml</string>
        </array>
        <key>UTTypeDescription</key>
        <string>GPS Exchange Format (GPX)</string>
        <key>UTTypeIdentifier</key>
        <string>com.topografix.gpx</string>
        <key>UTTypeReferenceURL</key>
        <string>http://www.topografix.com/GPX/1/1</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <array>
                <string>gpx</string>
            </array>
            <key>public.mime-type</key>
            <string>application/gpx+xml</string>
        </dict>
    </dict>
</array>
flightsimmer668
  • 41
  • 1
  • 10

2 Answers2

10

Make sure you define the UTI for GPX in your plist since it is not defined as part of the default iOS UTIs. You can do this by adding the GPX UTI to your target.

  1. Select your Project file
  2. select your target
  3. select "Info"
  4. expand "Import UTIs
  5. Click the + icon
  6. Add the GPX UTI info

You can also edit the plist directly if you want.

Here is what it should look like: enter image description here

In the plist it will look like this:

<key>UTImportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeIdentifier</key>
            <string>com.topografix.gpx</string>
            <key>UTTypeReferenceURL</key>
            <string>http://www.topografix.com/GPX/1/1</string>
            <key>UTTypeDescription</key>
            <string>GPS Exchange Format (GPX)</string>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.xml</string>
            </array>
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>gpx</string>
                </array>
                <key>public.mime-type</key>
                <string>application/gpx+xml</string>
            </dict>
        </dict>   
    </array>

Good info on this blog as well...

UPDATE

I assume you already have the document type defined as well in the plist. It should match this:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array/>
            <key>CFBundleTypeName</key>
            <string>GPS Exchange Format (GPX)</string>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.topografix.gpx</string>
            </array>
        </dict>
    </array>
rmp
  • 3,503
  • 1
  • 17
  • 26
  • I've seen that link and I've done what you suggested before, but I tried again anyway just in case I missed something. My application still won't show up in the "Open in" list of apps. Is there something else I need to add to my code to make this work? – flightsimmer668 Jul 01 '15 at 16:29
  • This does work in several app I have worked on. Double check your plist settings and make sure it matches exactly with what is shown above. Post your plist code too. Also, how are you testing this? – rmp Jul 01 '15 at 16:34
  • I'm running it on my iPad and iPhone. – flightsimmer668 Jul 01 '15 at 16:36
  • I don't see anything that looks incorrect. I don't think the order matters. I have also updated my answer to include the Document Type code for your plist. I assume you already have this but just double check to make sure it matches. – rmp Jul 01 '15 at 17:19
  • Ah, there you go that fixed my problem. It is now showing up in the "Open in" dialog. It was the missing entries in the Document Type section. Maybe I missed it or the documentation doesn't mention that you need to define both of them. Thank you very much for your help – flightsimmer668 Jul 01 '15 at 17:49
0

Also implementing CFBundleDocumentTypes to plist allows your app to open when the air drop content conforms to your UTI.

     <key>CFBundleDocumentTypes</key>
     <array>
        <dict>
           <key>CFBundleTypeIconFiles</key>
           <array/>
           <key>CFBundleTypeName</key>
           <string>GPX File</string>
           <key>LSHandlerRank</key>
           <string>Default</string>
           <key>LSItemContentTypes</key>
           <array>
               <string>com.your-Bundle-Idenitifer.gpx</string>
           </array>
         </dict>
     </array>
Mitch
  • 576
  • 5
  • 11