我试图用Xcode制作一个简单的Mac Objective-C应用程序,以保持两位玩家玩一个简单游戏的分数,每位玩家最多可获得36分。由于其功能有限,它不是一个非常实用的应用程序,而且主要是用于练习。我试图用一个首选项窗口来扩展应用程序,当点击一个菜单项时会弹出。Command/Developer/usr/bin/clang失败,退出代码为1
我创建了一个文件来控制男性项目,然后点击时弹出一个笔尖。所有这些工作都很好,并且会弹出一个新窗口。我将滑块,文本字段等放在笔尖上,并将它们连接到动作。所有这一切都很好。
当我试图将文件导入到根控制器,以便我可以在应用程序中使用用户的选择时出现问题。
我得到以下编译器错误:
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)
有没有理由为什么我会得到这个错误?在我正在导入的课程中,我需要做些什么?请相当详细,我是新来的语言somight不知道如何做某些事情。如果有什么我需要澄清,让我知道。编号: 这是我无法导入的文件的代码
#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
我没有任何与下划线,究竟是什么意思?下面是我无法导入的.m文件的代码:编辑:由于注释中没有换行符,我还会在问题底部发布代码。 – ObjectiveProgrammer
'#import“Preferences.h” @implementation Preferences int addScores; - (IBAction)addScoresToggled { NSLog(@“addScores was toggle。“); } - (ID)initWithWindow:(NSWindow *)窗口 { 自我= [超级initWithWindow:窗口]; 如果(个体){ } 返回自我; } - (空隙)的dealloc { [超级的dealloc];} - (无效)windowDidLoad { [超级windowDidLoad]; } @end ' – ObjectiveProgrammer
可能晚了,但“int addScore”处于静态范围。所以,如果它包含在其他地方(或者在项目中多次包含文件),则最终会出现重复。 – GtotheB