简体   繁体   中英

Cannot find JSON file while running an app on the Apple Watch

I'm currently developing an app for the Apple Watch which uses a JSON file to create the menu navigation. Everything works perfectly fine when I run it on simulator, but as soon as I run it on a device the app crashes. The exception says:

could not find file /private/var/mobile/Containers/Bundle/Application/some identifier/AppName.app/Plugins/com.companyname.AppName.watchkitextension.appex/Resources/Motorcontroller.json"

Motorcontroller.json is the JSON file I need and I put it in the Resources folder of my WatchKitExtension . I then call it with:

using (StreamReader sr = new StreamReader("MotorController.json")) 
{

}

Which only seems to work on the simulator. I'm probably missing something really simple here and allready tried to put the file in the WatchApp Project as well as the App Project for the iPhone.

The App is for WatchOS 1 and I am using Xamarin and therefore C# to program it.

I don't know why, but I recognised that the file ending started with a capital J. So the name was MotorController.Json not MotorController.json. It seems the simulator doesn't have a problem with it, but the Apple Watch does.

I hope nobody put to much effort in solving this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM