【问题标题】:Where to add source map command in Xcode for my production build when adding sourcemap for React Native for Production?为 React Native for Production 添加源映射时,在 Xcode 中的何处为我的生产构建添加源映射命令?
【发布时间】:2016-03-12 15:25:39
【问题描述】:

RE(没有足够的经验值在那里回复): “在我的生产构建的捆绑命令中,我告诉它生成源映射” How to add sourcemap in React Native for Production?

在 Xcode 7.3 beta 3 中,我转到 [我的项目] > 构建阶段 > 捆绑 React Native 代码和图像

在: 导出 NODE_BINARY=节点 ../node_modules/react-native/packager/react-native-xcode.sh

我补充说: cd /Users/andresn/dev/[我的项目] react-native bundle --platform ios --entry-file index.ios.js --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios --sourcemap-output ./sourcemap .js

他的意思是这样的,还是有更合适的方法?

【问题讨论】:

  • 注意:在第一个 cd 之后需要一个分号或换行符: cd /Users/andresn/dev/[My Project]; react-native bundle --platform ios --entry-file index.ios.js --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios --sourcemap-output ./sourcemap .js
  • 嘿@Andres Narvaez 你设法让它为你工作了吗?
  • @brien.crean 是的,在我上次发表评论后至今没有任何问题。

标签: ios xcode react-native


【解决方案1】:

我最终在 Bundle React Native 代码和图像中使用了以下脚本:

export NODE_BINARY=node
if [ "${CONFIGURATION}" = "Release" ]
then ../sourcemap.sh
else ../node_modules/react-native/scripts/react-native-xcode.sh
fi

然后在项目目录的根目录中,我使用以下 sourcemap.sh 脚本在 ./ios 目录中生成一个源映射文件:

#!/bin/bash
$NODE_BINARY ../node_modules/react-native/local-cli/cli.js bundle --platform ios --entry-file ./index.ios.js --dev false --bundle-output ./main.jsbundle --assets-dest ./ --sourcemap-output ./main.jsbundle.map

【讨论】:

    【解决方案2】:

    基于您已经说过的通用解决方案:

    export NODE_BINARY=node
    
    if [ "${CONFIGURATION}" = "Release" ]
    then
      cd "${PROJECT_DIR}/../"
      react-native bundle --platform ios --entry-file index.ios.js --dev false --bundle-output ./ios/main.jsbundle --assets-dest ./ios --sourcemap-output ./ios/main.jsbundle.map
    else
      ../node_modules/react-native/scripts/react-native-xcode.sh
    fi
    

    确保将资产和 main.jsbundle.map 添加到您的 iOS 项目,然后再次创建发布版本。

    【讨论】:

    猜你喜欢
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2019-11-05
    • 2020-12-11
    相关资源
    最近更新 更多