XcodeでシンプルなMac Objective-Cアプリケーションを作成しようとしました。その機能が限られているため、非常に実用的なアプリケーションではありません。私は、メニュー項目がクリックされたときにポップアップするPreferencesウィンドウでアプリケーションを少し拡張しようとしていました。終了コード1でコマンド/開発者/ usr/bin/clangに失敗しました
私はmenアイテムを制御するためのファイルを作成し、それをクリックすると、ポップアップするようにしました。これはすべて正常に動作し、新しいウィンドウがポップアップします。ペン先にスライダやテキストフィールドなどを置き、それらをアクションに関連付けました。そのすべてがうまくいきました。
問題は、アプリケーションでユーザーの選択肢を使用できるようにファイルをルートコントローラにインポートしようとしたときに発生しました。私のプロジェクトのフォローに
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
(おそらく)関連ファイル:このすべてとともに
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ファイルへのコードをheresします。編集:コメントに改行がないので、質問の最後にコードを投稿します。 – ObjectiveProgrammer
'#import" Preferences.h " @implementationプリファレンス int addScores; - (IBAction)addScoresToggled { NSLog(@ "addScoresがトグルされました。「); } - (ID)initWithWindow:(NSWindowの*)ウィンドウ { 自己= [スーパーinitWithWindow:ウィンドウ]; 場合(自己){ } 戻り自己; } - (ボイド)のdealloc {[スーパーのdealloc];} - (ボイド)がwindowDidLoad {[スーパーwindowDidLoad];} @end ' – ObjectiveProgrammer
おそらく遅くなりますが、" int addScore "は静的スコープにあります。したがって、それが他の場所(またはプロジェクトに複数回含まれているファイル)に含まれていると、重複してしまうでしょう。 – GtotheB