链接器失败,错误代码为1

时间:2014-03-10 01:12:30

标签: ios constants

我一直收到错误Linker command failed with exit code 1,这似乎是因为我的.h-file。在我的stringsDE.h中,我定义了常量字符串。这可能是问题吗?

  

重复符号_QUESTIONCATBUTTONMIXED:       /Users/philip_air/Library/Developer/Xcode/DerivedData/juraQuiz-awgytksreajdjbdmoctjoffmzmmk/Build/Intermediates/juraQuiz.build/Debug-iphoneos/juraQuiz.build/Objects-normal/armv7/appLaunch.o       /Users/philip_air/Library/Developer/Xcode/DerivedData/juraQuiz-awgytksreajdjbdmoctjoffmzmmk/Build/Intermediates/juraQuiz.build/Debug-iphoneos/juraQuiz.build/Objects-normal/armv7/quizVC.o   ld:架构armv7的17个重复符号   clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

CODE:

http://pastebin.com/iGTVAb6K

2 个答案:

答案 0 :(得分:2)

使用以下命令在.h文件中声明所有字符串:

// QUESTIONCAT BUTTONS
extern NSString const *QUESTIONCATBUTTON1;
extern NSString const *QUESTIONCATBUTTON2;
extern NSString const *QUESTIONCATBUTTON3;
extern NSString const *QUESTIONCATBUTTONMIXED;

然后在一个.m文件中真正定义它们,如下所示:

// QUESTIONCAT BUTTONS
NSString * const QUESTIONCATBUTTON1 = @"Zivilrecht";
NSString * const QUESTIONCATBUTTON2 = @"öffentliches Recht";
NSString * const QUESTIONCATBUTTON3 = @"Strafrecht";
NSString * const QUESTIONCATBUTTONMIXED = @"Gemischt";

答案 1 :(得分:0)

我之前已经知道了#importing .m文件而不是.h。