问题
I've noticed that several apps, when an iP* is connected, has a "File Sharing" feature inside of iTunes. Example applications are CloudReaders, Stanza, etc. This interface lets users Add files to the app and Save files from the app to their computers. Right now I've got a HTTP server running inside the app which lets users add files to it via Wi-Fi, but I'd like to support the aforementioned method as well.
Thanks to Art Gillespie, I got this working. Recently, I renamed my project and ended up having to dig around a bit again to figure out how to re-enable this since it went away.
This is how you do it.
- In your plist, add a new key for
UIFileSharing
. It should be listed as something like "Application supports iTunes file sharing". - Build your code in "Release" mode.
- Go to the
build/Release-iphoneos/
folder of your project and drag the appname file (not the.dSYM
one) to iTunes. Click "Yes" if it asks about replacing. - Now if you click on your device and go to "Apps" and scroll down you should see your app listed in the "File Sharing"'s Apps list.
回答1:
You want to add the UIFileSharingEnabled
key to your app's Info.plist
Sharing Files With The User
回答2:
In the new Xcode, you can do this in the UI:
1. Select your project in top left
2. Select target in next column
3. Click on Info tab
4. In Custom iOS Target Properties, hover mouse over any row and click +
5. In popup, select "Application supports iTunes file sharing", then set Value to YES on right
6. Click Validate Settings at bottom to make sure all is good
回答3:
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.
To enable file sharing for your app, do the following:
Add the UIFileSharingEnabled key to your app’s Info.plist file, and set the value of the key to YES.
Put whatever files you want to share in your app’s Documents directory.
When the device is plugged into the user’s computer, iTunes displays a File Sharing section in the Apps tab of the selected device.
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.
来源:https://stackoverflow.com/questions/3241107/how-to-implement-itunes-built-in-app-file-sharing-feature