gpt4 book ai didi

iphone - "Apple Mach-O linker command failed with exit code 1"

转载 作者:技术小花猫 更新时间:2023-10-29 11:15:20 24 4
gpt4 key购买 nike

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

我发现他们出现以下错误,但我不确定去哪里修复它:

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 答案

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.

Parth Bhatt链接。

为了完整性

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

如果您错过了勾选该选项,您需要按照以下步骤操作:

  1. 选择您的项目名称
  2. 选择目标
  3. 选择构建阶段
  4. 在 Compile Sources 部分添加 .m 类

我原来的回答

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

为避免该编译错误,请改用“将文件添加到您的项目名称”。

假设您的桌面上有一个目录,其中包含名为“SVProgressHUD”的 .h 和 .m 文件。

现在你必须:

  1. 删除以前的文件(.h 和 .m)
  2. 在您的项目中单击鼠标右键
  3. 选择“SVProgressHUD”目录和“Add Files to YourProjectName”(选择以下复选框选项:Destination Copy items... and Folders Create groups for any。 ..)

希望对您有所帮助。

关于iphone - "Apple Mach-O linker command failed with exit code 1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9809477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com