【发布时间】:2021-07-25 18:06:03
【问题描述】:
对于最近开始发生的这个问题,我感到很陌生。以前,我的应用程序通过运行此命令 react-native run-ios 在 iOS 模拟器上运行良好。现在我做了很多研究,并让我的应用程序通过 XCode 运行。但不知何故,当应用程序通过 XCode 运行时,metro bundler 没有链接。
我尝试通过react-native run-ios 运行该应用程序,但每次都看到此错误。在这里复制粘贴每个错误都太大了,但这里有一些:
Undefined symbols for architecture x86_64:
"Swift._ArrayBuffer._copyContents(initializing: Swift.UnsafeMutableBufferPointer<A>) -> (Swift.IndexingIterator<Swift._ArrayBuffer<A>>, Swift.Int)", referenced from:
generic specialization <serialized, Swift._ArrayBuffer<Swift.Int8>> of Swift._copyCollectionToContiguousArray<A where A: Swift.Collection>(A) -> Swift.ContiguousArray<A.Element> in libMixpanel-swift.a(AutomaticProperties.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld /Users/careerlabsdev/Library/Developer/Xcode/DerivedData/CareerLabs_Elev8-gxcfanteiuxazegkgwkjkrjxbdmw/Build/Products/Debug-iphonesimulator/CareerLabs.app/CareerLabs normal
(1 failure)
为了让它发挥作用,我做了很多事情。我在这里获得的唯一成功是while running the command react-native run-ios, it opens up the metro bundler server。之后,它失败并给出 1000 行错误。我选择了有一些奶油部分的错误。从错误中挑选一些关键词:
- ld:未找到架构 x86_64 的符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
- 不理解 BUILD FAILED 下列出的 Ld 一词
我的做法如下:
- 正在删除 node_modules、Pod。从 XCode 清理构建。运行
npm install,然后运行cd ios && pod install,然后运行命令react-native run-ios - 删除 Pod,Podfile.lock。做了
pod install,然后在根react-native run-ios - 这样做:
rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
pod install
cd ..
react-native run-ios
- 重启系统,再次运行命令
react-native run-ios - 在 XCode 的 Excluded Architecture 中添加了 arm64。请注意,这使我能够
build and runXCode 上的应用成功。但它不会连接到 Metro 捆绑器服务器。看起来它只运行发布模式。 - 将我的包
react-native-gesture-handler更新为最新的1.10.3,看看是否能解决我的问题。但没有运气。
我的 Podfile 如下所示:
platform :ios, '10.0'
use_flipper!({'Flipper' => '0.81.0'})
post_install do |installer|
flipper_post_install(installer)
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
我现在别无选择,正在等待提供一些见解。看到从未造成问题的事物出现错误确实令人沮丧。我正在使用 Apple M1 芯片 Macbook。
更新 V1.0
- 我尝试从
/ios/Podfile中注释掉use_flipper!(),然后重新做同样的事情,比如删除Pods、Podfile.lock。运行这个命令,pod update && pod install && cd.. && npm run ios。遇到多个问题。我不知道 Apple M1 上的 XCode 和 React Native 有什么问题。
更新 V2.0
我发现了一些开发人员抱怨相同的重要地方。 XCode 已在未经我通知的情况下将我的版本强制更新到 12.5。现在 XCode 给 RN Older 项目带来了问题。以下是相同的支持链接:
我希望这可以给像我一样困惑的开发人员一些见解。请看一下,看起来Facebook 正在修复它,但不知道什么时候。必须密切关注:/
【问题讨论】:
标签: ios xcode react-native build-error apple-m1