gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 03:24:58 25 4
gpt4 key购买 nike

我试图用 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/

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