RN报错汇总

一、react-native init #projName# 报错:

 info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "http://registry.npm.taobao.org/@babel/plugin-proposal-class-properties/download/@babel/plugin-proposal-class-properties-7.3.0.tgz: Client network socket disconnected before secure TLS connection was established".

镜像不对,检查镜像是否为taobao的镜像,

npm config list
//或者
npm config get registry
解决方法:

能看到key值为registry的url,是否为https://registry.npm.taobao.org/ ,不是的话,修改:

npm config set registry https://registry.npm.taobao.org/
//或者注册华为的
npm config set registry https://mirrors.huaweicloud.com/repository/npm/

二、Cocoapods下的第三方库libReact.a多个路径

:-1: Multiple commands produce '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a':
1) Target 'React' has a command with output '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a'
2) Target 'React' has a command with output '/Users/***/Library/Developer/Xcode/DerivedData/sentryCpush-cvpqbragxhlzloeebvyoihyauasl/Build/Intermediates.noindex/ArchiveIntermediates/sentryCpush/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libReact.a'
解决方式:

在Podfile中添加:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    
    # The following is needed to ensure the "archive" step works in XCode.
    # It removes React & Yoga from the Pods project, as it is already included in the main project.
    # Without this, you'd see errors when you archive like:
    # "Multiple commands produce ... libReact.a"
    # "Multiple commands produce ... libyoga.a"
    
    targets_to_ignore = %w(React yoga)
    
    if targets_to_ignore.include? target.name
      target.remove_from_project
    end
    
  end
end

四、Staging 打包报错:

问题:

:-1: "sentryCpush" requires a provisioning profile. Select a provisioning profile for the "Staging" build configuration in the project editor. (in target 'sentryCpush')

或者

directory not found for option '-L/Users/***/Library/Developer/Xcode/DerivedData/qifutong-avakrnqhxoxkxdcqxbgxzehdkoeg/Build/Products/Staging-iphonesimulator/yoga'
解决方法:

1、前提是你没有改过所有Staging加载的路径,
或者你改过的话,看一下所有Staging加载的路径,都必须还是Staging环境下的,没有手动改为Release。eg:/$(CONFIGURATION)没有被Release代替

$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

2、需要修改两处
(1)、工程的build Settings 中 Per-configuration Build Products Path 的 Staging,修改为 Release

$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)

(2)、Pods的工程,build Settings 中 Per-configuration Build Products Path 的 Staging,修改为 Release

$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)

如果Pod中没有Staging环境,info的Configurations 点击 + 号,添加Release Configuration ,然后把新添加的修改名称为Staging,再更改Per-configuration Build Products Path

3、library not found for -lPods-myapp
重新link了下, pod update,xcode进行clear操作,突然就好了,至今是个谜,有些纠结。。。

五、library not found for -lRCTWebSocket 或者 glog no found

cd node_modules/react-native/third-party/glog-0.3.5
../../scripts/ios-configure-glog.sh

六、_RCTSetLogFunction 报错

Undefined symbols for architecture arm64:   "_RCTSetLogFunction", referenced from:       -[PropertyFinderTests testRendersWelcomeScreen] in PropertyFinderTests.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决:
Build Setting 中设置 Dead Code StrippingNo

你可能感兴趣的:(RN报错汇总)