如何为我的应用程序启用文件共享?

时间:2021-01-27 22:10:36

I have an image editing app where users can apply effects to photos. How could I enable it so that users can see my app in iTunes in the File Sharing tab and then just drag+drop photos to the app?

我有一个图像编辑应用程序,用户可以将效果应用到照片上。我怎么能让用户在文件共享标签的iTunes上看到我的应用程序,然后拖放照片到应用程序?

Some of the eBook readers like Stanza works like this and it would be a cool option. Maybe someone can point out a tutorial or resource that talks about how to enable and use this technique.

一些像Stanza这样的电子书阅读器是这样工作的,这将是一个很酷的选择。也许有人可以指出一个教程或资源,讨论如何启用和使用这种技术。

5 个解决方案

#1


220  

You just have to set UIFileSharingEnabled (Application Supports iTunes file sharing) key in the info plist of your app. Here's a link for the documentation. Scroll down to the file sharing support part.

你只需要设置UIFileSharingEnabled(应用程序支持iTunes文件共享)键在你的应用程序的info plist中,这里是文档的链接。向下滚动到文件共享支持部分。

In the past, it was also necessary to define CFBundleDisplayName (Bundle Display Name), if it wasn't already there. More details here.

在过去,如果还没有定义CFBundleDisplayName (Bundle DisplayName),那么也需要定义它。更多细节在这里。

#2


30  

According to apple doc:

根据苹果医生:

File-Sharing Support
File-sharing support lets apps make user data files available in iTunes 9.1 and later. An app that declares its support for file sharing makes the contents of its /Documents directory available to the user. The user can then move files in and out of this directory as needed from iTunes. This feature does not allow your app to share files with other apps on the same device; that behavior requires the pasteboard or a document interaction controller object.

文件共享支持文件共享支持让应用程序可以让用户数据文件在iTunes 9.1和更高版本中获得。一个声明支持文件共享的应用程序,使其/文档目录的内容对用户可用。然后用户可以根据需要从iTunes中移动文件。该功能不允许你的应用程序在同一设备上与其他应用共享文件;这种行为需要粘贴板或文档交互控制器对象。

To enable file sharing for your app, do the following:

为您的app启用文件共享,请执行以下操作:

  1. Add the UIFileSharingEnabled key to your app’s Info.plist file, and set the value of the key to YES. (The actual key name is "Application supports iTunes file sharing")

    添加UIFileSharingEnabled密钥到你的应用程序的信息。plist文件,并将键值设置为YES。(实际的关键名称是“应用程序支持iTunes文件共享”)

  2. Put whatever files you want to share in your app’s Documents directory.

    将你想要分享的文件放入你的应用程序的文档目录中。

  3. When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected device.

    当设备插入用户的电脑时,iTunes会在所选设备的应用程序选项卡中显示一个文件共享部分。

  4. The user can add files to this directory or move files to the desktop.

    用户可以将文件添加到这个目录或将文件移动到桌面。

Apps that support file sharing should be able to recognize when files have been added to the Documents directory and respond appropriately. For example, your app might make the contents of any new files available from its interface. You should never present the user with the list of files in this directory and ask them to decide what to do with those files.

支持文件共享的应用程序应该能够识别何时将文件添加到文档目录并做出适当的响应。例如,您的应用程序可能会使任何新文件的内容从其接口中获得。您不应该将该目录中的文件列表呈现给用户,并请他们决定如何处理这些文件。

For additional information about the UIFileSharingEnabled key, see Information Property List Key Reference.

有关UIFileSharingEnabled键的附加信息,请参见信息属性列表的关键引用。

#3


13  

New XCode 7 will only require 'UIFileSharingEnabled' key in Info.plist. 'CFBundleDisplayName' is not required any more.

新的XCode 7只需要在Info.plist中使用“UIFileSharingEnabled”键。“CFBundleDisplayName”不再需要了。

One more hint: do not only modify the Info.plist of the 'tests' target. The main app and the 'tests' have different Info.plist.

还有一个提示:不要只修改信息。“测试”目标的plist。主应用程序和“测试”有不同的Info.plist。

#4


2  

If you find by alphabet in plist, it should be "Application supports iTunes file sharing".

如果你在plist里找到字母表,它应该是“应用程序支持iTunes文件共享”。

#5


0  

In Xcode 8.3.3 add new row in .plist with true value

在Xcode 8.3.3中,在.plist中添加新行的true值。

Application supports iTunes file sharing

应用程序支持iTunes文件共享。

#1


220  

You just have to set UIFileSharingEnabled (Application Supports iTunes file sharing) key in the info plist of your app. Here's a link for the documentation. Scroll down to the file sharing support part.

你只需要设置UIFileSharingEnabled(应用程序支持iTunes文件共享)键在你的应用程序的info plist中,这里是文档的链接。向下滚动到文件共享支持部分。

In the past, it was also necessary to define CFBundleDisplayName (Bundle Display Name), if it wasn't already there. More details here.

在过去,如果还没有定义CFBundleDisplayName (Bundle DisplayName),那么也需要定义它。更多细节在这里。

#2


30  

According to apple doc:

根据苹果医生:

File-Sharing Support
File-sharing support lets apps make user data files available in iTunes 9.1 and later. An app that declares its support for file sharing makes the contents of its /Documents directory available to the user. The user can then move files in and out of this directory as needed from iTunes. This feature does not allow your app to share files with other apps on the same device; that behavior requires the pasteboard or a document interaction controller object.

文件共享支持文件共享支持让应用程序可以让用户数据文件在iTunes 9.1和更高版本中获得。一个声明支持文件共享的应用程序,使其/文档目录的内容对用户可用。然后用户可以根据需要从iTunes中移动文件。该功能不允许你的应用程序在同一设备上与其他应用共享文件;这种行为需要粘贴板或文档交互控制器对象。

To enable file sharing for your app, do the following:

为您的app启用文件共享,请执行以下操作:

  1. Add the UIFileSharingEnabled key to your app’s Info.plist file, and set the value of the key to YES. (The actual key name is "Application supports iTunes file sharing")

    添加UIFileSharingEnabled密钥到你的应用程序的信息。plist文件,并将键值设置为YES。(实际的关键名称是“应用程序支持iTunes文件共享”)

  2. Put whatever files you want to share in your app’s Documents directory.

    将你想要分享的文件放入你的应用程序的文档目录中。

  3. When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected device.

    当设备插入用户的电脑时,iTunes会在所选设备的应用程序选项卡中显示一个文件共享部分。

  4. The user can add files to this directory or move files to the desktop.

    用户可以将文件添加到这个目录或将文件移动到桌面。

Apps that support file sharing should be able to recognize when files have been added to the Documents directory and respond appropriately. For example, your app might make the contents of any new files available from its interface. You should never present the user with the list of files in this directory and ask them to decide what to do with those files.

支持文件共享的应用程序应该能够识别何时将文件添加到文档目录并做出适当的响应。例如,您的应用程序可能会使任何新文件的内容从其接口中获得。您不应该将该目录中的文件列表呈现给用户,并请他们决定如何处理这些文件。

For additional information about the UIFileSharingEnabled key, see Information Property List Key Reference.

有关UIFileSharingEnabled键的附加信息,请参见信息属性列表的关键引用。

#3


13  

New XCode 7 will only require 'UIFileSharingEnabled' key in Info.plist. 'CFBundleDisplayName' is not required any more.

新的XCode 7只需要在Info.plist中使用“UIFileSharingEnabled”键。“CFBundleDisplayName”不再需要了。

One more hint: do not only modify the Info.plist of the 'tests' target. The main app and the 'tests' have different Info.plist.

还有一个提示:不要只修改信息。“测试”目标的plist。主应用程序和“测试”有不同的Info.plist。

#4


2  

If you find by alphabet in plist, it should be "Application supports iTunes file sharing".

如果你在plist里找到字母表,它应该是“应用程序支持iTunes文件共享”。

#5


0  

In Xcode 8.3.3 add new row in .plist with true value

在Xcode 8.3.3中,在.plist中添加新行的true值。

Application supports iTunes file sharing

应用程序支持iTunes文件共享。