ios “Apple Mach-O 链接器命令失败,退出代码为 1”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9809477/
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
"Apple Mach-O linker command failed with exit code 1"
提问by jroyce
I am trying to implement the SVProgressHUD activity indicator. I copied the classes to my project and added the following code to my appDelegate but can't figure out why it crashes.
我正在尝试实施 SVProgressHUD 活动指标。我将这些类复制到我的项目中,并将以下代码添加到我的 appDelegate 中,但无法弄清楚它为什么会崩溃。
I get they following error and am not sure where to look to fix it:
我得到他们以下错误,但不知道在哪里修复它:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_SVProgressHUD", referenced from:
objc-class-ref in QuotesAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is the code:
这是代码:
#import "SVProgressHUD.h"
@implementation QuotesAppDelegate
- (void)startLoading
{
//call this in your app delegate instead of setting window.rootViewController to your main view controller
//you can show a UIActivityIndiocatorView here or something if you like
[SVProgressHUD show];
[self performSelectorInBackground:@selector(loadInBackground) withObject:nil];
}
- (void)loadInBackground
{
//do your loading here
//this is in the background, so don't try to access any UI elements
[self populateFromDatabase];
[SVProgressHUD dismiss];
[self performSelectorOnMainThread:@selector(finishedLoading) withObject:nil waitUntilDone:NO];
}
- (void)finishedLoading
{
//back on the main thread now, it's safe to show your view controller
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[self copyDatabaseIfNeeded];
[self startLoading];
}
回答by Lorenzo B
Edit
编辑
The answer I provided (see My original answer) only fixes the problem, but it's not the correct solution. For correct solutions see Jimanswer
我提供的答案(请参阅我的原始答案)仅解决了问题,但不是正确的解决方案。有关正确的解决方案,请参阅Jimanswer
It sounds like SVProgressHUD.m isn't enabled for your target. Click on it in the project navigator in the left-hand pane, then look in the file inspector in the right-hand pane to make sure there's a tick next to the target you are building.
听起来您的目标没有启用 SVProgressHUD.m。在左侧窗格的项目导航器中单击它,然后查看右侧窗格中的文件检查器以确保您正在构建的目标旁边有一个勾号。
or Parth Bhattlink.
或Parth Bhatt链接。
For the sake of completeness
为了完整性
Experimenting a little bit, I found that when you drag and drop file or directory within your project, Xcode (4.3.1) asks you to select the right option to add those files or dir to your project. Make sure that that "Add to targets" option is checked.
经过一些试验,我发现当您在项目中拖放文件或目录时,Xcode (4.3.1) 会要求您选择正确的选项以将这些文件或目录添加到您的项目中。确保选中“添加到目标”选项。
If you have missed to check that option, you need to following these steps:
如果您错过了检查该选项,则需要执行以下步骤:
- Select YourProjectName
- Select TARGETS
- Select Build Phases
- Add .m classes in Compile Sources section
- 选择您的项目名称
- 选择目标
- 选择构建阶段
- 在 Compile Sources 部分添加 .m 类
My original answer
我的原答案
If you dragged those classes in your project, it could be the problem.
如果您在项目中拖动这些类,则可能是问题所在。
To avoid that compiling error, use "Add Files to YourProjectName" instead.
为避免编译错误,请改用“将文件添加到 YourProjectName”。
Suppose you have a directory that contains .h and .m files called "SVProgressHUD" in your desktop.
假设您的桌面中有一个包含名为“SVProgressHUD”的 .h 和 .m 文件的目录。
Now you have to:
现在你必须:
- Remove previous files (both .h and .m)
- Click with right click in your project
- Select "SVProgressHUD" dir with "Add Files to YourProjectName" (select the following check box options: DestinationCopy items... and FoldersCreate groups for any...)
- 删除以前的文件(.h 和 .m)
- 单击鼠标右键单击您的项目
- 选择“SVProgressHUD”目录和“Add Files to YourProjectName”(选择以下复选框选项:DestinationCopy items... and FoldersCreate groups for any...)
Hope it helps.
希望能帮助到你。
回答by Jim
It sounds like SVProgressHUD.m
isn't enabled for your target. Click on it in the project navigator in the left-hand pane, then look in the file inspector in the right-hand pane to make sure there's a tick next to the target you are building.
听起来SVProgressHUD.m
您的目标没有启用。在左侧窗格的项目导航器中单击它,然后查看右侧窗格中的文件检查器,确保您正在构建的目标旁边有一个勾号。
回答by Parth Bhatt
Checkout this link. Refer to accepted answer in this link:
结帐此链接。请参阅此链接中接受的答案:
Undefined symbols for architecture i386: _OBJC_CLASS_$_SKPSMTPMessage", referenced from: error
架构 i386 的未定义符号:_OBJC_CLASS_$_SKPSMTPMessage”,引用自:错误
If it still doesnt help then refer to Allen Pike's answer in the above link. try removing and adding back QuartzCore
framework in your app.
如果仍然没有帮助,请参考上面链接中 Allen Pike 的回答。尝试QuartzCore
在您的应用程序中删除和添加框架。
Hope this helps you.
希望这对你有帮助。
回答by dsafa
- check if you have any objects that you could previously delete without knowing it
- check if your all objects are connected , for example if you have a MapView but without a connection, it crashes down
- if this doesn't work, try with cleaning the app, or just restarting your iPhone and Xcode
- 检查您是否有任何先前可以在不知情的情况下删除的对象
- 检查您的所有对象是否已连接,例如,如果您有 MapView 但没有连接,它会崩溃
- 如果这不起作用,请尝试清理应用程序,或者只是重新启动 iPhone 和 Xcode
回答by Syed Usman Ali Gillani
I resolved this issue by changing in Player Settings in the Unity Editor.
我通过在 Unity 编辑器中更改播放器设置解决了这个问题。
menu path:PlayerSettings > OtherSettings > Scripting Backend change to IL2CPP from Mono2x.
菜单路径:PlayerSettings > OtherSettings > Scripting Backend 从 Mono2x 更改为 IL2CPP。
Second change was to change the Architecture to universal.
第二个变化是将架构更改为通用。