【问题标题】:FastLanes. Run sh action in Xcode project root folder快车道。在 Xcode 项目根文件夹中运行 sh 操作
【发布时间】:2015-11-04 14:54:16
【问题描述】:

在以下Fastfile 上运行fastlane build_and_rename

  lane :build_and_rename do
    sigh
    gym(output_directory: "./Build/")
    sh "mv ./Build/MY-APP.ipa ./Build/nicely_name.ipa"
  end

导致以下错误ln: ./Build/MY-APP.ipa: No such file or directory

测试表明,FastLane 的sh 操作在./fastlane 目录中运行。例如,fastlane test_sh 代表以下 Fastfile

  lane :test_sh do
    sh "touch where_am_i.txt"
  end

导致在./fastlane 文件夹中创建where_am_i.txt。不在运行fastlane 的文件夹中。

显然我可以更改所有脚本以包含 ../,但想知道是否有办法让 fastlane 在 xCode 的根项目中运行 sh 操作?

【问题讨论】:

    标签: ios fastlane


    【解决方案1】:

    原来比较简单,只要加上cd.. &&就可以切换到根目录了。

    lane :test_sh do
        sh "cd .. && touch where_am_i.txt"
    end
    

    https://github.com/fastlane/fastlane/issues/990#issuecomment

    【讨论】:

    • 如何在shell脚本中传递参数?这不起作用lane :addPrivateKey do | options | sh ("cd .. && ./add_key.sh ", options[:clientKey]) end
    • 错误是什么?您是否尝试过 sh ("touch", options[:clientKey]) 之类的方法来查看 options 参数是否按预期工作?
    【解决方案2】:

    要更改目录,您可以使用 Ruby,Dir.chdir

    示例

    lane :test_sh do
      Dir.chdir("..") do
        # code here runs in the parent directory
        sh "touch where_am_i.txt"
      end    
    end
    

    Fastlane docs

    【讨论】:

      【解决方案3】:

      在 shell 脚本中调用 fastlane 操作。

      转到包含 fastlane 文件夹的文件夹。

      path="快速通道路径"

      cd $path/
      fastlaneAction="fastlane test_do"
      $fastlaneAction
      

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      • 2019-12-21
      • 1970-01-01
      相关资源
      最近更新 更多