react-native 问题记录

150 阅读3分钟

xCode构建信息不完整,如何查看完整信息

问题如图:

Snipaste_2024-03-31_11-20-15.png 解决方案:点击最右侧的信息按钮,可查看完整信息

image.png

如何开启真机调试

  • ios
    1. 进入到ios目录,Xcode 打开.xcworkspace文件,如果是 0.60 以前的版本则打开.xcodeproj文件

    2. 注册设备

      如果这是第一次在 iOS 设备上运行 app,需要注册开发设备。从 Xcode 菜单栏打开Product菜单,然后前往Destination。从列表中查找并选择设备。Xcode 将注册为开发设备。

    3. 配置签名

      在 Xcode Project 导航中选择 project,然后选择 main target(它应该和 project 共享同样的名字)。查找"General"标签。前往"Signing"并确保在"Team"下拉下选择了开发者账号或团队。tests target(以 Tests 结尾,在 main target 下面)也需要重复同样的操作。

    4. 执行构建

opt/homebrew/Cellar/node/21.6.2_1/bin/node no such file or directory

  1. 查看ios目录下是否有.xcode.local.env文件,有的话直接删除

dyld_shared_cache_extract_dylibs

1. 进入目录: ~/Library/Developer/Xcode/iOS DeviceSupport/
2. 删除对应设备的文件 rm -rf -d phone_directory
3. 重新连接设备,可在下面路径查看连接信息

image.png

真机调试如何打release包

从 Xcode 菜单栏打开Product菜单,前往SchemeEdit Scheme

image.png

node命令执行自动kill问题解决

  1. sudo ln -s $(which node) /usr/local/bin/node
  2. codesign --force --deep --sign - /usr/local/bin/node

地图组件鸿蒙系统手机白屏问题

关闭混淆功能:修改 build.gradle 文件中  def enableProguardInReleaseBuilds = false

modal框android 没有遮盖状态栏问题

modal添加属性 statusBarTranslucent=true

expo 49 安卓审核隐私问题 获取andriodId问题解决

原因:断点调试发现expo-application包启动时,自动获取了andriodId

image.png 解决方案:patch-pachage

  1. 修改node_module中代码,修改内容如下
diff --git a/node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.kt b/node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.kt
index 8d63e9b..7c6ff29 100644
--- a/node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.kt
+++ b/node_modules/expo-application/android/src/main/java/expo/modules/application/ApplicationModule.kt
@@ -57,11 +57,17 @@ class ApplicationModule(private val mContext: Context) : ExportedModule(mContext
       Log.e(TAG, "Exception: ", e)
     }
 
-    constants["androidId"] = Settings.Secure.getString(mContext.contentResolver, Settings.Secure.ANDROID_ID)
+    // constants["androidId"] = Settings.Secure.getString(mContext.contentResolver, Settings.Secure.ANDROID_ID)
+    constants["androidId"] = "chinese_privacy_fix"
 
     return constants
   }
 
+  @ExpoMethod
+  fun getAndroidIdAsync(promise: Promise) {
+    promise.resolve(Settings.Secure.getString(mContext.contentResolver, Settings.Secure.ANDROID_ID))
+  }
+
   @ExpoMethod
   fun getInstallationTimeAsync(promise: Promise) {
     val packageManager = mContext.packageManager
diff --git a/node_modules/expo-application/build/Application.d.ts b/node_modules/expo-application/build/Application.d.ts
index cbca9fe..8d1ebce 100644
--- a/node_modules/expo-application/build/Application.d.ts
+++ b/node_modules/expo-application/build/Application.d.ts
@@ -42,6 +42,8 @@ export declare const applicationId: string | null;
  * @platform android
  */
 export declare const androidId: string | null;
+export declare const getAndroidIdAsync: () => Promise<string> | null;
+
 /**
  * Gets the referrer URL of the installed app with the [`Install Referrer API`](https://developer.android.com/google/play/installreferrer)
  * from the Google Play Store. In practice, the referrer URL may not be a complete, absolute URL.
diff --git a/node_modules/expo-application/build/Application.js b/node_modules/expo-application/build/Application.js
index c771294..77b2277 100644
--- a/node_modules/expo-application/build/Application.js
+++ b/node_modules/expo-application/build/Application.js
@@ -57,6 +57,8 @@ export const applicationId = ExpoApplication
  * @platform android
  */
 export const androidId = ExpoApplication ? ExpoApplication.androidId || null : null;
+export const getAndroidIdAsync = ExpoApplication ? ExpoApplication.getAndroidIdAsync : null;
+
 // @needsAudit
 /**
  * Gets the referrer URL of the installed app with the [`Install Referrer API`](https://developer.android.com/google/play/installreferrer)
  1. 执行 yarn patch-package expo-application
  2. package.json中增加代码
  "scripts": {
    "postinstall": "patch-package"
  },

ScrolView 嵌套,子ScrollView无法滚动问题解决

开启属性:nestedScrollEnabled=true

手势冲突控制

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

原因: 这个问题通常发生在你安装了命令行工具(CommandLineTools)后,xcode-select 的开发者目录(developer directory)仍然指向了 /Library/Developer/CommandLineTools,但实际上你需要的是完整的 Xcode 开发工具集。通常在这种情况下,xcode-select 会默认选择命令行工具,而不是完整的 Xcode,这会导致一些依赖 Xcode 的工具无法正常工作,比如 xcodebuild 或其他需要 Xcode 的命令。 解决方案:

  • 将 xcode-select 指向完整的 Xcode 安装目录
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

xcode platforms 安装经常网络不行导致下载失败问题解决

  • xcodebuild -downloadPlatform iOS