Reputation: 39
In new Xcode 9 I want to add images in project. But If I add images and try to use it in code or in storyboard my images not showing in simulator. But in Xcode 8 all works fine. How to fix it?
Upvotes: 3
Views: 5936
Reputation: 3008
Note : This Problem does not Exist Anymore in newer XCode
If you have dragged image in your project, you must select Copy If Needed While adding any file into your project.
After Adding Image take a look at your image if it is available to target, I have face similar issue with other file types too. In xcode9 it was not selected by default even after selecting copy if needed.
Upvotes: 8
Reputation: 19134
Check release notes of XCode 9.1:
Adding files to a project now adds them to the selected targets. (34551617)
Upvotes: 0
Reputation: 1109
Yes - this is super annoying. With XCode 9, now in addition to dragging a new image into the XCode Project Navigator (the left-hand list of files), you now have to go into Targets for your project, go to "Build Phases" and manually add the image file to "Copy Bundle Resources" using the "+" button at the bottom of the list of files.
This is required for any object you used to have to just drag into the project, including third-party frameworks and bundles.
PS: in dragging the image into your project you don't have to have "Copy Item if needed" selected if the image file is already somewhere in your project folder or a subfolder thereof.
Upvotes: 2
Reputation: 41
If you have to handle multiple images, it is probably more convenient to copy the resources to your target app in the General Settings > Build Phases > Copy Bundle Resources Copy Bundle Resources
This does the same as checking Target Membership for the resource – but you can add multiple images to your target app at once.
Upvotes: 1