0

Background
I have a dictionary with more than 100 keys that I've stored in a property list that I can transfer/load/save to from one Xcode project to another.

Research
I've looked at several posts on StackOverflow but most of them seem to deal with loading a plist from the main bundle, copying it to the Documents directory and loading/saving it from there with no way of retrieving it to use in other projects.

TLDR
I want to be able to 'export' a plist created programmatically as a separate file I can use in other projects unrelated to the current one.

Update
Thanks to @NSNoob I've figured out that I can manually access the new plist from the Documents directory. Now the question is, how? Isn't iOS sandboxed without access to the filesystem unless it's jailbroken?

NSNoob
  • 5,320
  • 5
  • 35
  • 51
cyril
  • 2,644
  • 3
  • 29
  • 57
  • Is the said plist in your main project bundle? – NSNoob Aug 01 '16 at 08:48
  • @NSNoob yup the empty one is located in the main project bundle which my code copies into the documents directory and modifies it there with no changes to the former one (which is what I /don't/ want happening) – cyril Aug 01 '16 at 08:49
  • You cannot modify the original plist. It will remain the same. – NSNoob Aug 01 '16 at 08:51
  • 1
    You want to write that plist to your main bundle, that's not possible. – NSNoob Aug 01 '16 at 08:51
  • @NSNoob so there is no way of creating a property list that is exportable in Swift? – cyril Aug 01 '16 at 08:51
  • Not in Objective C either. You simply can't write to your main bundle. – NSNoob Aug 01 '16 at 08:53
  • You can export but not in the main bundle, you can write in the Document directory for example. – Raphaël Aug 01 '16 at 08:54
  • @NSNoob ah that's too bad. Is there any reason for that? – cyril Aug 01 '16 at 08:54
  • You are still unclear, now you are saying you want to export the plist instead of writing it to your main bundle. Why don't you just access the modified plist in documents directory and do what you want with it? Export it how? Writing to some directory? Sending it to a server? – NSNoob Aug 01 '16 at 08:54
  • @NSNoob I want to be able to obtain the modified .plist as a file that I can use in another Xcode project for example. A sort of output file I guess. – cyril Aug 01 '16 at 08:56
  • @cyril You can either manually pick up the saved plist from document directory and then import it in your other Xcode project. A better solution would be to maintain a server where you save the plist and use it between your different projects using Network. – NSNoob Aug 01 '16 at 08:58
  • @NSNoob that makes more sense - now the modified question is, how do I manually access the new plist in the document directory? – cyril Aug 01 '16 at 09:00
  • See my answer. Adding screenshots in a moment – NSNoob Aug 01 '16 at 09:06

1 Answers1

2

You can get Documents directory contents of your app like following:

  1. Connect your device to your mac
  2. Open your Xcode
  3. Click on Window and select Devices

enter image description here

  1. Click on your device
  2. Search for your app in installed apps list
  3. Click on your app
  4. Click on gear icon
  5. Click on Download Container.

enter image description here

  1. Right Click on Saved xcappdata file.
  2. Click on Show package contents.

enter image description here

That will open your documents directory and you will be able to find your modified plist there.

NSNoob
  • 5,320
  • 5
  • 35
  • 51