ios Xcode 链接器错误:对于架构 x86_64 文件太小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14034048/
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 linker error: file too small for architecture x86_64
提问by tbodt
I'm developing an application in Xcode.
我正在 Xcode 中开发一个应用程序。
When I try to build, this error comes up:
当我尝试构建时,出现此错误:
ld: in /Users/theodore/Library/Developer/Xcode/DerivedData/Tower-bkpdifuqssebjdgurzmtirbxejnn/Build/Intermediates/Tower.build/Debug/Tower.build/Objects-normal/x86_64/TWRAppDelegate.o, file too small for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know what's wrong?
有谁知道出了什么问题?
回答by Peter K.
Stealing @martin-baulig's answer:
窃取@martin-baulig 的回答:
Try a full rebuild / clean. It's possible that the previous build has been abnormally aborted, leaving the TWRAppDelegate.o file corrupted or zero-size.
尝试完全重建/清理。之前的构建可能已异常中止,导致 TWRAppDelegate.o 文件损坏或大小为零。
回答by grassyburrito
I usually add a space (could be any character for that matter) to the file in question, remove it and then save. Easier and quicker than a clean build.
我通常在有问题的文件中添加一个空格(可以是任何字符),删除它然后保存。比干净的构建更容易、更快。
回答by yeyimilk
rm -rf /Users/hostname/Library/Developer/Xcode/DerivedData
rm -rf /Users/hostname/Library/Developer/Xcode/DerivedData
回答by Anton Plebanovich
To automatically fix this issue Build Script Phase
can be added. Goto Xcode -> Your Project -> Your Target -> Build Phases -> + -> New Run Script Phase
Build Script Phase
可以添加自动修复这个问题。转到 Xcode -> Your Project -> Your Target -> Build Phases -> + -> New Run Script Phase
Rename it to Xcode Link Fix
and move it above Compile Sources
phase. Paste this into script body:
将其重命名为Xcode Link Fix
并将其移动到Compile Sources
阶段之上。将其粘贴到脚本正文中:
# Legacy build system
legacy_dir=`dirname "$LD_DEPENDENCY_INFO_FILE"`
find "$legacy_dir" -size 0 | while read -d $'\n' file; do
rm "$file"
done
# New build system
find "$OBJECT_FILE_DIR_normal" -size 0 | while read -d $'\n' file; do
rm "$file"
done
This script checks for object files with zero size and removes them so when compilation is done in next step it success.
此脚本检查大小为零的目标文件并将其删除,以便在下一步中完成编译时成功。
You need to add this script for every app target if you have many.
如果您有多个应用程序目标,则需要为每个应用程序目标添加此脚本。
This script takes ~0.1 second to run and saves you from full project rebuild.
此脚本需要大约 0.1 秒才能运行,并使您免于完整的项目重建。
回答by harchi
just remove this file by run cmd in your terminal app:
只需通过在终端应用程序中运行 cmd 删除此文件:
rm /Users/theodore/Library/Developer/Xcode/DerivedData/Tower-bkpdifuqssebjdgurzmtirbxejnn/Build/Intermediates/Tower.build/Debug/Tower.build/Objects-normal/x86_64/TWRAppDelegate.o
回答by Jason Pepas
You can just delete the TWRAppDelegate.o file and continue your build. Copy the full path mentioned in the error message and paste it behind an 'rm' command in your terminal. There's no need to clean/rebuild, delete derived data, add/remove the file from the project, etc.
您可以删除 TWRAppDelegate.o 文件并继续构建。复制错误消息中提到的完整路径,并将其粘贴到终端中的“rm”命令后面。无需清理/重建、删除派生数据、从项目中添加/删除文件等。
回答by Matic Oblak
Since building a clean project may take way too long there is shorter way for those that have the access to the file that is corrupt in the cache:
由于构建一个干净的项目可能需要很长时间,因此对于那些有权访问缓存中损坏的文件的人来说,有一种更短的方法:
- Delete the file (Remove reference)
- Build project
- Reinsert file
- Build project
- 删除文件(删除参考)
- 构建项目
- 重新插入文件
- 构建项目
Full version so you have no trouble finding the file:
完整版,因此您可以轻松找到文件:
- Find the file in Xcode project navigator
- Right click the file and press "show in finder" (opens a finder at the location where the file is)
- Select the file in Xcode and press backspace then click "Remove reference"
- Build project (it will fail but wait for it to finish)
- Reinsert file by dragging it from the finder into the same location you just deleted it
- Build project (should work now)
- 在 Xcode 项目导航器中找到该文件
- 右键单击文件并按“在查找器中显示”(在文件所在的位置打开查找器)
- 在 Xcode 中选择文件并按退格键,然后单击“删除引用”
- 构建项目(它会失败但等待它完成)
- 通过将文件从查找器拖动到刚刚删除它的同一位置来重新插入文件
- 构建项目(现在应该可以工作)
回答by Vadim Akhmerov
Quick way to fix error without complete cache clean:
无需完全清理缓存即可修复错误的快速方法:
- Open file described in error (in case of this question
TWRAppDelegate
) - cmd + A
- cmd + X
- Rebuild - fail
- cmd + V
- Rebuild - succeed
- 打开错误描述的文件(在此问题的情况下
TWRAppDelegate
) - CMD + A
- 指令 + X
- 重建 - 失败
- CMD + V
- 重建 - 成功
回答by tland
Step 1. Go to: Project > Build Settings > Search Paths
步骤 1. 转到:项目 > 构建设置 > 搜索路径
Step 2. Set "Always Search User Paths" to Yes
第 2 步。将“始终搜索用户路径”设置为是
Step 3. Build the project (You'll get a warning but the project will build.)
步骤 3. 构建项目(您将收到警告,但项目将构建。)
Step 4. Set "Always Search User Paths" back to No and build again to eliminate the warning
第 4 步。将“始终搜索用户路径”设置回否并再次构建以消除警告
回答by David Santiago
A clean rebuild didn′t in my case so i explain how i solved the problem:
- Removed reference to the file (don′t delete the file)
- Add the file to the project again and run
在我的情况下没有进行干净的重建,所以我解释了我是如何解决这个问题的:
- 删除了对文件的引用(不要删除文件)
- 再次将文件添加到项目中并运行