ios - iOS 项目上的命令脚本问题

标签 ios iphone xcode

我得到一个 iOS 项目,我想用 XCode 编译它。
当我构建它时,出现以下错误:

(!)Run custom shell script 'Get App Version'
 _________________________________________________________________
| PhaseScriptExecution Get\ App\ Version /Users........./Script-  9AAC7B315646546DC5.sh
| cd ....
| export ....
| ....
| long scripts
| .... 
|_________________________________________________________________
sed: 1: "s/CURRENT_VERSION/There ...": unescaped newline inside subtitute pattern
Command /bin/sh failed with exit code 1.

在项目中,当我转到 Target > Build Phases 时,没有运行脚本阶段。

编辑
我在“构建阶段”>“获取应用程序版本”

中找到了脚本
Shell: /bin/sh
Version='agvtool vers -terse'
sed -e "s/CURRENT_VERSION/$Version/g" Resources/App/version.h.tpl > GeneratedFiles/version.h

如果我添加 echo $Version 我会得到以下内容

There are multiple projects in this directory. agvtool does not work with multiple projects in the same directory. agvtool - Apple-generic versioning tool for Xcode projects usage: agvtool help agvtool what-version | vers [-terse] agvtool [-noscm | -usecvs | -usesvn] next-version | bump [-all] agvtool [-noscm | -usecvs | -usesvn] new-version [-all] <versNum> agvtool [-noscm | -usecvs | -usesvn] tag [-force | -F] [-noupdatecheck | -Q] [-baseurlfortag] agvtool what-marketing-version | mvers [-terse | -terse1] agvtool [-noscm | -usecvs | -usesvn] new-marketing-version <versString>
sed: 1: "s/CURRENT_VERSION/There ...": unescaped newline inside substitute pattern
Command /bin/sh failed with exit code 1

最佳答案

这是错误:

sed: 1: "s/CURRENT_VERSION/There ...": unescaped newline inside subtitute pattern

我认为问题在于 > 之后的新行。你的脚本应该是 3 行,而不是 4

Shell: /bin/sh
Version='agvtool vers -terse'
sed -e "s/CURRENT_VERSION/$Version/g" Resources/App/version.h.tpl > GeneratedFiles/version.h

或者 $Version 包含一个 \n

改为

你可以完全删除那个构建脚本

关于ios - iOS 项目上的命令脚本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35158872/

相关文章:

ios - 我不小心删除了 Xcode 8 中的 asset 资源文件夹

ios - 如何为 iOS 应用程序创建 iCloud 日历以与 swift 一起使用?

ios - UITableViewCell 堆积起来,反复出现

iphone - 设置 UIButton 实例突出显示

iphone - 无论如何可以从应用程序内设置 settings.bundle 中的值

iphone - 每次从同一 View 加载应用程序

iPhone - 未找到以下 -L

ios - 集成 Facebook 以从 iPhone 应用程序发布内容

ios - 如何在ios中针对不同尺寸类别使用相同的Outlet?

iphone - 反转变换比例