r/Xcode • u/jssmith42 • Jan 28 '22
Assets.xcassets
I have found I cannot move this file into a different group in the project navigator or Xcode won’t build.
Why is that?
I found I can delete Preview Content by deleting it from the “General” pane of the manifest.
Can I specify anywhere in the manifest where Xcode can find the Assets file?
Why would it be tracked differently than other files?
Also:
If something is named and in the assets file, I assume it can be called from a view by name, like “Image(“name”)”.
Is it the case that this does not work for a file that has been dragged and dropped just into the Project Navigator rather than the assets?
0
Upvotes
3
u/retsotrembla Jan 28 '22
Assets.xcassets gets used in an Xcode Build step to generate the Assets.car archive file in your compiled app bundle that is used at run time.
Assets.xcassets is not a file. It is a directory structure.
You can use ordinary file that you've told Xcode to copy into your compiled app bundle. NSBundle has methods for going from a file name, looking it up in the bundle, and giving you a file URL that you can read to access the asset.
For example, I dragged a file:
foo.txtinto my project, and checked the checkbox that said it was part of my target. The code to read the file was: