安装 Reanimated 2 后 iOS 构建崩溃。使用 React Native 0.71.2
我还在本地搭建了 Reanimated 游乐场,并且运行成功。 从命令行(即yarn start)运行iOS项目时,项目挂起并显示以下内容:
从 CLI 构建日志:
info Found Xcode workspace "GluApp.xcworkspace"
info Found booted iPhone 14, iPhone 14 Plus
info Launching iPhone 14
info Building (using "xcodebuild -workspace GluApp.xcworkspace -configuration Debug -scheme GluApp -destination id=87333F30-59BA-47D3-BC75-5401B963DECF")
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace GluApp.xcworkspace -configuration Debug -scheme GluApp -destination id=87333F30-59BA-47D3-BC75-5401B963DECF
User defaults from command line:
IDEPackageSupportUseBuiltinSCM = YES
Prepare packages
Computing target dependency graph and provisioning inputs
Create build description
Build description signature: a8a3776bb009792fd6aef7d31e911c75
Build description path: /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/XCBuildData/a8a3776bb009792fd6aef7d31e911c75-desc.xcbuild
note: Building targets in dependency order
warning: Run script build phase 'Create Symlinks to Header Folders' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'fmt' from project 'Pods')
ProcessInfoPlistFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Products/Debug-iphonesimulator/fmt/fmt.framework/Info.plist /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods/Target\ Support\ Files/fmt/fmt-Info.plist (in target 'fmt' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
builtin-infoPlistUtility /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods/Target\ Support\ Files/fmt/fmt-Info.plist -producttype com.apple.product-type.framework -expandbuildsettings -format binary -platform iphonesimulator -o /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Products/Debug-iphonesimulator/fmt/fmt.framework/Info.plist
ProcessInfoPlistFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Products/Debug-iphonesimulator/glog/glog.framework/Info.plist /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods/Target\ Support\ Files/glog/glog-Info.plist (in target 'glog' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
builtin-infoPlistUtility /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods/Target\ Support\ Files/glog/glog-Info.plist -producttype com.apple.product-type.framework -expandbuildsettings -format binary -platform iphonesimulator -o /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Products/Debug-iphonesimulator/glog/glog.framework/Info.plist
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libwebp.build/libwebp-all-target-headers.hmap (in target 'libwebp' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libwebp.build/libwebp-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-all-target-headers.hmap (in target 'libevent' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/libevent.build/libevent-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Yoga.build/yoga-all-target-headers.hmap (in target 'Yoga' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Yoga.build/yoga-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-perflogger.build/reactperflogger-all-target-headers.hmap (in target 'React-perflogger' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-perflogger.build/reactperflogger-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/SDWebImage.build/SDWebImage-all-target-headers.hmap (in target 'SDWebImage' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/SDWebImage.build/SDWebImage-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-logger.build/logger-all-target-headers.hmap (in target 'React-logger' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-logger.build/logger-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/PromisesObjC.build/FBLPromises-all-target-headers.hmap (in target 'PromisesObjC' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/PromisesObjC.build/FBLPromises-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-jsinspector.build/jsinspector-all-target-headers.hmap (in target 'React-jsinspector' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-jsinspector.build/jsinspector-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/DoubleConversion.build/DoubleConversion-all-target-headers.hmap (in target 'DoubleConversion' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/DoubleConversion.build/DoubleConversion-all-target-headers.hmap
WriteAuxiliaryFile /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/GTMSessionFetcher.build/GTMSessionFetcher-all-target-headers.hmap (in target 'GTMSessionFetcher' from project 'Pods')
cd /Users/chaserobbins/Documents/GitHub/glu-rn/ios/Pods
write-file /Users/chaserobbins/Library/Developer/Xcode/DerivedData/GluApp-exnhohxglkpavifmejwmwogxilfm/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/GTMSessionFetcher.build/GTMSessionFetcher-all-target-headers.hmap
PhaseScriptExecution [CP]\ Co
从 xCode 启动时出错:
Undefined symbol: hermes::vm::NopCrashManager::~NopCrashManager()
Undefined symbol: facebook::jsi::HostObject::getPropertyNames(facebook::jsi::Runtime&)
Undefined symbol: facebook::jsi::HostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
Undefined symbol: facebook::jsi::HostObject::set(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&, facebook::jsi::Value const&)
Undefined symbol: facebook::jsi::HostObject::~HostObject()
Undefined symbol: facebook::jsi::Value::Value(facebook::jsi::Value&&)
Undefined symbol: facebook::jsi::Value::Value(facebook::jsi::Runtime&, facebook::jsi::Value const&)
Undefined symbol: facebook::jsi::Value::~Value()
Undefined symbol: facebook::jsi::Buffer::~Buffer()
Undefined symbol: facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
Undefined symbol: facebook::jsi::JSError::~JSError()
Undefined symbol: facebook::react::HermesExecutorFactory::defaultRuntimeConfig()
Undefined symbol: facebook::hermes::makeHermesRuntime(hermes::vm::RuntimeConfig const&)
Undefined symbol: facebook::jsi::Value::asNumber() const
Undefined symbol: facebook::jsi::Value::toString(facebook::jsi::Runtime&) const
Undefined symbol: facebook::jsi::Object::getPropertyAsObject(facebook::jsi::Runtime&, char const*) const
Undefined symbol: facebook::jsi::Object::getPropertyAsFunction(facebook::jsi::Runtime&, char const*) const
Undefined symbol: facebook::jsi::Value::asObject(facebook::jsi::Runtime&) const &
Undefined symbol: facebook::jsi::Value::asString(facebook::jsi::Runtime&) const &
Undefined symbol: facebook::jsi::Value::asSymbol(facebook::jsi::Runtime&) const &
Undefined symbol: facebook::jsi::Object::asFunction(facebook::jsi::Runtime&) const &
Undefined symbol: facebook::jsi::Object::asArray(facebook::jsi::Runtime&) const &
Undefined symbol: facebook::jsi::Value::asObject(facebook::jsi::Runtime&) &&
Undefined symbol: facebook::jsi::Value::asString(facebook::jsi::Runtime&) &&
Undefined symbol: facebook::jsi::Object::asFunction(facebook::jsi::Runtime&) &&
Undefined symbol: facebook::jsi::Object::asArray(facebook::jsi::Runtime&) &&
Undefined symbol: typeinfo for facebook::jsi::HostObject
Undefined symbol: typeinfo for facebook::jsi::Buffer
Undefined symbol: typeinfo for facebook::jsi::JSError
Undefined symbol: vtable for hermes::vm::CrashManager
Undefined symbol: vtable for hermes::vm::NopCrashManager
Undefined symbol: vtable for facebook::jsi::HostObject
Undefined symbol: vtable for facebook::jsi::Buffer
Undefined symbol: vtable for facebook::react::HermesExecutorFactory
Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true
platform :ios, min_ios_version_supported
prepare_react_native_project!
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
target 'GluApp' do
use_frameworks!
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 => flags[:hermes_enabled],
: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 => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
target 'GluAppTests' 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
package.json
"name": "GluApp",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@cometchat-pro/react-native-chat": "3.0.11",
"@firebase/app": "^0.9.3",
"@firebase/auth": "^0.21.3",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-firebase/app": "^17.1.0",
"@react-native-firebase/auth": "^17.1.0",
"@react-navigation/native": "^6.1.3",
"@react-navigation/native-stack": "^6.9.9",
"@react-query-firebase/auth": "^1.0.0-dev.2",
"firebase": "^9.17.1",
"react": "18.2.0",
"react-native": "0.71.2",
"react-native-confirmation-code-field": "^7.3.1",
"react-native-fast-image": "^8.6.3",
"react-native-flatlist-alphabet": "^1.1.2",
"react-native-reanimated": "^2.14.4",
"react-native-safe-area-context": "^4.5.0",
"react-native-screens": "^3.19.0",
"react-native-sheet": "^0.1.6",
"react-native-vector-icons": "^9.2.0",
"react-query": "^3.39.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "^3.2.0",
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.73.7",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"jest": {
"preset": "react-native"
}
}
我也遇到了这个问题并且能够解决它。
在你的 podfile 中,
use_frameworks!
行使用框架而不是静态库。我相信有些 React Native 库不喜欢这个?
解决办法是:
use_frameworks!
替换为 use_frameworks! :linkage => :static
use_frameworks!
替换为(包含在 React-Native 入门模板中):linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
编辑:进一步研究这一点,我有更多信息。
use_framework
与 Flipper、Hermes 和新的 RN 架构(Fabric)不兼容。
在 React-Native 版本 0.69.1 中,修复程序允许 Hermes 与
use_frameworks!
一起使用。要将 use_frameworks
与 Hermes 一起使用,请确保您已设置与 use_frameworks! :linkage => :static
的静态链接。
另请参阅:https://github.com/software-mansion/react-native-reanimated/pull/3491
根据我的收集,静态库无论如何都有更快的应用程序加载时间。可能值得选择退出动态库。
没有任何解决方案对我有用,但修复对我来说非常简单。只需清理构建文件夹并再次构建即可。 在 Xcode 中清理构建文件夹的说明 打开
Xcode -> Product -> Clear build folder
清理构建文件夹后,您可以关闭并打开 Xcode,它应该可以工作。
你在babel.config.js文件中添加了react-native-reanimated babel插件了吗?
关于 React Native CLI:
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};
如果您正在使用 Expo:
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};