本文介绍了“Apple Mach-O链接器命令失败,退出代码为1”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现SVProgressHUD活动指示器。我将类复制到我的项目中,并将以下代码添加到我的appDelegate,但无法弄清楚它崩溃的原因。

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.

我得到他们关注错误,我不确定在哪里修复它:

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)

以下是代码:

#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];

}


推荐答案

编辑

我提供的答案(请参阅我的原始答案)仅解决了问题,但这不是正确的解决方案。要获得正确的解决方案,请参阅 Jim 回答

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

Parth Bhatt 链接。

为了完整起见

尝试一下,我发现当你在项目中拖放文件或目录时,Xcode (4.3.1)要求您选择正确的选项以将这些文件或目录添加到项目中。确保选中添加到目标选项。

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.

如果您错过了检查该选项,则需要执行以下步骤:

If you have missed to check that option, you need to following these steps:


  1. 选择YourProjectName

  2. 选择TARGETS

  3. 选择构建阶段

  4. 在编译源部分添加.m类

  1. Select YourProjectName
  2. Select TARGETS
  3. Select Build Phases
  4. Add .m classes in Compile Sources section

我的原始答案

如果您在项目中拖动这些类,则可能是问题。

If you dragged those classes in your project, it could be the problem.

为避免编译错误,请使用 将文件添加到YourProjectName而不是。

To avoid that compiling error, use "Add Files to YourProjectName" instead.

假设您的桌面中包含名为SVProgressHUD的.h和.m文件的目录。

Suppose you have a directory that contains .h and .m files called "SVProgressHUD" in your desktop.

现在你需要:


  1. 删除以前的文件(.h和.m)

  2. 在项目中单击鼠标右键单击

  3. 选择SVProgressHUD目录并选择将文件添加到YourProjectName(选择以下复选框选项:目的地复制项目。 ..和文件夹为任何...创建群组。)

  1. Remove previous files (both .h and .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...)

希望有所帮助。

这篇关于“Apple Mach-O链接器命令失败,退出代码为1”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:36