Linking issues in Swift with SDK 0.10.0


Hi all,

Have hit an issue with linking some API calls from the new SDK in our project.



Both look to be ‘free’ or ‘helper functions’, living outside of the class definition in the header files.

Have tried everything I can think of with project settings to try and get the Swift version to build, but still can’t crack it.

I know it’s accessing the framework OK, as I can call other methods with no problems.

Imagine it’s to do with the bridging of Objective C to Swift.

Following is a link to two sample minimum projects, one in Objective C that works as expected, and another in Swift that fails to build. Open both projects, set a development team, and then try to build them. As you should be able to see, the Swift version fails with an error indicating an issue at the linker stage.

Undefined symbols for architecture arm64:

“_launchCalibratorAppOrGoToAppStore”, referenced from:

  LinkerTest_Swift.ViewController.viewDidAppear(Swift.Bool) -> () in ViewController.o

“_STCaptureSessionPropertiesSetColorCameraAutoExposureISOAndWhiteBalance”, referenced from:

  LinkerTest_Swift.ViewController.viewDidAppear(Swift.Bool) -> () in ViewController.o

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Tried with Structure SDK 0.10.0 Preview 3, and still showing the error.

Fails on hardware and simulator.

Trying the Objective C version on an iPad without calibration correctly throw up the prompt to set calibration, while the Swift version with the _captureSession?.launchCalibratorAppOrGoToAppStore() call (which does compile) doesn’t show the same dialog.

Given our app is 100% Swift, this is a total roadblock to get it updated to for new SDK, and to use STCaptureSession.


Andy Warwick

MKII Sensor Bounding Box Drift

@n6xej @agnomen I know that both of you have some experience with Swift and the Structure SDK. Would either of you have some insight on the above?


I believe the problem is the symbols are not being exported correctly.
I haven’t figured out the launchCalibratorAppOrGoToAppStore() yet, I just use the deprecated call, but below is equivalent to the missing helper functions:

// STCaptureSessionPropertiesSetColorCameraAutoExposureISOAndWhiteBalance();
let autoExposureISOAndWhiteBalance = [
kSTCaptureSessionPropertyIOSCameraWhiteBalanceModeKey: NSNumber(value:,
kSTCaptureSessionPropertyIOSCameraISOModeKey: NSNumber(value:,
kSTCaptureSessionPropertyIOSCameraExposureModeKey: NSNumber(value:

// STCaptureSessionPropertiesLockAllColorCameraPropertiesToCurrent();
let lockAllColorCamera = [
kSTCaptureSessionPropertyIOSCameraFocusModeKey: NSNumber(value: STCaptureSessionIOSCameraFocusMode.lockedToCurrent.rawValue),
kSTCaptureSessionPropertyIOSCameraISOModeKey: NSNumber(value: STCaptureSessionIOSCameraISOMode.lockedToCurrent.rawValue),
kSTCaptureSessionPropertyIOSCameraExposureModeKey: NSNumber(value: STCaptureSessionIOSCameraExposureMode.lockedToCurrent.rawValue),
kSTCaptureSessionPropertyIOSCameraWhiteBalanceModeKey: NSNumber(value: STCaptureSessionIOSCameraWhiteBalanceMode.lockedToCurrent.rawValue)

// STCaptureSessionPropertiesLockAllColorCameraPropertiesToCurrent(withTargetExposure: 0.5);
let withTargetExposure = [
kSTCaptureSessionPropertyIOSCameraExposureModeKey: NSNumber(value: STCaptureSessionIOSCameraExposureMode.lockedToCustom.rawValue),
kSTCaptureSessionPropertyIOSCameraISOModeKey: NSNumber(value: STCaptureSessionIOSCameraISOMode.lockedToCurrent.rawValue),
kSTCaptureSessionPropertyIOSCameraWhiteBalanceModeKey: NSNumber(value: STCaptureSessionIOSCameraWhiteBalanceMode.lockedToCurrent.rawValue),
kSTCaptureSessionPropertyIOSCameraExposureValueKey: NSNumber(value: 0.5),
kSTCaptureSessionPropertyIOSCameraFocusModeKey: NSNumber(value: STCaptureSessionIOSCameraFocusMode.lockedToCurrent.rawValue)


You have the same problem if you have no Objective-C++ files in your project. That is no file with .mm. So it is not just a Swift issue.

There are five functions I know of that have this issue, they are:

The last three on the list I identified the values being set by the helper function in my post above, so you can just set the capture session properties using those values. But if you really want to call the helper function (not a bad idea in case it changes) there is a way to do it from Swift but you need an Objective-C++ wrapper.

Here is a link to a Swift project I wrote that gets around the issue by implementing a couple of categories in Objective-C++. It works with Objective-C as well, but you could just change the file extension of your .m file that is calling those functions to .mm and that will take care of it as well.


Thanks @n6xej. Great stuff. Really appreciate it. Will see if I can get it working now.

Compile error with SDK 0.10 when using three InfraredSensor keys

Looks like Structure SDK 0.10.1 fixes at least some (all?) of these issues, and I was able to fix building our Swift app without using @n6xej’s fix after updating. (And I now know how the technique to band-aid similar issues in future, so thanks for that!)