Issues with XCTest

Hi there, I'm unable to get my tests to work.

I'm new to swift programming, but I have been following a lot of resources trying to get this to work. Classes declared on my main module are not visible to the tests module.

I tried several things:

Settings -> Enable Testability on the build settings

Settings -> Defines Modules : Yes

None would work

trying to @testable import MyApp does not work

The only way I found to get this to work on xcode was to click on the class and set it to have multiple targets (there has to be an easier way)

What am I missing here? Apologies for the very basic question, but those seems to be the hardest to find an answer


Thank you


Hello, Viniciusccarvalho.

This may happen for different reasons. You may check that your application target is in `Target Dependencies` of your test target. If not, try to add it and see it it resolves your problem. If that does not help in your case, can you please share your project in our issue tracker for us to help you investigate the problem.

Please note that if your project is generated from Swift Package Manager file, all changes to the .xcodeproj could be overwritten by SwiftPM.

I have created an issue for your particular case 

Thanks, I'm really new to Swift environment (come from a long time java and recently kotlin dev experience) so I'm still trying to find how everything works.

as for SPM, yes, everytime I run swift package resolve (when changing deps) I noticed I have to open xcode and add the swift files back to the target.


Where do I find the `Target Dependencies` on appcode? Is it under Project Settings? That one BTW could benefit from a contextual search (just like the one we have on the preferences of the IDE)



Vinicius, thanks.

As far as I understand your project is Swift PM based. Can you please share your project in the issue i've linked in my previous message? Most probably your manifest file lacks some dependencies between your test and application targets.

It is currently not possible to modify target dependencies right in AppCode, you may use Xcode for now. You can also track the issue for this functionality here:


Sorry for the delay, this is a personal pet project of mine to start learning about swift, so I have limited time on it.

Project is here:

At very least you could see the SPM file there.