ZhengXingchi / ZhengXingchi.github.io

Apache License 2.0
0 stars 0 forks source link

react-native #69

Open ZhengXingchi opened 4 years ago

ZhengXingchi commented 4 years ago

启动页

ios配置在./ios/[项目名]/Images.xcassets/aunchImage.launchimage/Contetents.json

android在/android/app/src/main/res目录下 一堆drawable目录,替换掉以下相应目录中的launcher_screen.png就可以了。 注意如果删掉图片会报错是因为在同目录下layout/launch_screen.xml的有引用

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"  
    android:background="@drawable/launch_screen"> 
</LinearLayout>

删除android:background="@drawable/launch_screen"即可

桌面图标

ios配置在./ios/[项目名]/Images.xcassets/AppIcon.appiconset/Contetents.json

android在/android/app/src/main/res目录下 一堆mipmap目录,替换掉以下相应目录中的ic_launcher.png就可以了。 注意如果删掉图片会报错是因为在android/app/src/main/AndroidManifest.xml中有引用

 <application
      android:name=".MainApplication"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:roundIcon="@mipmap/ic_launcher_round" 
      android:allowBackup="false"
      android:theme="@style/AppTheme"
      android:networkSecurityConfig="@xml/network_security_config">
      <activity
          ......
      </activity>
      ......

    </application>

android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"删去即可

桌面名称

ios配置在./ios/cgjApp.xcodeproj/project.pbxproj

android 一般Android在打包的时候,如果没经过修改,那么应用显示的名称就是我们在react-native init时设定的名称,这肯定不是我们需要的,那么,如何修改呢?

挺简单的,我们打开项目的android/app/src/main/AndroidManifest.xml文件可以看到名称的设定: android:label="@string/app_name"

这说明app的显示名称在@string/app_name中进行了设定。 那我们直接继续打开android/app/src/main/res/values/strings.xml,即可看到配置中的app_name,修改为你想要的即可,如:

参考文献

React Native 添加图标和启动屏(完美适配各种屏幕)

react-native 配置启动图支持ios和android

ZhengXingchi commented 4 years ago

React/RCTBridgeModule.h file not found

React/RCTBridgeModule.h file not found “RCTBundleURLProvider.h” file not found - AppDelegate.m

ZhengXingchi commented 4 years ago

react-native-debugger

报错

DevTools v4 is incompatible with this version of React 
Either upgrade React or install React DevTools v3
npm install -d react-devtools@^3

安装低版本的react-native-debugger就好了 参考react-devtools agent got no connection in react native with expo

ZhengXingchi commented 4 years ago

真机调试

ios

打开"RCTWebSocketExecutor.m"文件,将“localhost”改为你的电脑的ip,然后在developer menu下单击debug js remotely启动js远程调试功能

android

方式一 在Android5.0以上设备上,将手机通过usb连接到你的电脑,然后通过adb命令行工具运行如下命令来设置端口转发 adb reverse tcp:8081 tcp:8081

方式二 通过摇一摇打开developer menu 下面的Dev Settings中设置你的电脑ip来进行调试

在使用真机调试时,你需要确保你的手机和电脑处在同一个网段内,即它们实在同一个路由器下面

ZhengXingchi commented 3 years ago

Could not find iPhone 6 simulator

react-native : 0.57.8
i solved the problem

change the file node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 42 line as below
    if (
      !version.startsWith('com.apple.CoreSimulator.SimRuntime.iOS') &&
      !version.startsWith('com.apple.CoreSimulator.SimRuntime.tvOS')
    ) {
      continue;
    }
change the file node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js 56 line as below
      if (!simulator.isAvailable) {
        continue;
      }