react-native-skia
react-native-skia copied to clipboard
SkData.h not found when using use_frameworks!
Adding use_frameworks! :linkage => :static to my podlike (required for RN Firebase) and I get a failed build on skia due to missing headers?
.../node_modules/@shopify/react-native-skia/cpp/skia/include/core/SkStream.h:11:10: 'include/core/SkData.h' file not found
Hi, @dpyeates! I'm not able to find any mention of use_frameworks! :linkage => :static in the Firebase installation examples - I'm seeing that they require enabling frameworks, but the only requirement for this should be use_frameworks!? Setting linkage to static globally like you suggest looks a bit suspect as there might be other libs not working with this switch.
@chrfalch agreed, I was using it temporarily as a work around waiting for a package update.
However, even just having use_frameworks! I still get the same error?
@shopify/react-native-skia/cpp/skia/include/core/SkStream.h:11:10: 'include/core/SkData.h' file not found
Has anyone been able to get RN Skia working in conjunction with Firebase and use_frameworks? Would you be able to share your podfile config? I've been at this a while now and have tried seemingly every option without any success.
Here is my current pod file:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
target 'RNApp' do
config = use_native_modules!
config = use_frameworks!
$FirebaseSDKVersion = '9.3.0'
$RNFirebaseAsStaticFramework = true
$RNGoogleMobileAdsAsStaticFramework = true
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true,
:fabric_enabled => false,
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
pod 'rnmapbox-maps', :path => '../node_modules/@rnmapbox/maps', :inhibit_warnings => false
pre_install do |installer|
$RNMapboxMaps.pre_install(installer)
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# use_flipper!()
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer) if defined?(__apply_Xcode_12_5_M1_post_install_workaround)
$RNMapboxMaps.post_install(installer)
end
end
@chrfalch could you try building using use_frameworks! and see if you get the same error please?
Well, I got it to work with the workaround below since we also use React Native Firebase and just got started with React Native Skia:
Found this ruby package called cocoapods-user-defined-build-types that "allows to specify how each pods are built" - as the package says.
So, in our case, we have:
Note: I've included my M1 specific workarounds but if you're on an intel, I'm assuming you won't need that.
plugin 'cocoapods-user-defined-build-types'
enable_user_defined_build_types!
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '11'
install! 'cocoapods', :deterministic_uuids => false
# Replace RNAppName with your app name
target 'RNAppName' do
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
# Here's the specific fix for React Native Firebase
pod "FirebaseCoreInternal", :build_type => :dynamic_framework
pod "FirebaseCore", :build_type => :dynamic_framework
use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
## All this is M1 mac specific
post_install do |installer|
installer.pods_project.targets.each do |target|
case target.name
when 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
else
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']= '12.0'
end
end
end
react_native_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
end
end
installer.aggregate_targets.first.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(inherited)', '$(SDKROOT)/usr/lib/swift']
end
end
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
@laudebugs Thanks for the suggestion! @dpyeates Could you test out if this works for you?
I'm trying :-) Having a few problems getting that gem to work. @laudebugs which version of CocoaPods are you using? I'm using 1.11.3 on an M1 Mac and I'm getting
[!] Your Podfile requires that the plugin cocoapods-user-defined-build-types be installed. Please install it and try installation again.
The gem installs OK after adding it to my Gemfile and doing a bundle install, but the pod install doesn't seem to be finding it. Still investigating - will update ASAP.
try running gem install cocoapods-user-defined-build-types in your ios folder?
I'm trying :-) Having a few problems getting that gem to work. @laudebugs which version of CocoaPods are you using? I'm using 1.11.3 on an M1 Mac and I'm getting
[!] Your Podfile requires that the plugincocoapods-user-defined-build-typesbe installed. Please install it and try installation again.The gem installs OK after adding it to my Gemfile and doing a bundle install, but the pod install doesn't seem to be finding it. Still investigating - will update ASAP.
Hmmm, no idea why that made a difference but it did. gem seems to work OK now. I had to add additional Firebase pod as I am using other Firebase libraries:
pod "FirebaseCoreInternal", :build_type => :dynamic_framework
pod "FirebaseCore", :build_type => :dynamic_framework
pod "FirebaseStorageInternal", :build_type => :dynamic_framework
pod "FirebaseAppCheckInterop", :build_type => :dynamic_framework
pod "FirebaseAuthInterop", :build_type => :dynamic_framework
pod "FirebaseCoreExtension", :build_type => :dynamic_framework
pod "FirebaseCrashlytics", :build_type => :dynamic_framework
However, I don't get to tell if Skia builds as Firebase modules fail to build before hand.

Hmmm, no idea why that made a difference but it did. gem seems to work OK now. I had to add additional Firebase pod as I am using other Firebase libraries:
pod "FirebaseCoreInternal", :build_type => :dynamic_framework pod "FirebaseCore", :build_type => :dynamic_framework pod "FirebaseStorageInternal", :build_type => :dynamic_framework pod "FirebaseAppCheckInterop", :build_type => :dynamic_framework pod "FirebaseAuthInterop", :build_type => :dynamic_framework pod "FirebaseCoreExtension", :build_type => :dynamic_framework pod "FirebaseCrashlytics", :build_type => :dynamic_frameworkHowever, I don't get to tell if Skia builds as Firebase modules fail to build before hand.
This happens even after cleaning your ios build folder and reinstalling pods?
Yes. It seems there is an issue with @react-native-firebase/storage which means this isn't working quite right. If I remove @react-native-firebase/storage from my build I got one other Skia related error related to react-native bridging paths which I resolved with another workaround in the post_install before I got a successful build.
Worth noting that I also got it working without using the cocoapods-user-defined-build-types gem, by setting RNFirebaseAsStaticFramework to true and setting modular_headers => true on each Firebase library that I required.
$RNFirebaseAsStaticFramework = true
pod "[FB pod name here]", :modular_headers => true
To summarise: RNSkia doesn't build with use_frameworks! at the moment. So any dependent library you use that does require frameworks (such as Firebase) you will need to at to your pod file and set modular_headers => true.
Here is my pod file - I have FirebaseStorage excluded until I get a fix here
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.4'
install! 'cocoapods', :deterministic_uuids => false
target 'fdeck' do
config = use_native_modules!
$FirebaseSDKVersion = '9.3.0'
$RNFirebaseAsStaticFramework = true
pod "FirebaseCore", :modular_headers => true
pod "FirebaseCoreInternal", :modular_headers => true
pod "FirebaseCoreExtension", :modular_headers => true
#pod 'FirebaseStorage', :modular_headers => true
#pod "FirebaseStorageInternal", :modular_headers => true
pod "FirebaseAppCheckInterop", :modular_headers => true
pod "FirebaseAuthInterop", :modular_headers => true
pod "FirebaseCrashlytics", :modular_headers => true
pod "GoogleUtilities", :modular_headers => true
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => true,
:fabric_enabled => false,
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
pod 'rnmapbox-maps', :path => '../node_modules/@rnmapbox/maps', :inhibit_warnings => false
pre_install do |installer|
$RNMapboxMaps.pre_install(installer)
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!()
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# This makes the iOS build much quieter.
# In particular libevent dependency, pulled in by react core / flipper items is ridiculously noisy
config.build_settings["GCC_WARN_INHIBIT_ALL_WARNINGS"] = "YES"
# Another workaround needed for static framework build
# Bitcode will not work with it, but that's okay, bitcode is deprecated
# https://github.com/facebook/react-native/pull/34030#issuecomment-1171197734
config.build_settings["ENABLE_BITCODE"] = "NO"
# Required for Apple Silicon Macs
config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
# Required to allow react-native-skia to build (hopefully can come out with next RN patch release)
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
end
end
# Apple Silicon builds require a library path tweak for Swift discovery or we get "symbol not found"
installer.aggregate_targets.first.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(inherited)', '$(SDKROOT)/usr/lib/swift']
end
end
__apply_Xcode_12_5_M1_post_install_workaround(installer)
$RNMapboxMaps.post_install(installer)
end
end
Unfortunately, these workarounds do not work for us because we need to use use_frameworks! :linkage => :static (https://github.com/idnow/de.idnow.ios/issues/119).
@chrfalch Are there any plans to make react-native-skia compatible with this build type? This is currently holding us back from integrating this library.
Hi @reichhartd - could you look into how this can be done and what we'd need to support? A PR would be very welcome.
Unfortunately, I have only rudimentary knowledge of cocoapods myself. I am currently reading up on the exact difference: Cocoa Touch Static Library vs. Cocoa Touch Framework
When I look at a similar issue with sentry-react-native (https://github.com/getsentry/sentry-react-native/pull/2369), the problem seems to be a reference to a private cocoa SDK class.
I also have a lot to do at the moment, so I can't promise to take over the issue.
Edit: This article explain the difference better: Basic overview of static and dynamic frameworks on iOS
It works in combination with use_frameworks! linkage: :static if you remove the folder prefix from the header imports of the Skia lib.
I don't know how reasonable these contribution and a pull request would be though. Since you would have to change a large part of the lib, I would say that is rather unrealistically.
I'm seeing the same as @dpyeates and @reichhartd
I'm also seeing this. Forced to run with use_frameworks! because of react-native-firebase (https://github.com/invertase/react-native-firebase/issues/6322).
How can we move this forward? What changes need to be made to support use_frameworks? react-native-firebase is perhaps one of the most popular libraries and it has a hard requirement on use_frameworks going forward due to the underlying upstream iOS firebase libraries. It would be a shame if nobody using firebase could use skia!
As a very temporary workaround you can roll back to react-native-firebase version 14.11.1 and remove use_frameworks, that's the last version of rnfirebase that can build without use_frameworks.
Would it be possible to create a small repo showing this issue (preferably as a Github repo) so that we can investigate?
The easiest way is to add the line use_frameworks! linkage: :static to the Podfile in the example project of this repository, and disable Flipper.
Otherwise, I created a repository here, for which I added the React Native TypeScript template. Only react-native-skia was installed, and just the line use_frameworks! linkage: :static was added to the Podfile.
The error appears when you try to launch the iOS app.
Same here!
Any updates on this issue?
I tried adding use_frameworks! linkage: :static to a new RN 0.70.0 project and ended up with an error about Flipper not being found - so it doesn't even work with Flipper?
I found some information about Firebase now supporting static frameworks here: https://firebase.google.com/docs/ios/link-firebase-static-dynamic
Flipper does not work with use_frameworks! as described in my comment above, and also in the Podfile of the template.
https://github.com/facebook/react-native/blob/0.70-stable/template/ios/Podfile#L20-L23
Correct - and I think the problem lies with Firebase, could you all try to follow the link and see if there are other options linking Firebase in later versions that doesn't affect linking of all other libraries in the App?
any update on this issue?
This won't work for us, as we also have react-native-idnow-videoident as a hard-dependency, which also requires use_frameworks!. I created an issue in their repository a couple months ago, if it is possible to set the link type freely. Unfortunately there is no answer yet.
I don't have a strong opinion which one I prefer, I think it should be up to the user which link type to use, because otherwise there will always be conflicting libraries.
The issue is still happening any fix?
Ahh! this dependency loop is quite frustrating. I removed Firebase entirely from my project (not only due to the above) and have been enjoying Skia since, however, I just integrated Appodeal, which requires use_frameworks and again this issue has resurfaced. It is not a Firebase issue. It is that Skia has missing headers if you define use_frameworks, or use_frameworks! :linkage => :static