Skip to main content

Unit Testing a Project with Spaces in Its Name

·1 min

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.