简体   繁体   English

“ Apple Mach-O链接器命令失败,退出代码为1”

[英]“Apple Mach-O linker command failed with exit code 1”

I am trying to implement the SVProgressHUD activity indicator. 我正在尝试实现SVProgressHUD活动指示器。 I copied the classes to my project and added the following code to my appDelegate but can't figure out why it crashes. 我将这些类复制到我的项目中,并将以下代码添加到我的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];

}

Edit 编辑

The answer I provided (see My original answer ) only fixes the problem, but it's not the correct solution. 我提供的答案(请参阅“ 我的原始答案” )只能解决问题,但这不是正确的解决方案。 For correct solutions see Jim answer 有关正确的解决方案,请参见Jim答案

It sounds like SVProgressHUD.m isn't enabled for your target. 听起来您的目标未启用SVProgressHUD.m。 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. 在左侧窗格中的项目导航器中单击它,然后在右侧窗格中查看文件检查器,以确保要构建的目标旁边有一个勾号。

or Parth Bhatt link. 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. 稍作试验,我发现当您在项目中拖放文件或目录时,Xcode(4.3.1)要求您选择正确的选项以将这些文件或目录添加到项目中。 Make sure that that "Add to targets" option is checked. 确保已选中“添加到目标”选项。

If you have missed to check that option, you need to following these steps: 如果您错过了该选项,则需要执行以下步骤:

  1. Select YourProjectName 选择YourProjectName
  2. Select TARGETS 选择目标
  3. Select Build Phases 选择构建阶段
  4. Add .m classes in Compile Sources section 在“编译源”部分中添加.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: 现在您必须:

  1. Remove previous files (both .h and .m) 删除以前的文件(.h和.m)
  2. Click with right click in your project 在项目中单击鼠标右键
  3. Select "SVProgressHUD" dir with "Add Files to YourProjectName" (select the following check box options: Destination Copy items... and Folders Create groups for any...) 通过“将文件添加到YourProjectName”选择“ SVProgressHUD”目录(选择以下复选框选项: 目标复制项目...和文件夹为任何...创建组)

Hope it helps. 希望能帮助到你。

It sounds like SVProgressHUD.m isn't enabled for your target. 听起来您的目标未启用SVProgressHUD.m 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. 在左侧窗格中的项目导航器中单击它,然后在右侧窗格中查看文件检查器,以确保要构建的目标旁边有一个勾号。

  1. check if you have any objects that you could previously delete without knowing it 检查是否有以前不知道可以删除的对象
  2. check if your all objects are connected , for example if you have a MapView but without a connection, it crashes down 检查是否所有对象都已连接,例如,如果您有MapView但没有连接,则崩溃
  3. if this doesn't work, try with cleaning the app, or just restarting your iPhone and Xcode 如果这不起作用,请尝试清洁应用程序,或者仅重新启动iPhone和Xcode

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. 如果仍然不能解决问题,请参考上面链接中的艾伦·派克(Allen Pike)的回答。 try removing and adding back QuartzCore framework in your app. 尝试在您的应用中删除并重新添加QuartzCore框架。

Hope this helps you. 希望这对您有所帮助。

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>脚本后端从Mono2x更改为IL2CPP。

Second change was to change the Architecture to universal. 第二个更改是将体系结构更改为通用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM