How can I add file to project in Xcode 9?

aiur picture aiur · Jul 14, 2017 · Viewed 10.1k times · Source

I created a new project in xcode 9.

I want to add image file to project.

enter image description here

enter image description here

When I delete this file from desktop,

Image file appears in red?

enter image description here

But in project folder, I find this image file.

enter image description here

In Xcode 8 its working fine,

Any idea?

Answer

enigma picture enigma · Jul 15, 2017

It is an Xcode9-beta (9M136h) bug. I don't know if it has been resolved in beta3 or not. Copy items if needed copies the file to your project directory but still links to the original file.

What I do is, after dragging the file to my project, I select the folder icon (see red circle in the image below) from File Inspector and point to the copied file in the project directory.

image of the file inspector showing folder icon

@pesch's approach works too. First copy the image to your project folder and then drag it to Xcode.