如何在 React Native 上解决"property with retain (or strong) attribute must be of object type"?



我正试图在iOS中构建一个使用Firebase的React Native应用程序,但我遇到了这个错误:

错误屏幕截图

error: property with 'retain (or strong)' attribute must be of object typeWhile building module 'FirebaseStorage'

这是一个错误日志:

In file included from /Users/xxxx/Documents/Grups/grups/node_modules/@react-native-firebase/messaging/ios/RNFBMessaging/RNFBMessagingSerializer.h:18:
/Users/xxxx/Documents/Grups/grups/ios/Pods/Headers/Public/Firebase/Firebase.h:50:13: fatal error: could not build module 'FirebaseFirestore'
#import <FirebaseFirestore/FirebaseFirestore.h>
~~~~~~~^
While building module 'FirebaseStorage' imported from /Users/xxxx/Documents/Grups/grups/ios/Pods/Headers/Public/Firebase/Firebase.h:78:
In file included from <module-includes>:2:
/Users/xxxx/Library/Developer/Xcode/DerivedData/grups-ekqodkfcidbeowgmbeplgbgpybif/Build/Products/Debug-iphonesimulator/FirebaseStorage/FirebaseStorage.framework/Headers/FirebaseStorage-Swift.h:315:1: error: property with 'retain (or strong)' attribute must be of object type

这是我的podfile:

$RNFirebaseAsStaticFramework = true
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false
target 'grups' do

use_frameworks! :linkage => :static
config = use_native_modules!
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
#:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#:flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'grupsTests' do
inherit! :complete
# Pods for testing
end
post_install do |installer|
react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end

这是包.json

{
"name": "grups",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "18.1.0",
"react-native": "0.70.3",
"@react-native-async-storage/async-storage": "^1.17.10",
"@react-native-firebase/app": "^15.7.0",
"@react-native-firebase/auth": "^15.7.0",
"@react-native-firebase/firestore": "^15.7.0",
"@react-native-firebase/messaging": "^15.7.1",
"@react-native-firebase/storage": "^15.7.0",
"@react-native-google-signin/google-signin": "^8.0.0",
"@react-native-picker/picker": "^2.4.6",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.0",
"@types/react-native": "^0.70.4",
"i18n-js": "^3.8.0",
"react-native-date-picker": "^4.2.5",
"react-native-image-crop-picker": "^0.38.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-screens": "^3.17.0",
"react-native-vector-icons": "^9.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "0.72.3",
"react-test-renderer": "18.1.0"
},
"jest": {
"preset": "react-native"
}
}

我该如何解决?

我在这里没有找到其他解决方案。

这个问题发生在我的项目中的firebase react native 15中,降级为react nativefirebase 14.11.0对我有效。

最新更新