The problem I'm encountering, and absolutely not understanding, is why can my Swift code not access an bridged C-style struct import from objective-c when a NSString
pointer is contained, whereas the struct is visible when then NSString
is replaced with a char *
.
For example, when I've got the following defined in my Foo.h
file:
typedef struct {
NSString* value;
SomeEnum unit;
} SomeMeasurement;
I get an error of Value of Type ... has no member Measurement
(from the parental class
) at compile time.
Whereas when my struct is the following:
typedef struct {
char* value;
SomeEnum unit;
} SomeMeasurement;
Things compile as expected (even if char
unusable for my current needs).
The fact that that small change allows for this struct to be "seen" by Swift is totally perplexing me, since it means it's (probably) not an issue with a file in bridging header or something of that sort.
Also, if I replace NSString
with NSMutableData
, the problem persists, and the struct cannot be seen.
import Foundation
? – DepartmentFoo.h
and in my destinationBar.swift
– Cavil@available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) public struct Measurement<UnitType>
– DepartmentNSString* value
inside C struct. Structs in Swift are handled differently and are not compatible as is. The documentation talks only about similar syntax, not about about generated converting C structs to swift structs. – Departmenttypedef
visible from swift and the other one isn't". – Cavil