Aeveus Aeveus - 1 year ago 164
iOS Question

Accidentally removed xcassets file from XCode project

I wanted to remove a single folder from the image collection, however, I somehow managed to throw the entire xcassets file into the trash.

The normal 'Put back' method is not available, and simply dragging the deleted folder to XCode yields an error:

"Images.xcassets" couldn't be copied to "ProjectPear" because an item with the same name already exists.

To save the file, either provide a different name, or move aside or
delete the existing file, and try again.

I'm not sure where this collection is located within my XCode project, as the navigator doesn't appear to show anything, and the command-line isn't dropping any hints either. I'm afraid to mess around with the
file, as it might jumble up a lot more than just my image collection.

Dragging the files back to Finder from Trash was successful, however, the XCode navigator no longer recognises - or in this case, still doesn't recognise - the .xcassets file. I'm not sure whether to add something in the .pbxproj file.

Answer Source

I just did this myself and figured out how to quickly remedy the issue.

  1. Go to the project folder in the Finder. You should find that the folder Images.xcassets is still there.

  2. Move it to a separate location like to the Desktop or something. It still has all of the images and json files.

  3. Jump back to Xcode and create a new asset catalog for images.

    File > New > File... > Resource > Asset Catalog

    Name it Images.

  4. Quit Xcode and return to the Finder.

  5. Copy the folders from within your old Images.xcassets to the new Images.xcassets directory in your project.

  6. Launch Xcode and you're back in business!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download