0

I would like to use some static char arrays in Swift using the bridge header functionality. In my bridge header I've declared this variable:

static char test[] = {
    0x74, 0x65, 0x73, 0x74
};

and I'm using it in my app delegate (just testing right now) like this:

let string = withUnsafePointer(&test) {
    String.fromCString(UnsafePointer($0))!
}

But I'm getting a linker error because apparently the symbol _test is not defined.

Nicolò Ciraci
  • 678
  • 5
  • 23
  • Possible duplicate of http://stackoverflow.com/questions/28577147/not-allowing-to-use-constant-defined-in-objective-c-header-file-in-swift-class. – Martin R Jun 18 '15 at 12:49
  • Note also that `String.fromCString()` expects a NUL-terminated C string. – Martin R Jun 18 '15 at 12:50

0 Answers0