0
votes

I'm converting some code from Objective C to Swift so I can get a handle on Swift.

Basically, in Objective C, I had a header file containing some global constants which were accessible in other Objective C classes.

I changed my .h file to be .swift and changed the constants to look like:

public let INVALID_INTEGER_VALUE = (-32768)
public let INVALID_LONGLONG_VALUE = (0x8000000000000000)
...

But when I try to access these in another Swift file, the compiler gives "Use of unresolved identifier..." I tried importing my .swift file, but that also didn't work (as far as I can tell, I shouldn't need to import any of my swift files as they are part of the same module).

Any thoughts?

1
Have you added the file to the target? Check the "target membership" check box in the file inspector.Martin R
The file was added to the target but from some reason it wasn't in the "Copy Sources" under "Build Phases". Adding it there fixed the problem!rayg

1 Answers

0
votes

You could also run into this if the file that is trying to use the constant has been added to another target (like the tests target) that the file containing the constants has not been added to.