react-native-video iOS端出现Thread 1: signal SIGABRT错误求排查
Hey fellow dev, that SIGABRT crash on iOS while Android runs smoothly is almost always a missing platform-specific configuration step. Let’s walk through the most common fixes to get your video component working on iOS:
1. Add Mandatory Info.plist Permissions
iOS requires explicit permission strings for any media-related functionality—even if you’re just playing pre-recorded video. If your app touches camera or microphone features (directly or via the video component), add these entries to your Info.plist (located in ios/[YourAppName]/):
<!-- Insert inside the <dict> tag of your Info.plist --> <key>NSCameraUsageDescription</key> <string>Need camera access to record or preview video</string> <key>NSMicrophoneUsageDescription</key> <string>Need microphone access for audio in video content</string>
If you’re loading videos from non-HTTPS URLs, you’ll also need to adjust App Transport Security (ATS) settings (note: avoid global ATS disable for production):
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
2. Verify CocoaPods Installation
react-native-video relies on CocoaPods for iOS integration, and incomplete or outdated pod installs are a frequent crash trigger. Follow these steps:
- Navigate to your iOS directory:
cd ios - Clear old pod files:
rm -rf Pods Podfile.lock - Reinstall pods:
pod install - Double-check your
Podfileincludes the correct package reference:pod 'react-native-video', :path => '../node_modules/react-native-video'
3. Fix Local Video Asset Setup
If using local video files:
- Drag the video file into your Xcode project navigator, making sure "Copy items if needed" is checked and your app target is selected under "Add to targets"
- Use the correct path syntax in your React Native code—iOS requires proper
require()usage:<Video source={require('./assets/demo-video.mp4')} />
4. Check Version Compatibility
Mismatched versions between react-native-video and React Native often cause crashes. For example:
- React Native 0.70+ requires react-native-video v6.0 or later
- Update to a compatible version if needed:
npm install react-native-video@latest
5. Perform a Full Clean and Rebuild
Cached build files can cause odd, hard-to-trace crashes. Do a complete reset:
- In Xcode: Press
Cmd + Shift + Kto clean the build folder - In your project root:
npm cache clean --force - Reinstall dependencies:
npm install - Re-run pod install (follow step 2)
Pro Tip: Dig Into Xcode’s Error Log
The SIGABRT signal is generic, but Xcode’s console output (below the crash line) will have a specific error message—look for lines like "Missing Info.plist key" or "Unable to load asset" to pinpoint the exact issue faster.
内容的提问来源于stack exchange,提问作者陈黑白

