How to add and use images as files instead of xcassets in XCode

Drag and drop the files into the project, set the targets and click finish. Use the images in the same way you use xcassets.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 08/31/2023 at 10:00
Last Updated on 08/31/2023 at 13:41
<p>Two flowers that represent Swift and XCode side by side. Beneath them sits the text “Image Files”.</p>

Drag and drop the files into the project, set the targets and click finish. Use the images in the same way you use xcassets.

SubscribeDownload open source project

Step One: Drag and Drop the Files

<p>A screenshot showing a finder window next to an XCode project. We have highlighted how you can drag and drop assets from the finder window into Xcode.</p>

Drag and drop the images into the project.

We recommend that you hold all images under a Images folder within Files.

Step Two: Add to Project

<p>This screenshot highlights the pop up that appears in Xcode when you drag and drop images into a project. We have highlighted how you need to check off "copy items if needed" and to ensure that you have checked off the targets that use the images.</p>

In the pop up that appears, make sure that Copy items if needed is checked off and that you have checked off the relevant targets for the project that will use these images.

Step Three: Use

<p>A screenshot of Xcode showing swift code that demonstrates that you can apply an image file the same way that you use xcassets - by using the name within a UIImage.</p>

Local image files work the same was as xcassets, and can be added to an image view by using the name of the file.

We recommend that you add the names to a struct that holds all the references. To learn how to do this or how to add an image to a view, follow the tutorials below.

How to use an image within a storyboard in XCodeHow to add a local image to a view in SwiftHow to add and structure local images in Swift

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe