解决react-native-image-picker IOS 无法上传视频

449 阅读1分钟

错误描述:

调用showImagePicker选择视频方法 回调未执行,XCode中报权限错误

错误原因:

插件问题,目前还未修复,只能手动更改源码

解决方法

在XCode中找到 react-native-image-picker 中的 ImagePickerManager.m文件,将

[fileManager moveItemAtURL:videoURL toURL:videoDestinationURL error:&error];

更改为

[fileManager copyItemAtURL:videoURL toURL:videoDestinationURL error:&error];

可通过在package.json文件中配置postinstall属性来实现每次yarn自动更改源码文件,备份的文件路径自己定,我是放在了ios/yarnReplacePage中

"postinstall": " cp ios/yarnReplacePage/ImagePickerManager.m node_modules/react-native-image-picker/ios/ImagePickerManager.m "