Can't load content for iOS at all anymore. Simple (new) test project fails. Looks for xnb files in strange location?

Hi everyone. I’m fairly experienced with Monogame and loading content, but I can’t seem to load content for iOS anymore. Even a simple test fails. I recently updated to OSX Catalina and Visual Studio 2019 though. Everything went fine, except for the content loading for iOS.

So I created a basic test, from the command line:

dotnet new mgios -o TestProject

I opened Content/Content.mgcb in the Pipeline Tool to add the texture “test.png”, then built the content, which results in the following:

#----------------------------- Global Properties ----------------------------#


#-------------------------------- References --------------------------------#

#---------------------------------- Content ---------------------------------#

#begin test.png

When I run the project, it creates the xnb file in the following location:

[project folder]/Content/bin/iOS/Content/test.xnb

I’m not sure why it creates that inside my project’s Content folder or whether it should do that or not. But it’s a newly created project and I didn’t modify anything.
It also creates:

[project folder]/bin/iOS/Content/ (folder is empty)
[project folder]/bin/iPhoneSimulator/Debug/ (folder contains compiled files)

The only line I add to the Draw method of the default Game1.cs is:

Texture2D texture = Content.Load<Texture2D>(“test”);

And that’s where it fails with a ContentLoadException immediately.
I tried to figure out where it tries to look for the xnb file and that seems to be:

Could not find a part of the path “/Users/MacUser/Library/Developer/CoreSimulator/Devices/0BA3132E-4CCA-4192-BEC2-2916AAC01B7E/data/Containers/Bundle/Application/7C5803F0-331B-4212-B7BD-13BA9F927477/”

I don’t know how the xnb files are supposed to get there. This probably has to be done behind the scenes but it clearly doesn’t, not even with a simple test project. I tried to copy the xnb file there by myself but the folder ID under the Application folder seems to change after each run, so no luck there. Manually placing the xnb file in the empty [project folder]/bin/iOS/Content/ folder before running the project also doesn’t seem to make a difference.

I also tried to run the project on an actual iPhone instead of the simulator, but results in the same error. The path is different though, probably of the device itself and also includes folders that seem to be a changing ID.

My iOS projects used to work, so this error is new to me. Does anyone have experience with this and know how I can get the xnb files for iOS in the right place automatically?

Thanks in advance!

I’m not sure if my problem was addressed before and therefore fixed in the new 3.8 prerelease.

I replaced the NuGet packages of MonoGame.Content.Builder (to MonoGame.Content.Builder.Task) and MonoGame.Framework.iOS to both prerelease versions of and this solved my iOS content loading error!

I might add that the generated folders and the location of the xnb file is the same as what I described in my issue above. Interesting. Something must have been changed under the hood. If someone likes to clarify that for me, I would be interested to hear that.

Yes, it was addressed in the develop branch / 3.8 prerelease, we had a bit of a “race condition” between building the content and packing the content :slight_smile:

PS. Feel free to install the 3.8 prerelease dotnet templates by doing:

dotnet new --install MonoGame.Templates.CSharp::

or you can even install the new Visual Studio for Mac templates from:

Ah, alright. I didn’t know it had been addressed. That makes sense. :slight_smile: I’m very happy that got fixed!

Thanks for showing how to install the 3.8 templates at the command line and the new Visual Studio. :smiley: That’s very convenient! :+1: