No way to use npm package if it uses Native lib supported in iOS but not tvOS
See original GitHub issueVersion: "react-native": "npm:react-native-tvos@0.60.4-6",
When I want to use some library that is supported by iOS but not tvOS, for example react-native-webview, I am unable to build tvOS anymore.
Steps To Reproduce
yarn add react-native-webviewcd ios && pod install
Expected: pod installs for iOS but not for tvOS
Actual pod install attempts to install for tvOS and throws fatal error, blocker
[!] The platform of the target `MyApp-tvOS` (tvOS 9.2) is not compatible with `react-native-webview (7.2.5)`, which does not support `tvos`.
error Command failed with exit code 1.
Attempted workarounds:
- tried editing the
.podspecfrom the library to support the tvOS target:s.platforms = { :ios => "9.0" }-->s.platforms = { :ios => "9.0", :tvos => "9.2" }
this allowed me to install the pod. but then i encountered fatal errors, because this lib uses webkit and webkit/webviews is not supported by tvOS
Desired solution:
Is there a way to change the Podfile so that the tvOS target section can “exclude” an autolinked pod form node_modules?
If we can’t do this, then we would be forced to only use libraries which are supported by both iOS and tvOS, which is not great.
Snapshot of my Podfile
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'MyApp' do
platform :ios, '9.0'
# Pods for MyApp
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
use_native_modules!
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'MyApp-tvOS' do
platform :tvos, '9.2'
# Pods for MyApp-tvOS
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
use_native_modules!
target 'MyApp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:16 (2 by maintainers)

Top Related StackOverflow Question
I think the problem is the
use_native_modules!line. That is going to try to automatically pick up any NPM dependencies that have native modules.If you take that out, and put in a
podline for the iOS target that explicitly pulls inreact-native-webviewpod, that should solve the issue.@octopicorn any update on this?