ZhengXingchi / ZhengXingchi.github.io

Apache License 2.0
0 stars 0 forks source link

react native #64

Open ZhengXingchi opened 4 years ago

ZhengXingchi commented 4 years ago

搭建开发环境

brew install node
brew install watchman

# 使用nrm工具切换淘宝源
npx nrm use taobao
# 如果之后需要切换回官方源可使用
npx nrm use npm

# 下载Android studio
https://developer.android.google.cn/
ZhengXingchi commented 4 years ago

参考文献

React Native 入门学习笔记

React Native for Windows + macOS

ZhengXingchi commented 4 years ago

Xcode_10.2.1.xip(您使用的是 macOS 10.13.3。该应用程序要求 macOS 10.14.3 或更高版本。) 后来使用了Xcode_5.1.dmg,还是没法用,参考了Xcode 与 macOS 系统版本的兼容问题 最后采用了Xcode_9.xip安装并放到application启动台上 Apple官方下载地址 iMyMac Mac Cleaner&&免费的PDF压缩器

ZhengXingchi commented 4 years ago

android开发平台

android开发环境

ZhengXingchi commented 4 years ago

  1. * What went wrong:
    Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
    > java.nio.file.AccessDeniedException: /xxxxxxx/rnapp/android/app/build/intermediates/transforms/dexBuilder/debug/0/androidx/core/R.dex

    最后在命令行加sudo yarn android解决,本来想参考完美解决:app:transformClassesWithDexForDebug,但是好像不是一个问题,没什么帮助

ZhengXingchi commented 4 years ago
  1. 
    Getting these errors on initializing a new react native app:
  2. Property 'passwordRules' not found on object of type 'UIView *'
  3. Use of undeclared identifier 'UITextInputPasswordRules'

Try updating Xcode to the latest. I was stuck in Mojave so couldn't update the Xcode. But after Catalina + latest Xcode. Build worked. Xcode 9.x definitely not gonna work with react native 0.60.0+

参考自Property 'passwordRules' not found on object of type 'UIView *'

ZhengXingchi commented 4 years ago
  1. Could not install the app on the device, read the error above for details. 项目根文件下运行 就是为android文件夹下的gradlew命令 添加权限 chmod 755 android/gradlew 最后记得检查下/android/local.properties,改为自己sdk位置
ZhengXingchi commented 4 years ago
  1. A problem occurred configuring project ':app'. > failed to find Build Tools revision 28.0.1 修改/android/build.gradle文件
    android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    ...
ZhengXingchi commented 4 years ago
  1. Could not find com.android.support:appcompat-v7:27.1.1 参考[Could not find com.android.support:appcompat-v7:27.1.1.](https://github.com/lottie-react-native/lottie-react-native/issues/343)
    
    I had the same issue. According to this issue Could not find com.android.support:appcompat-v7:26.1.0.

In the android gradle file you need to specify the following

compileSdkVersion 26 buildToolsVersion "26.0.1" and then find this text compile "com.android.support:appcompat-v7" and make sure it says compile "com.android.support:appcompat-v7:26.0.1"

In your build.gradle file add maven url 'https://maven.google' should look like this

allprojects { repositories { mavenLocal() jcenter() maven { url 'https://maven.google.com' } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } } } Rebuild your project, then this problem has been solved 😄

ZhengXingchi commented 4 years ago
  1. Execution failed for task ':app:installDebug'. 参考Gradle: Error while uploading app-local-debug.apk : Unknown failure ([CDS]close[0]) [Build failed with an exception: Execution failed for task ':app:installDebug'. #15901](https://github.com/facebook/react-native/issues/15901)
adb devices     
sudo  react-native run-android --deviceId emulator-5554
ZhengXingchi commented 4 years ago
  1. Strict mode does not allow function declaration 参考SyntaxError:Strict mode does not allow function declaration in a lexically nested statement.

将react-native版本改成0.38.0能解决问题。

ZhengXingchi commented 4 years ago
  1. requiring unknown module "0" 删除node_modules重新安装并且重启react-native run-android
ZhengXingchi commented 4 years ago

ios打包

Xcode: Missing private key

iOS证书(.p12)和描述文件(.mobileprovision)申请 IOS Missing private key Apple开发者账号介绍及证书配置说明。 iOS 的「描述文件」是什么? iOS开发者证书和描述文件申请 一个苹果证书如何多次使用——导出p12文件

ZhengXingchi commented 4 years ago

手动下载Xcode Simulator

手动下载Xcode Simulator

ZhengXingchi commented 4 years ago

android打包

Error: Watchman error: resolve_projpath: path

参考[Watchman crawl failed. After MacOS Catalina Update #751](https://github.com/facebook/watchman/issues/751)

To change the permissions for Watchman regarding the Documents folder, it's under Security & Privacy -> files & folders in the system preferences
Guys. I spent hours to figure this out. I found a solution.
If you still face this problem after you re-install node, watchman and expo cli etc, You gotta try this simple step. Trust me. Its all bcuz of catalina grant access to folders permission.

First, Kill all the server running and close your terminal.
Go to 'System preference' -> 'Security & Privacy' -> scroll down and click 'Full Disk Access' -> Make sure you checked on 'Terminal' and 'Watchman'. Save and restart ur laptop.

You are welcome.
ZhengXingchi commented 3 years ago
  1. error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening cgjApp.xcworkspace. Run CLI with --verbose flag for more details. Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace cgjApp.xcworkspace -configuration Debug -scheme cgjApp -destination id=3C4694DD-961C-4949-BA21-2F7837EAA402 -derivedDataPath build/cgjApp

User defaults from command line: IDEDerivedDataPathOverride = /项目地址/ios/build/cgjApp

error: /项目地址/ios/Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig: unable to open file (in target "NotificationService" in project "cgjApp") (in target 'NotificationService' from project 'cgjApp') error: /项目地址/ios/Pods/Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig: unable to open file (in target "NotificationService" in project "cgjApp") (in target 'NotificationService' from project 'cgjApp')

解决方案

cd ios
pod install
ZhengXingchi commented 3 years ago
  1. 解决CocoaPods各种慢的方案 /user/用户名/.cocoapods/repos