Jack Jafari
Jack Jafari

Reputation: 59

Asset Catalog doesn't open in visual studio

I have a xamarin project that it didn't have any problem in visual studio. I don't know why but now I couldn't open the asset catalog to add new images for iOS in visual studio. Can any body help me please?

Upvotes: 3

Views: 4964

Answers (6)

Ken
Ken

Reputation: 11

I had this issue. Am using Xamarin Forms in Windows. My fix:

  1. Click 'Show All Files' in top menu bar of Solution Explorer
  2. My 'Assets.xcassets' file was grayed out
  3. Right-click on that file and selected 'Include in project'
  4. Did a Clean, then a re-build, and all is well

Upvotes: 1

Jmie
Jmie

Reputation: 117

Asset catalogs are supported by Visual Studio but if you need reliable support, manage your asset catalogs in Xamarin Studio and don't edit with Visual Studio.

There are so many issues with Visual Studio (Xamarin Forum) If you want a stable solution open solution in Visual Studio for Mac (former Xamarin Studio) , edit asset catalogs, save and open solution in Visual Studio to work again.

Works for me over a year stable now, but I wish there was a better solution for this.

Upvotes: 0

ZZZ
ZZZ

Reputation: 2812

In my case, it was the ios.csproj file got a little bit corrupted though the app is still compiled and running well. Luckily I have the other iOS app with the editor opened normally. Through comparing, I had seen some redundant entries of json files and png file listed in csproj, as siblings of AppDelegate.cs in the same ItemGroup. Removing these redundant entries in csproj and restarting VS 2017 had resolved the problem and the Assets.xcassets editor is opened normally again.

Upvotes: 0

Gustavo Baiocchi Costa
Gustavo Baiocchi Costa

Reputation: 1448

I solved this problem by removing duplicates in my .csproj file.

By reading Peter's answer it helped me resolve this problem which I have been struggling for quite some time.

I had to create other assets files to hold new images since I couldn't reuse/open the assets files in Visual Studio any longer.

For instance, I had this as a duplicate:

<ImageAsset Include="Resources\Media.xcassets\LaunchImages.launchimage\Contents.json">
  <Visible>false</Visible>
</ImageAsset>

Everything is working as it should now.

Upvotes: 2

Peter
Peter

Reputation: 775

I have had issues with the Asset Catalogs in Visual Studio, the issue for me was two things that both caused the Asset Catalogs not to open:

1 Missing/wrong entry in the .csproj file:

In the Contents.json there was specified a file (i.e. [email protected]) however there was no entry in the .csproj file, this also includes cases where there was an entry in the csproj file but it was the wrong path:

Solution

Add the following (or edit the appropriate) line to the csproj file:

<ImageAsset Include="Resources\Assets.xcassets\image.png.imageset\[email protected]">
  <Visible>false</Visible>
</ImageAsset>

2 Slashes/Backslashes (seriously?!?)

In the csproj file for the iOS project, the ImageAsset tag for the image was with the wrong kind of slashes (which is probably why it sometimes works with Xamarin Studio on MacOS / Linux)

This will look like this when it does not work:

<ImageAsset Include="Resources/Assets.xcassets/image.png.imageset/[email protected]">
  <Visible>false</Visible>
</ImageAsset>

Solution

Reverse the slashes

<ImageAsset Include="Resources\Assets.xcassets\image.png.imageset\[email protected]">
  <Visible>false</Visible>
</ImageAsset>

Upvotes: 3

El Peter
El Peter

Reputation: 61

I had the same problem and my solution was:

  • Exclude Assets.xcassets folder from project.
  • Uncheck readonly mark from Assets.xcassets.
  • Restart visual studio

Upvotes: 6

Related Questions