【转】RN报错汇总

原文网址:https://www.jianshu.com/p/804dac985411

1. 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
npm config set registry https://registry.npm.taobao.org/
//或者注册华为的
npm config set registry https://mirrors.huaweicloud.com/repository/npm/

iOS

1. 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

2. 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操作,突然就好了,至今是个谜,有些纠结。。。

3. library not found for -lRCTWebSocket 或者 glog no found 或者 libfishhook.a

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

4. _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

5. iOS使用cocoapods 安装libwebp 错误Error installing libwebp

原因:pod repo中libwebp的地址是谷歌的
解决办法:
1、
pod repo
2、在本地库中, 并找到对应的libwebp版本的文件 执行命令
find ~/.cocoapods/repos/master -iname libwebp
3、 Finder中修改libwebp.podspec.json文件
(command+shift+G)~/.cocoapods/repos/master/Specs/1/9/2/libwebp
4、把source - git中的url更换成https://github.com/webmproject/libwebp.git
然后保存
5、最后重新执行pod install

注:
1、如果仍旧报了错误: error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
解决方法:
git clone https://git.coding.net/CocoaPods/Specs.git ~/.cocoapods/repos/master
2、如果仍旧报错:
解决方法:打开Finder 使用快捷键 shift+command+G ,然后输入 /应用程序/Xcode.app/Contents/Developer
回车;进入到对应的文件

打开终端 ,输入 sudo xcode-select -switch 然后将上面文件Developer 拖到终端输入的命令sudo xcode-select -switch 后面
如下 sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 回车
然后 终端输入 pod setup

Android

1. SSL的错误,gradle版本下载不下来

解决方法: gradle.properties => systemProp 的配置全部隐藏

2. Manifest merger failed : Android

解决方法:Add to your package level android/build.gradle in buildscript -> ext:

 googlePlayServicesVersion = "16.+"
    firebaseVersion = "17.6.0"
3. Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle is packaged correctly for release.

解决方法:You need to change your target sdk to 27 instead of 28 in your project level build.gradle. From Android P(28), Google ban the use of http.

4. libfishhook.a

vi node_modules/react-native/third-party/glog-0.3.4/src/signalhandler.cc
At Line 78, change: return (void*)context->PC_FROM_UCONTEXT; to return NULL;


react native _RCTSetLogFunction

1.Opened XCode and pressed cmd + 1
2.Clicked on my project in the left panel, my target in the middle panel
3.Clicked on "Build Settings"
4.In the "Linking" section, under the "Dead Code Stripping" section, changed the setting for "Release" from "Yes" to "No"

Dead Code Stripping,Link With Standard Libraries

3.3.2 Dead Code Stripping  > YES;(YES,消除无效代码)

120104_ZnEU_2519676.png

 

For statically linked executables, dead-code stripping is the process of removing unreferenced code from the executable file. If the code is unreferenced, it must not be used and therefore is not needed in the executable file. Removing dead code reduces the size of your executable and can help reduce paging. 

To enable dead-code stripping in Xcode, in the Linking group of Build Settings, set the Dead Code Stripping option to Yes.

 

3.3.3 Link With Standard Libraries > YES;

默认是YES,编译器在链接时会自动使用标准库的链接器;

看网上好多资料都说要改成NO,但是看官方的文档,如果设置为NO,需要配置 Other Linker Flags 来指定链接器。

111340_W6I5_2519676.png



 

posted on 2020-07-31 19:00  wi100sh  阅读(458)  评论(0编辑  收藏  举报

导航