简体   繁体   中英

Multiple Targets in Xcode: “File not found”

I am having a single project file. Then I created another target for a "Lite" version. I changed the bundle ID and product name for each target and am able to continue working this way.

But when I added a new custom class to the project, I try to use the class in existing VC by #import "NewClass.h" but it only works on one target, on the Lite target, it says:

File not found

Why is this and how to solve it?

While adding any new file and if you are working on multiple targets and you want that file in both the targets then you need to check both the targets while adding file

Check screenshot

在此处输入图片说明

You need to add the file to both the Target, so it can be accessed.

Click on the file you have added and then go to the Utilities Area in the right and click on File Inspector . You will have section called 'Target Membership', please select the target from the list of Targets.

Alternatively approach : Select the Target in which you are getting error then got to Build Phases -> Compile Sources and make sure the file is present there.

If you forgot to add a target when you creating a file, you can add later by selecting the file in project navigator and then check/uncheck the target(s) in the File Inspector (on the right)

Screenshot

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