Mac下React Native初始化失败,寻求规避cdn.jsdelivr.net的方案
React Native初始化失败(libevent CDN封禁)解决方案
1. 无需依赖cdn.jsdelivr.net的替代配置
用旧版React Native初始化项目
React Native 0.71.x及更早版本的libevent podspec未使用cdn.jsdelivr.net,可指定版本创建项目:npx react-native@0.71.12 init AwesomeProject修改现有项目的libevent podspec
若项目目录已生成,手动修改node_modules/react-native/third-party-podspecs/libevent.podspec中的source字段,替换为GitHub仓库地址:# 原内容 s.source = { :http => 'https://cdn.jsdelivr.net/gh/libevent/libevent@release-2.1.12-stable/libevent.podspec' } # 修改后 s.source = { :git => 'https://github.com/libevent/libevent.git', :tag => 'release-2.1.12-stable' }进入ios目录重新执行:
pod install
2. 不受地区限制的React Native CocoaPods替代源
替换CocoaPods默认源为国内镜像
执行命令替换trunk源为清华镜像:pod repo remove trunk pod repo add trunk https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git单独指定libevent的podspec来源
在ios/Podfile中添加如下配置,直接从GitHub拉取libevent的podspec:pod 'libevent', :podspec => 'https://raw.githubusercontent.com/libevent/libevent/release-2.1.12-stable/libevent.podspec'之后执行
pod install即可。
内容的提问来源于stack exchange,提问作者Saadalla
相关产品推荐
相关产品推荐

