Unit Testing a Project with Spaces in Its Name

June 17th, 2019

Filed under: Xcode | Be the first to comment!

Suppose you have an Xcode project with spaces in the name.

My App

In your unit tests you want to import the module so you can access your app’s classes in your unit tests. If you import the app project with the spaces,

@testable import My App

You’ll get errors from the compiler.

How do you import the project name? Replace the spaces with underscores.

@testable import My_App

Now you can access your app’s classes in your tests.

Tags:


Leave a Reply

Your email address will not be published. Required fields are marked *