objective-c - 命令/Developer/usr/bin/clang 失败,退出代码为 1

标签 objective-c xcode compiler-errors

我试图用 Xcode 制作一个简单的 Mac Objective-C 应用程序来记录两个玩简单游戏的玩家的分数,每个玩家最多 36 个分数。它不是一个非常实用的应用程序,因为它的功能有限,主要用于练习。我试图使用首选项窗口稍微扩展应用程序,单击菜单项时会弹出​​该窗口。

我创建了一个文件来控制 men 项目,然后在单击它时弹出一个 Nib 。所有这些工作正常,并且会弹出一个新窗口。我将 slider 、文本字段等放在 Nib 上,并将它们连接到 Action 。所有这些都运行良好。

当我试图将文件导入我的根 Controller 以便我可以在应用程序中使用用户的选择时,问题出现了。

我得到以下编译器错误:

Command /Developer/usr/bin/clang failed with exit code 1

连同所有这些:

Ld "/Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Products/Debug/SimpleScoreKeeper Mac.app/Contents/MacOS/SimpleScoreKeeper Mac" normal x86_64 cd "/Users/myusername/Dropbox/iphone app/SimpleScoreKeeper Mac" setenv MACOSX_DEPLOYMENT_TARGET 10.6 /Developer/usr/bin/clang -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -L/Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Products/Debug -F/Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Products/Debug -filelist "/Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Intermediates/SimpleScoreKeeper Mac.build/Debug/SimpleScoreKeeper Mac.build/Objects-normal/x86_64/SimpleScoreKeeper Mac.LinkFileList" -mmacosx-version-min=10.6 -framework Cocoa -o "/Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Products/Debug/SimpleScoreKeeper Mac.app/Contents/MacOS/SimpleScoreKeeper Mac"

ld: duplicate symbol _addScores in /Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Intermediates/SimpleScoreKeeper Mac.build/Debug/SimpleScoreKeeper Mac.build/Objects-normal/x86_64/Prefrences.o and /Users/myusername/Library/Developer/Xcode/DerivedData/SimpleScoreKeeper_Mac-bjvjeiybvmwfjpfilvnpezarwkml/Build/Intermediates/SimpleScoreKeeper Mac.build/Debug/SimpleScoreKeeper Mac.build/Objects-normal/x86_64/RootController.o for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Command /Developer/usr/bin/clang failed with exit code 1

我项目中的(可能)相关文件如下。

RootController.h - All the interface declarations for stuff in the MainMenu.xib window
RootController.m - Where I need to import the files to
MainMenu.xib - The nib owned by the RootController class
Preferences.h - A file I'd want to import, but it won't work.
Preferences.m - A file I'd (maybe) want to import, but it won't work.
Preferences.xib - The nib owned by the Preferences class.
PreferencesMenuController.h - Where I declare the clickPreferences action. (Liked to MainMenu.xib)
PreferencesMenuController.m - Where I say that clickPreferences opens up Preferences nib.  (Linked to MainMenu.xib)

我会收到此错误的原因是什么?我正在导入的类(class)中需要做些什么吗?请非常详细,我是该语言的新手,所以可能不知道如何做某些事情。如果有什么我需要澄清的,请告诉我。

编辑: 这是我无法导入的文件的代码。

#import "Preferences.h"

@implementation Preferences

int addScores;

- (IBAction)addScoresToggled
{
    NSLog(@"addScores was toggled.");
}


- (id)initWithWindow:(NSWindow *)window
{
    self = [super initWithWindow:window];
    if (self) {

    }

    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)windowDidLoad
{
    [super windowDidLoad];
}

@end

最佳答案

如果您不小心包含了实现文件而不是头文件,您也可能会遇到此错误。例如#import "MyClass.m"而不是 #import "MyClass.h"

关于objective-c - 命令/Developer/usr/bin/clang 失败,退出代码为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6907112/

相关文章:

iphone - Objective-C : Return an array of objects from a class method

iphone - 如何告诉您的 viewController 更新并将具有更新细节的对象传递给它?

swift - 在路径 SwiftLint 中未找到 lintable 文件

iphone - 休息套件 : expected ';' after top level declarator

c++ - c++中struct的恼人问题

c++ - 从 'std::istream&'类型的表达式中获取 'int'类型的引用的无效初始化

c++ - 这些错误是什么意思? ISOC++禁止分配数组

iphone - 如何在 Core Data 中分配相关对象?

c++ - 来自纯 C++ 的 NSUserNotification

iphone - 管理 iphone 项目中的构建目标变量