-1

I've inherited a Xamarin mobile app (focused on iOS). It's an internal app that's not published to the app store.

The app currently retrieves images from an API. While running iOS simulator, I can see that plist files are saved in the Documents/ directory and the images are stored in the Documents/Content directory. If those files are already there, the app doesn't connect to the API.

We no longer have access to the API. While we're in the process of rebuilding the API, I'd like to bundle the images and plist files with the application so that it is no longer dependent on the current API. I'm new to Xamarin and am not sure where to start with this.

UPDATE: FWIW, I'm on a mac, currently using JetBrains Rider IDE

webaholik
  • 1,619
  • 1
  • 19
  • 30
  • Some questions: **1)** Are those files **identical**, for different users of the app? **2)** *"We no longer have access to the API."* Does this mean you have to place those files into the folders they are in now, or can you change your code to access them from a different folder? – ToolmakerSteve Nov 29 '22 at 23:17
  • @ToolmakerSteve - **1)** yes **2)** Files could be placed elsewhere I suppose. I was hoping to change as little code as possible since the end goal is to recreate the existing API. The existing API is still up and running, but it's provided by a third-party that is going to shutdown the service. I only have access to the Xamarin codebase, not the codebase for the backend API. – webaholik Nov 29 '22 at 23:25

1 Answers1

0

Just add the files to the iOS project with build action of “content”. Then you should be able to read them using “file name” for the path

Note that bundled files are NOT writable

Jason
  • 86,222
  • 15
  • 131
  • 146
  • I don't need anything to be writable. Sounds straightforward, I'm using the JetBrains "Rider" IDE, I'll see what I need to do to get this to work. – webaholik Nov 29 '22 at 23:33
  • if you want to maintain the current folder structure your app uses, you can just copy the files from the bundle to the App folders you used previously. Add some code to the App startup using System.IO.File methods to copy the files – Jason Nov 29 '22 at 23:57
  • I would prefer to use the current folder structure. – webaholik Nov 30 '22 at 00:02
  • then just use `File.Copy` to copy them from the bundle to the current folder structure – Jason Nov 30 '22 at 00:13
  • Files total about 500MB, do you think there would be any issue using `File.Move`? – webaholik Nov 30 '22 at 00:17
  • you can't use Move because the app bundle signed and read-only. Not sure how 500 MB in bundled files will behave, if it's not in the App store it may not matter. I would try at least zipping them before adding them to the bundle. – Jason Nov 30 '22 at 01:18