Open defagos opened 9 months ago
Workshop 10/10/2023
We have tried to implement a RN 0.72.5 - Turbo Module for the Pillarbox library
https://github.com/SRGSSR/react-native-pillarbox
✅ It seems to work
❌ It does not work
It is possible to use Pillarbox for iOS in an React Native iOS project.
Here are the relevant steps to create a new project from scratch, add Pillarbox to it via SPM and display a native SwiftUI player view powered by Pillarbox:
Use npx create-expo-app@latest
to create a new project with Expo.
Run npx expo prebuild
to generate the native Apple and Android projects.
Open the generated Xcode workspace.
Update the minimum deployment target of the application to 16.0, the minimum version currently required by Pillarbox.
Add https://github.com/SRGSSR/pillarbox-apple.git as an SPM dependency and link the desired products (e.g. PillarboxPlayer
or PillarboxCoreBusiness
with the application target.
Add a Swift implementation file to implement a custom player layout using SwiftUI. Provide @objc
annotated APIs so that your Swift code can be called from Objective-C(++) code that React usually requires.
To be able to call your Swift code from Objective-C(++) code import the following headers in order:
#import <ExpoModulesCore-Swift.h>
#import "YourAppName-Swift.h"
Note that the YourAppName-Swift.h
header is automatically generated for your project to provide definitions for Swift code exposed to Objective-C(++). This file is managed entirely by Xcode.
Somehow use your APIs to display the player view in your app.
Have fun!
Associated sample code is available.
A PR has recently been merged into React Native main branch to support SPM depdencies in React plugins.
Despite our efforts we could not build / use pre-release versions of React Native to test this new feature but, according to the usual React Native delivery cycle, there is hope that SPM support should appear in version 0.75.0 or soon after.
Once SPM support has been delivered by React Native we will test whether Pillarbox is compatible as dependency. SPM support in CocoaPods / React Native namely seems to have some limitations, some of which possibly incompatible with Pillarbox (e.g. I suspect that binary dependencies Pillarbox has, most notably for 3rd party closed-source analytics SDKs, might be a problem). Stay tuned.
I saw the merge yesterday and wanted to give it try 😄 -> https://github.com/SRGSSR/react-native-pillarbox/pull/1 This PR has SPM working on React Native 0.74 by applying the changes from the official PR to react-native after installation.
You can use the example/
as before to test "our react-native-pillarbox library".
Pillarbox is already setup as SPM dependeny on iOS: https://github.com/SRGSSR/react-native-pillarbox/pull/1/files#diff-0af6797c52bd5c14d8b756faec4fff93fb1956b052a28f292ce3a8a4e116c1a2R43-R53
Great, thanks for the info. We tried your PR but we are sadly facing a few compilation issues, but I guess your setup is probably better than ours.
@leonchabbey So do you confirm that you can create a native plugin that depends on Pillarbox using SPM support recently added to React Native on main
?
@defagos I haven't gone far enough in the example to confirm at 100% that it works but I can say that it compiles properly with the Pillarbox Swift dependency.
I don't have the time right now to explore the whole Swift / objective-c++ bridge thing needed but I will try to find some time when I can. We have the Pillarbox Hackathon 2 coming up next Wednesday so maybe we continue this together that day? (We could also jump quickly in call and I help you with the compilation issues you are facing if needed)
As a Pillarbox developer I want to:
As a Play Suisse developer I want to:
Acceptance criteria