How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

huangapple go评论71阅读模式
英文:

How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

问题

我使用React Native和Expo构建了一个应用程序。
我之前使用Expo SDK版本48,刚刚升级到版本49。现在当我运行:eas buildeas submit,然后通过TestFlight在手机上更新我的应用程序时,它立即崩溃。

我该如何解决这个错误 - 或者找出为什么会发生这种情况?
顺便说一句:我的项目名称是hercules

解决尝试1:App Store Connect崩溃报告

然后我可以发送一个崩溃报告。

如果我在App Store Connect中找到它并点击'在Xcode中打开':

How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

然后我会得到一个类似这样的堆栈跟踪:

How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

我猜这是使用React Native和Expo的一个缺点。当像这样生成最终构建时,更难理解堆栈跟踪中的信息。我无法理解上面显示的图像中的内容。

解决尝试2:Expo.dev中的构建日志

我还检查了Expo.dev的“构建”菜单中的“构建日志”。有9MB的日志。以下是开头和结尾部分(没有时间戳,所以我不知道它是按升序还是降序排序的):

命令行调用:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace ./hercules.xcworkspace -scheme hercules -configuration Release -destination generic/platform=iOS -archivePath "/Users/expo/Library/Developer/Xcode/Archives/2023-07-09/hercules 2023-07-09 15.19.05.xcarchive" archive
用户默认值来自命令行:
    IDEArchivePathOverride = /Users/expo/Library/Developer/Xcode/Archives/2023-07-09/hercules 2023-07-09 15.19.05.xcarchive
    IDEPackageSupportUseBuiltinSCM = YES
准备包
计算目标依赖图和提供输入
创建构建描述
构建描述签名:2d65783870e59f558d579d6dedae71da
构建描述路径:/Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/IntermediateBuildFilesPath/XCBuildData/2d65783870e59f558d579d6dedae71da.xcbuilddata
注意:按依赖关系的顺序构建目标
CreateBuildDirectory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation
    cd /Users/expo/workingdir/build/ios
    builtin-create-build-directory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation
CreateBuildDirectory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/IntermediateBuildFilesPath
...
...
...
验证 /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app (在项目'hercules'中的目标'hercules'中)
    cd /Users/expo/workingdir/build/ios
    builtin-validationUtility /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app
Touch /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app (在项目'hercules'中的目标'hercules'中)
    cd /Users/expo/workingdir/build/ios
    /usr/bin/touch -c /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app
警告:运行脚本构建阶段'[CP-User] Generate app.manifest for expo-updates'将在每次构建期间运行,因为它没有指定任何输出。要解决此警告,请将输出依赖项添加到脚本阶段,或通过取消选中脚本阶段中的“基于依赖关系分析”来配置它在每次构建中运行。(在项目'Pods'中的目标'EXUpdates'中)
** 归档成功 **

解决尝试3:其他小注释和尝试

  • 在我的手机上,我更新了应用程序版本后,什么都看不到:它立即崩溃了。
  • 我尝试了强制退出应用程序、重新安装应用程序、重启手机。这些都没有改变结果(仍然立即崩溃)。
  • 我可以在我的Mac上的iOS模拟器上运行应用程序(没有崩溃,但我遇到了Axios Network Error,我正在调试它)。
  • 我尝试过安装Sentry以获得更好的错误报告。但我无法让它工作(构建开始
英文:

I have an app built with React Native and Expo.
I had it on Expo SDK-version 48 and just upgraded to version 49. Now when I run: eas build and eas submit and then update my app via TestFlight on my phone, then it crashes immediately.

How do I solve this error - or figure out why it happens?
And my FYI: My projects name is hercules.

Solution attempt 1: App Store Connect Crash report

I can then send a crash report.

If I find it in App Store Connect and click 'Open in Xcode':

How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

I then get a stack trace like this:

How to debug React Native Expo-app crashing on iOS, after updating Expo SDK to version 49. Running the app in an iOS simulator works fine

I guess this is the downside of using React Native and Expo. When the final build is generated like this, then it's harder to make sense of the stack trace. I can't make sense of what it says in above-shown image.

Solution attempt 2: Build logs in Expo.dev

I also checked the "Build logs" from the Expo.dev "Build" menu. There are 9mb of logs. Here is the start and the end (there are no timestamps, so I don't know if it's sorted in ascending or descending order):

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace ./hercules.xcworkspace -scheme hercules -configuration Release -destination generic/platform=iOS -archivePath "/Users/expo/Library/Developer/Xcode/Archives/2023-07-09/hercules 2023-07-09 15.19.05.xcarchive" archive
User defaults from command line:
    IDEArchivePathOverride = /Users/expo/Library/Developer/Xcode/Archives/2023-07-09/hercules 2023-07-09 15.19.05.xcarchive
    IDEPackageSupportUseBuiltinSCM = YES
Prepare packages
Computing target dependency graph and provisioning inputs
Create build description
Build description signature: 2d65783870e59f558d579d6dedae71da
Build description path: /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/IntermediateBuildFilesPath/XCBuildData/2d65783870e59f558d579d6dedae71da.xcbuilddata
note: Building targets in dependency order
CreateBuildDirectory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation
    cd /Users/expo/workingdir/build/ios
    builtin-create-build-directory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation
CreateBuildDirectory /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/IntermediateBuildFilesPath
...
...
...
Validate /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app (in target 'hercules' from project 'hercules')
    cd /Users/expo/workingdir/build/ios
    builtin-validationUtility /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app
Touch /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app (in target 'hercules' from project 'hercules')
    cd /Users/expo/workingdir/build/ios
    /usr/bin/touch -c /Users/expo/Library/Developer/Xcode/DerivedData/hercules-aiqjbxmtddzpiscjqedlczrddaee/Build/Intermediates.noindex/ArchiveIntermediates/hercules/InstallationBuildProductsLocation/Applications/hercules.app
warning: Run script build phase '[CP-User] Generate app.manifest for expo-updates' 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 'EXUpdates' from project 'Pods')
** ARCHIVE SUCCEEDED **

Solution attempt 3: Other minor notes and attempts

  • On my phone, after I've updated the app version, I don't see anything: It crashed immediately.
  • I tried force-quitting the app, reinstalling it, rebooting my phone. None of it changes the outcome (still an immediate crash).
  • I can run the app in an iOS simulator on my Mac (no crash, but I do get an Axios Network Error I'm debugging now).
  • I've tried to install Sentry to get better error reporting. But I couldn't get this to work (the build started to fail). So I remove this again.

Quickfix: Downgrade to Expo version 48.0.18

I downgraded the version in package.json (amongst cleaned up my file from new versions that was bumped).
Then I deleted package-lock.json and node_modules.
Ran npm install
Ran npx expo install --fix
Ran npx expo start -c
Ran eas build
Ran eas submit

That worked. No crash. ¯\_(ツ)_/¯

答案1

得分: 3

我在花了一天的时间后,在我的构建中修复了这个问题:问题实际上并不是由expo引起的;而是由于一个过时的expo-jest版本引起的,它失败了,因为它引用了一个过时的expo-config版本。我最初在expo-doctor中忽略了它,因为它只是一个开发依赖,所以我认为这并不重要。

你可以通过运行 npx expo-doctor 来验证是否存在这个问题,看看它是否提到了关于 expo-config 的内容。要升级到 expo 49,我只是在我的 package.json 文件中将 "jest-expo" 一行替换为 "jest-expo": "^49.0.0"

英文:

I fixed this in my build after burning a day: the problem wasn't actually caused by expo; it was caused by an outdated version of expo-jest, which was failing because it had a reference to an outdated version of expo-config. I initially ignored it in expo-doctor because it was just a dev dependency, so I thought it didn't matter.

You can verify if this is your issue by running npx expo-doctor and seeing if it mentions something about expo-config. For upgrading to expo 49, I just replaced my "jest-expo" line in package.json to "jest-expo": "^49.0.0".

huangapple
  • 本文由 发表于 2023年7月10日 19:53:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76653474.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定