首页 > 其他分享 >ReactNative XCode编译问题

ReactNative XCode编译问题

时间:2022-12-03 12:00:19浏览次数:55  
标签:-- XCode ios bundle 编译 myApp ReactNative

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重新点击 ▶️ 编译运行

标签:--,XCode,ios,bundle,编译,myApp,ReactNative
From: https://www.cnblogs.com/KevinTseng/p/16947275.html

相关文章