React Native中Xcode编译出现x86_64架构重复符号错误求助
React Native Xcode编译x86_64架构重复符号错误解决方法
错误详情
重复符号'_fsQueue'存在于: /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtil.o) /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlob.o) 重复符号'_commonTaskQueue'存在于: /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtil.o) /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlob.o) 重复符号'_fileStreams'存在于: /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtilFS.o) /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlobFS.o) 重复符号'_expirationTable'存在于: /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/react-native-blob-util/libreact-native-blob-util.a(ReactNativeBlobUtilNetwork.o) /Users/iTech/Library/Developer/Xcode/DerivedData/billingcalculatorshreejicode-exzozodcmqezdscmibmkfzyrvmvc/Build/Products/Debug-iphonesimulator/rn-fetch-blob/librn-fetch-blob.a(RNFetchBlobNetwork.o) ld: x86_64架构下存在4个重复符号 clang: error: 链接器命令失败,退出码为1(使用-v查看调用详情)
问题原因
react-native-blob-util是rn-fetch-blob的衍生维护库,二者底层实现包含相同的全局符号,同时引入会触发Xcode链接器的重复符号冲突。
解决方法
方案1:移除冲突库(推荐)
因为react-native-blob-util是rn-fetch-blob的替代方案,维护更活跃,优先移除rn-fetch-blob:
- 执行卸载命令:
npm uninstall rn-fetch-blob # 或使用yarn yarn remove rn-fetch-blob - 清理Xcode缓存:删除DerivedData目录(路径如错误信息所示),或在Xcode中按
Cmd+Shift+K执行清理 - 重新安装依赖:
npm install # 或 yarn install - 重新编译项目
方案2:临时忽略重复符号(不推荐,仅作应急)
若暂时无法移除任一库,可修改Xcode链接器设置忽略冲突符号:
- 打开Xcode项目,选中目标工程,进入
Build Settings - 搜索
Other Linker Flags - 添加以下参数:
-Wl,-U,_fsQueue -Wl,-U,_commonTaskQueue -Wl,-U,_fileStreams -Wl,-U,_expirationTable - 注意:此方法仅为临时 workaround,可能引发运行时未知问题,建议尽快替换为方案1
内容的提问来源于stack exchange,提问作者Ramani Chirag
相关产品推荐
相关产品推荐

