Import Structure SDK in Swift Framework


#1

Hello,

I am working on using the Structure SDK in a Swift framework, but I am struggling to achieve the import. I’ve been using many methods, the latest being an aggregate target to automatically create a module map for the structure headers. I keep hitting these errors:

-“Structure framework requires the C++ runtime. See Structure SDK Reference.” …as is found in your Structure.h.
-Could not build Objective-C module ‘Structure’ …obviously, since its a C++ module?

Do you have any advice?

Thanks you


SDK 10.1+ integration problem in Swift framework
#2

Do you read this Guide to setting up a Swift project ?


#3

Hello @Adp,

Thank you for replying, I have been waiting for some long time now.

Yes, I have followed that link, and several other links describing the same. They unfortunately do not resolve my issue.

In our Xcode project, I we have a Swift Cocoa Touch Framework. In this framework, we want to call/reference the Structure SDK. Of the many ways I tried to achieve this (following the link you provide, and google searches), I keep running into the error :(.


#4

It’s take a time for me to compile my project with Structure SDK. I don’t remember all my steps)
I can look at your project If you have it on github. As I understand there is no any sensitive info because you can’t bulid it)


#5

Hello @Adp.

Here is a the project on GitHub:

The error I mentioned above happens in a project I cannot share. I can share this project in which I am also unable to reference the Structure SDK from a Swift SDK (Cocoa Touch Framework). I have tried several different iteration of creating a simple empty iOS Single View App Swift project, in which I follow the below two articles (which start with the instructions you shared above). For the second link, I stopped at adding the “STSensorControllerDelegate” to the VC, as I clearly see Structure reference from the native code works.

Articles:


Then I create a Swift SDK target of type Cocoa Touch Framework, and configure it per the first article. I used option 2 of this link to create a bridging header in the Swift SDK:

For the many attempts, I can never compile as I run into either of these error (for device or simulator), both having the below output.

Error 1:
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error 2:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Output:
Ld /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Products/Debug-iphoneos/TestSwiftSDK.framework/TestSwiftSDK normal arm64 (in target: TestSwiftSDK)
cd /Users/pauladdy/Documents/C4W/Development/6.GitHubStructureToSwiftSDKProto/3.StructureSwift/StructureSwift
export IPHONEOS_DEPLOYMENT_TARGET=12.1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -L/Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Products/Debug-iphoneos -F/Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Products/Debug-iphoneos -F/Users/pauladdy/Documents/C4W/Development/6.GitHubStructureToSwiftSDKProto/3.StructureSwift/StructureSwift/Frameworks -filelist /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Intermediates.noindex/StructureSwift.build/Debug-iphoneos/TestSwiftSDK.build/Objects-normal/arm64/TestSwiftSDK.LinkFileList -install_name @rpath/TestSwiftSDK.framework/TestSwiftSDK -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -miphoneos-version-min=12.1 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Intermediates.noindex/StructureSwift.build/Debug-iphoneos/TestSwiftSDK.build/Objects-normal/arm64/TestSwiftSDK_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Intermediates.noindex/StructureSwift.build/Debug-iphoneos/TestSwiftSDK.build/Objects-normal/arm64/TestSwiftSDK.swiftmodule -lc++ -framework ExternalAccessory -framework ImageIO -lz -framework Structure -framework Accelerate -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Intermediates.noindex/StructureSwift.build/Debug-iphoneos/TestSwiftSDK.build/Objects-normal/arm64/TestSwiftSDK_dependency_info.dat -o /Users/pauladdy/Library/Developer/Xcode/DerivedData/StructureSwift-aixfkjdgrvwavbgyjxhpblddcysz/Build/Products/Debug-iphoneos/TestSwiftSDK.framework/TestSwiftSDK

Undefined symbols for architecture arm64:
OBJC_METACLASS$_CMAccelerometerData”, referenced from:
l26175 in Structure
OBJC_CLASS$_CMGyroData”, referenced from:
l26174 in Structure
“_CMCopyDictionaryOfAttachments”, referenced from:
l10841 in Structure
l13464 in Structure
“_CMSetAttachments”, referenced from:
l13464 in Structure
OBJC_METACLASS$_CMGyroData”, referenced from:
l26173 in Structure
OBJC_METACLASS$_CMAttitude”, referenced from:
l26168 in Structure
OBJC_CLASS$_AVCaptureDevice”, referenced from:
objc-class-ref in Structure
“_kCMTimingInfoInvalid”, referenced from:
l11429 in Structure
l13465 in Structure
OBJC_CLASS$_CMMotionManager”, referenced from:
objc-class-ref in Structure
“_CMSampleBufferGetPresentationTimeStamp”, referenced from:
l13702 in Structure
OBJC_CLASS$_CMAttitude”, referenced from:
l26170 in Structure
“_CMVideoFormatDescriptionCreateForImageBuffer”, referenced from:
l5256 in Structure
l11429 in Structure
l13459 in Structure
l13460 in Structure
l13465 in Structure
l13472 in Structure
“_CMTimeCompare”, referenced from:
l12120 in Structure
“_CMTimeMake”, referenced from:
l5256 in Structure
l13472 in Structure
“_CMSampleBufferGetSampleTimingInfo”, referenced from:
l11429 in Structure
l13459 in Structure
l13460 in Structure
l13465 in Structure
OBJC_CLASS$_CMDeviceMotion”, referenced from:
l26171 in Structure
“_kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix”, referenced from:
l10858 in Structure
“_CMGetAttachment”, referenced from:
l7281 in Structure
l10858 in Structure
“_CMSampleBufferGetImageBuffer”, referenced from:
l7280 in Structure
l10695 in Structure
l10858 in Structure
l10940 in Structure
l10942 in Structure
l10943 in Structure
l10944 in Structure

“_CMTimeGetSeconds”, referenced from:
l5011 in Structure
l12120 in Structure
l13702 in Structure
OBJC_METACLASS$_CMDeviceMotion”, referenced from:
l26172 in Structure
“_CMSampleBufferCreateForImageBuffer”, referenced from:
l5256 in Structure
l11429 in Structure
l13459 in Structure
l13460 in Structure
l13465 in Structure
l13472 in Structure
OBJC_CLASS$_CMAccelerometerData”, referenced from:
l26176 in Structure
“_kCMTimeInvalid”, referenced from:
l5256 in Structure
l11296 in Structure
l13472 in Structure
“_CMVideoFormatDescriptionGetDimensions”, referenced from:
l12120 in Structure
“_AVMediaTypeVideo”, referenced from:
l5011 in Structure
l11296 in Structure
l12119 in Structure


#6

I removed all sensitive info from me own project and share it on github.
Check it https://github.com/Podlesnyy/StructureToSwiftSDK


#7

Hi @Adp,

The project you shared is different than mine. You have only one target, the main app.

I have 2 targets: main app, and the Cocoa Touch Framework in Swift. I am trying to reference Structure SDK from the Cocoa Touch Framework in Swift.

Do you understand what I mean?

Regards,


#8

@Adp,have you had time to test and see if you can reference the Structure SDK from a Swift Cocoa Touch Framework?