简体   繁体   中英

Add images in project in new Xcode 9

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?

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.

在此输入图像描述

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.

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.

Check release notes of XCode 9.1:

Adding files to a project now adds them to the selected targets. (34551617)

https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM