How to embed a framework into my iOS extension?

I’m trying to create an extension that makes use of a framework from https://github.com/aws-amplify/aws-sdk-ios

I added the framework (ie. AWSCore) to lib/ios so the directory structure looks like this: lib/ios/AWSCore.framework

Observations
I’ve built an IPA with and without the framework and the IPA file size is always the same (it’s as if the framework isn’t being included?)

When I run my iOS app on my iPhone it immediately crashes. The crash report indicates to me that my framework didn’t get included (and thus needs to be embedded?). Maybe there is something particular about AWS’ frameworks?

{"code":1,"flags":518,"namespace":"DYLD","indicator":"Library missing","details":["(terminated at launch; ignore backtrace)"],"reasons":["Library not loaded: @rpath\/AWSCore.framework\/AWSCore","Referenced from: \/private\/var\/containers\/Bundle\/Application\/7E83B650-311D-4CCF-8906-9199166F9917\/extension-cognito.app\/extensioncognito","Reason: tried: '\/System\/Library\/Frameworks\/AWSCore.framework\/AWSCore' (no such file)"]},

Thanks for your time.

1 Like

Are you using the correct architecture of the framework? arm64

Ah, could be that AWS framework is built as a shared library. I think Defold supports static libraries only.
You can try recompiling the framework as a static library or maybe there is a way to load the dynamically linked version from within ObjC before using it, I don’t know.

2 Likes

Add the framework to the res/ios folder of your extension. That should copy it into the app bundle.

3 Likes

Yes! Thank you. This solved it.

Directory structure looks like this now:

lib/ios/AWSCore.framework
res/ios/Frameworks/AWSCore.framework

I also had to add the rpath in my ext.manifest

name: CognitoExt
platforms:
    arm64-ios:
        context:
            linkFlags:  ['-ObjC', '-Wl,-rpath,@executable_path/Frameworks']