Ld /Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Products/Debug-iphonesimulator/QuizUsingDB.app/QuizUsingDB normal i386
cd "/Users/ankit/Desktop/iOS Examples/QuizUsingDB"
export IPHONEOS_DEPLOYMENT_TARGET=6.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Products/Debug-iphonesimulator -F/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Products/Debug-iphonesimulator -filelist /Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/QuizUsingDB.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -lsqlite3 -framework UIKit -framework CoreGraphics -framework Foundation -Xlinker -dependency_info -Xlinker /Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/QuizUsingDB_dependency_info.dat -o /Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Products/Debug-iphonesimulator/QuizUsingDB.app/QuizUsingDB
duplicate symbol _flag in:
/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/MediumViewController.o
/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/SimpleQuestionViewController.o
duplicate symbol _flag in:
/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/MediumViewController.o
/Users/ankit/Library/Developer/Xcode/DerivedData/QuizUsingDB-bijvpcomctoytfblslktqvqbwaom/Build/Intermediates/QuizUsingDB.build/Debug-iphonesimulator/QuizUsingDB.build/Objects-normal/i386/HardViewController.o
ld: 2 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
答案 0 :(得分:1)
原因是您在多个文件中保持同名:flag
:MediumViewController
,SimpleQuestionViewController
和HardViewController
。
请在其中一个中重命名。
答案 1 :(得分:0)
该错误表示项目中有多个静态变量具有相同的名称。这可能会以几种不同的方式发生。
问题案例1:
.h文件1:
#import ...
int flag;
@interface
@end
.h文件2:
#import ...
int flag;
@interface
@end
然后,如果项目中包含这两个.h文件,则会有两个名为flag的全局变量。那很糟糕。
问题案例2:
你有一个.h文件,其中包含一个在多个.m文件中导入的全局变量。
·H
#import ...
int flag;
@interface
@end
.m文件1:
#import "your.h"
.m文件2:
#import "your.h"
当您导入定义它的.h文件时,这两个.m文件都会创建一个名为flag
的全局变量。
避免问题案例1的一种方法是重命名全局变量。避免问题2的一种方法是在.h文件中使用extern
修饰符,然后在.m文件中定义#import
你的.h文件中的变量。这可能是其他几个问题,但这些是我能想到的两个问题。
.h文件:
#import ...
extern int flag;
@interface
@end
.m文件
#import "your.h"
int flag
@implementation
@end
确保只在导入.h文件的.m文件中定义标志变量,否则您将再次出现重复的变量错误。