2

How do I open a file (it's an XML file) with the iOS app I'm developing. I want to test my: UIApplicationLaunchOptionsURLKey implementation. How do I do this? iOS Simulator doesn't come with Mail or anything so I'm clueless as to testing that kind of a function. Any ideas?

I did Document Types under Xcode's Target Properties bit so I'm pretty sure that's right:

<dict>
    <key>CFBundleTypeIconFiles</key>
    <array>
        <string>icon</string>
    </array>
    <key>CFBundleTypeName</key>
    <string>XML File</string>
    <key>LSItemContentTypes</key>
    <array>
        <string>public.XML</string>
    </array>
</dict>
Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
James Heald
  • 841
  • 1
  • 12
  • 33

3 Answers3

8

You simply have to drag and drop your file on the simulator. If your app registers for that file type, your app will open and handle it.

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
  • 1
    Given that I just spent 3 days messing around with webservers, iCloud Drive, emails and even 3rd party apps to try and do just this with no success, this answer is well worthy of it's upvote. Thank you good sir. – Jacob King May 10 '18 at 10:45
2

Use the sample application from Apple, you can include your file in this app and it will let you do an 'open in' where you can select your app.

cchana
  • 4,899
  • 3
  • 33
  • 43
Gary
  • 5,642
  • 1
  • 21
  • 41
1

You want something that looks like this:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>XML File</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.xml</string>
        </array>
    </dict>
</array>

This should be one entry in the Info.plist file.

rmaddy
  • 314,917
  • 42
  • 532
  • 579