How can I embed the TwilioVideo iOS SDK (in Swift Package form) into an internal standalone framework which is then imported into my app target?

Viewed 28

I have added package dependencies into internal frameworks and then been able to embed the internal frameworks into my main app target and use those frameworks without any issue (e.g. Firebase).

Moreover, I have attempted to do the same with the TwilioVideo SDK - but they have extensive instructions and issues that need to be fixed with Run Script Phases, etc.

Below are Twilio's instructions as well as a link

https://www.twilio.com/docs/video/ios-getting-started#1-get-the-programmable-video-ios-sdk

Swift Package Manager

You can add Programmable Video for iOS by adding the https://github.com/twilio/twilio-video-ios repository as a Swift Package. In your Build Settings, you will also need to modify Other Linker Flags to include -ObjC.

As of the latest release of Xcode, there is a known issue with consuming binary frameworks distributed via Swift Package Manager. The current workaround to this issue is to add a Run Script Phase to the Build Phases of your Xcode project. This Run Script Phase should come after the Embed Frameworks build phase. This new Run Script Phase should contain the following code:

find "${CODESIGNING_FOLDER_PATH}" -name '*.framework' -print0 | while read -d $'\0' framework
do
    codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "${framework}"
done

I am able to successfully add the swift package into my internal framework and even build on the simulator... but when attempting to build on a real device (where code signing is needed) I am not able to build and launch the app. Right when it's about to launch, I get this error:

Library not loaded: '@rpath/TwilioVideo.framework/TwilioVideo'

I have tried adding the run script phase to both the framework and the app target, just the app target, just the framework, etc and I cannot seem to get this thing to work properly. Twilio is also very slow to respond and doesn't offer any documentation on how to implement their libraries as frameworks, like Firebase does...

If anyone can provide guidance on how to achieve this that would be so helpful.. thanks.

0 Answers
Related