Imbru Imbru - 2 years ago 76
Swift Question

Cannot import Swift Code into Obj-C

I have the project CP Patient :

enter image description here

I have follow and authorize module :

enter image description here

When i import swift into my Obj-C i have this error :

enter image description here

What i have missed?

Answer Source

I believe the space in the Project name will get replaced by an underscore:

#import "CP_Patient-Swift.h"

I would recommend not to use Project/Framework names with spaces or special characters.

You might ask why this happens. The reason is simple. All your Swift code is automatically wrapped into a Swift module. The name of the module is the name of your project. However, there are rules for module naming. Normally modules are imported like this:

@import Foundation

So, obviously, we can't have spaces in module names. In general a module name has to be a valid identifier. All invalid characters (e.g. a number in the beginning) will be replaced with an underscore.

The Obj-C import does not import a file, it imports a Swift module.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download