Xcode 自定义 shell 脚本正在减慢编译时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20649298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode custom shell scripts are slowing down the compiling time
提问by Genhain
Testing any changes to my Xcode project has become an exercise in patience whenever I build. After all the source files have compiled, I get the following message in the activity window at the top of Xcode:
每当我构建时,测试对我的 Xcode 项目的任何更改已经成为一种耐心的练习。编译完所有源文件后,我在 Xcode 顶部的活动窗口中收到以下消息:
"Running 3 of 3 Custom Shell Scripts"
“运行 3 个自定义 Shell 脚本中的 3 个”
I have not added any of my own custom shell scripts but I am using quite a few dependencies via Cocoapods and I am using 2 frameworks for the build environment, Crashlytics and Tapstream. Crashlytics requires you add a run script in the build phases, other than that I don't know where the other ones are coming from and they appear to be the bottleneck in my build time.
我没有添加任何我自己的自定义 shell 脚本,但我通过 Cocoapods 使用了很多依赖项,并且我正在使用 2 个框架构建环境,Crashlytics 和 Tapstream。Crashlytics 要求您在构建阶段添加一个运行脚本,除此之外我不知道其他脚本来自哪里,它们似乎是我构建时间的瓶颈。
Can anyone enlighten me as to what is going on and how i possibly speed it up?
任何人都可以启发我了解正在发生的事情以及我如何加快速度?
回答by Ramsel
I can't enlighten you but I can tell you how I stopped mine from running. This also happened after installing Cocoapods. In my main project's Target
, under Build Phases
, I noticed two entries entitled Check Pods Manifest.lock
and another called Copy Pods Resources
.
我无法启发你,但我可以告诉你我是如何阻止我的跑步的。这也发生在安装 Cocoapods 之后。在我的主要项目的Target
下Build Phases
,我注意到两个条目名为Check Pods Manifest.lock
,另一个名为Copy Pods Resources
。
Under both there was an unchecked option Run script only when installing
. I checked both and at least for now my projects build and run fine without running the scripts.
在两者下都有一个未选中的选项Run script only when installing
。我检查了两者,至少现在我的项目在没有运行脚本的情况下构建和运行良好。
This is kind of a crappy answer because I can't really give you any more information, and it might not even work for your case, so hopefully someone comes along and enlightens us.
这是一个蹩脚的答案,因为我真的不能给你更多的信息,它甚至可能不适用于你的情况,所以希望有人能出现并启发我们。
POSSIBLE EXTERNAL BUNDLE ISSUES
可能的外部捆绑问题
So I just had a frustrating experience debugging an issue where a pod installed library's NSLocalized strings file weren't working. Turns out it was because I checked the option mentioned above. Pods-resources.sh
, which had the lines to install the bundle, wasn't running in debug mode. It was only running when installing - of course! Something to watch out for.
因此,我在调试 pod 安装库的 NSLocalized 字符串文件无法正常工作时遇到了令人沮丧的经历。原来是因为我检查了上面提到的选项。Pods-resources.sh
,其中有安装包的行,没有在调试模式下运行。它仅在安装时运行 - 当然!有什么需要注意的。
More info in this question:
这个问题的更多信息:
NSLocalizedStringFromTable not working in CocoaPod dependency
回答by Werner Altewischer
To fix the slow "Copy pods resources" problem I figured out a solution to only copy the resources if they haven't been copied before.
为了解决缓慢的“复制 pods 资源”问题,我想出了一个解决方案,只复制之前没有复制过的资源。
For this purpose we have to patch the *-resources.sh files that are created by cocoapods such that the copy procedure only happens if a generated file in the target directory doesn't exist (it is created upon first copy). As long as this target directory exists and includes this autogenerated file, the copy resources phase is skipped. This saves me about 30 seconds in my project (of course depends on your project size). To accomplish this do the following:
为此,我们必须修补由 cocoapods 创建的 *-resources.sh 文件,以便复制过程仅在目标目录中生成的文件不存在(它在第一次复制时创建)时发生。只要此目标目录存在并包含此自动生成的文件,就会跳过复制资源阶段。这为我的项目节省了大约 30 秒(当然取决于您的项目大小)。要完成此操作,请执行以下操作:
Create a patch file called 'copy_pod_resources_once.patch' in your project root dir with the following contents:
在您的项目根目录中创建一个名为“copy_pod_resources_once.patch”的补丁文件,内容如下:
5a6,13
> NONCE_FILE="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/copyresources-done.nonce"
> if [ -f "$NONCE_FILE" ]; then
> echo "already copied resources"
> exit 0
> else
> touch "$NONCE_FILE"
> fi
>
In the Podfile for your project add the following post install hook:
在项目的 Podfile 中添加以下安装后挂钩:
post_install do |installer_representation|
system('find "./Pods/Target Support Files" -name "*-resources.sh" | xargs -I{} patch -p0 {} -i ./copy_pod_resources_once.patch')
<other post install stuff>
end
回答by www_sq
For me, it was Crashlytics. There were some outstanding changes, as Crashlytics does auto-updating of its files. I reset/removed them and rebuilt and got past it.
对我来说,它是 Crashlytics。有一些显着的变化,因为 Crashlytics 会自动更新其文件。我重置/删除它们并重建并通过它。
So the general answer may be to check any third party components and make sure they're working properly.
所以一般的答案可能是检查任何第三方组件并确保它们正常工作。
回答by www_sq
Check your project folder name have any space.Because space creates problem in directory path like "SRCROOT".I removed spaces and project run fine.
检查您的项目文件夹名称是否有空格。因为空格会在“SRCROOT”等目录路径中产生问题。我删除了空格并且项目运行良好。
回答by jlew
I've found that this happens to me frequently. Exact cause unknown, but appears to be switching between git branches that have differences in what pods are being used. In my case simply touching the Pods-xxx-Resources.sh shell script file causes it to speed back up.
我发现这种情况经常发生在我身上。确切原因未知,但似乎正在 git 分支之间切换,这些分支在使用的 pod 方面存在差异。就我而言,只需触摸 Pods-xxx-Resources.sh shell 脚本文件即可使其加快备份速度。
回答by Randika Vishman
As Ramsel has said in this answer, https://stackoverflow.com/a/21318086/1752988I also went to Build Phases and cleared out all the possible links to PODs, after trying most of the other solutions and the three build issues shown regarding Pods were cleared out.
正如 Ramsel 在这个答案中所说的,https://stackoverflow.com/a/21318086/1752988 在尝试了大多数其他解决方案和显示的三个构建问题之后, 我还进入了构建阶段并清除了所有可能的 POD 链接关于 Pods 被清除。
But then one file which was not list under the XCode Project navigator was missing, but they were in the Downloaded Git Zip folder! Obviously, I copied it and put into the XCode project and try running it runs cleanly! :)
但是随后一个未在 XCode 项目导航器下列出的文件丢失了,但它们位于已下载的 Git Zip 文件夹中!很明显,我复制了它并放入XCode项目并尝试运行它运行干净!:)
回答by Daniel S
I had a similar issue in my project (however not using Cocoapods). It ended up being an issue with an application external to Xcode (Spritebuilder) somehow holding onto a resource within my Xcode project when it crashed. I forced the non-xcode application to close and now the issue is gone
我在我的项目中遇到了类似的问题(但没有使用 Cocoapods)。它最终成为 Xcode (Spritebuilder) 外部应用程序的一个问题,当它崩溃时以某种方式保留了我的 Xcode 项目中的资源。我强制关闭非 xcode 应用程序,现在问题消失了
回答by ninjaneer
Probably not going to work for you, but cleaning the project fixed it for me (Product -> Clean)
可能不会为你工作,但清理项目为我修复了它(产品 -> 清理)