Multiple Targets in Xcode: "File not found"

2.9k Views Asked by At

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?

3

There are 3 best solutions below

2
On BEST ANSWER

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

enter image description here

1
On

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.

0
On

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