ReactNative XCode编译问题

MacOS Monterey 12.6.1 + XCode 14.1 (14B47b) + 模拟器 iPhone11 ios13.4

启动步骤

  1. 打开终端,yarn start 启动Metro服务
  2. 打开XCode,打开项目中的ios文件夹下的 .xcworkspace 项目文件
  3. 点击 ▶️ 编译运行

问题及处理方法

  • 问题:
myApp/ios/Pods/Charts/Source/Charts/Data/Implementations/Standard/ChartDataSet.swift:532:1 Unavailable instance method 'replaceSubrange(_:with:)' was used to satisfy a requirement of protocol 'RangeReplaceableCollection'
  • 解决:
    // MARK: RangeReplaceableCollection
    extension ChartDataSet: RangeReplaceableCollection 方法里补充
public func replaceSubrange<C>(_ subrange: Swift.Range<Int>, with newElements: C) where C :
  Collection, ChartDataEntry == C.Element {
}

  • 问题:
myApp/ios/bundle/assets: No such file or directory
  • 解决:
    在ios文件夹下新建 bundle/assets 路径及对应文件夹

  • 问题:
myApp/ios/bundle/main.jsbundle: No such file or directory
  • 解决:
  1. 在package.json文件新增命令
  "scripts": {
    ......
    "bundle-ios":"node node_modules/react-native/local-cli/cli.js bundle --entry-file index.js  --platform ios --dev false --bundle-output ios/bundle/main.jsbundle --assets-dest ios/bundle"
  },
  1. 终端运行 yarn bundle-ios

  1. XCode重新点击 ▶️ 编译运行
posted @   KevinTseng  阅读(66)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示