在xcode運行腳本中運行腳本執行目的 - Run Script execution purpose in xcode run script -开发者知识库

在xcode運行腳本中運行腳本執行目的 - Run Script execution purpose in xcode run script -开发者知识库,第1张

I have a app that uses the shell script that do something during compilation, I am trying to understand what exactly that script do since I am getting compilation error and not able to run the source code.

我有一個應用程序使用shell腳本在編譯期間執行某些操作,我試圖了解該腳本究竟是什么,因為我收到編譯錯誤而無法運行源代碼。

If someone can help me and explain what below script do

如果有人可以幫助我並解釋下面腳本的作用

#!/bin/bash

echo BUILD_ROOT = "${BUILD_ROOT}"

p=`echo "${BUILD_ROOT}" | sed -ne 's/.*\(^\/.*\/DerivedData\).*//p'`

echo "//${BUILD_ROOT}" > ${SRCROOT}/info.h

cat "${p}/../info.h" >> ${SRCROOT}/info.h

I am getting following errors during compilation

我在編譯期間遇到以下錯誤

BUILD_ROOT = /Working/XXXXXXX/XXXXX/testTarget/DerivedData/testTarget/Build/Products cat: /Working/XXXXXX/XXXXXXX/testTarget/DerivedData/../info.h: No such file or directory

BUILD_ROOT = / Working / XXXXXXX / XXXXX / testTarget / DerivedData / testTarget / Build / Products cat:/Working/XXXXXX/XXXXXXX/testTarget/DerivedData/../info.h:沒有這樣的文件或目錄

1 个解决方案

#1


1  

This script doesn't make too much sense. What are you hoping for it to do? I'll break it down per line:

這個腳本沒有多大意義。你有什么希望呢?我會按行分解:

  1. Essentially this does nothing, it's storing the value of BUILD_ROOT in itself.
  2. 基本上這沒有任何作用,它存儲了BUILD_ROOT的值。
  3. By default, Xcode uses ~/Library/Developer/Xcode/DerivedData/<YOUR_APP>-XXXXX/... for its BUILD_ROOT variable. This line of code stores the full path of that folder in variable p.
  4. 默認情況下,Xcode使用〜/ Library / Developer / Xcode / DerivedData / -XXXXX / ...作為其BUILD_ROOT變量。這行代碼在變量p中存儲該文件夾的完整路徑。
  5. Creates a file called info.h at the base folder of your app's source code with the value of BUILD_ROOT.
  6. 在應用程序源代碼的基本文件夾中創建一個名為info.h的文件,其值為BUILD_ROOT。
  7. This line is going to the folder above DerivedData and printing the value of info.h - which doesn't actually exist and therefore crashing the script - and appending it to the info.h created in line 3.
  8. 這一行將轉到DerivedData上方的文件夾並打印info.h的值 - 它實際上並不存在,因此會使腳本崩潰 - 並將其附加到第3行中創建的info.h中。

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复