I am trying to get my app to import a csv file from the open in menu from other apps. I know that I need to register that in my info.plist, but I can't find much clear documentation that isn't either outdated or just not helpful.
Still new to iOS development so any help would be great! Thanks in advance!
Here is what I have so far in my info.plist. From what I gathered a URL Scheme is the best way to achieve this. I have no idea what to set these parameters to as my Xcode does not seem to want to show me any documentation for them.
CodePudding user response:
You do not want to use the URL Scheme setting for this. That defines URL schemes unique to your app for launching your app.
You need to enter details in the Document Types section of Info.plist to register the types of files that your app can open.
Here is an example to support CSV files:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Comma Separated Values</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.comma-separated-values-text</string>
</array>
</dict>
</array>
You will also want to define the CSV UTI in the Imported Type Identifiers section:
<key>UTImportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text </string>
</array>
<key>UTTypeDescription</key>
<string>Comma Separated Values</string>
<key>UTTypeIdentifier</key>
<string>public.comma-separated-values-text</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>csv</string>
</array>
</dict>
</dict>
</array>
Once both of those are in place you can build and run your app and then when you view a CSV file in the Files app (or a 3rd party app shares a CSV file using UIActivityViewController
), your app will appear in the list of options for sharing the file.
CodePudding user response:
To import a CSV file on ios: Make sure you have the CSV file you want to import on your iphone(e.g. in iCloud Drive,Dropbox,Google Drive,etc) Select the file and depending on the app chose open in, share or export,share sheet should open select wokabulary and make sure the languages are assigned correctly to the columns.