Ld /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Products/Debug/OC_Language normal x86_64
cd /Users/Rubert/IOS/iworkspace/OC_Language
export MACOSX_DEPLOYMENT_TARGET=10.10
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Products/Debug -F/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Products/Debug -filelist /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/OC_Language.LinkFileList -mmacosx-version-min=10.10 -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/OC_Language_dependency_info.dat -o /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Products/Debug/OC_Language
duplicate symbol _OBJC_CLASS_$_Student in:
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/main.o
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/Student.o
duplicate symbol _OBJC_METACLASS_$_Student in:
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/main.o
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/Student.o
duplicate symbol _OBJC_IVAR_$_Student.s in:
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/main.o
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/Student.o
duplicate symbol _OBJC_IVAR_$_Student.age in:
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/main.o
/Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/Intermediates/OC_Language.build/Debug/OC_Language.build/Objects-normal/x86_64/Student.o
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
该问题主要是因为引用的头文件不对。
#import <Foundation/Foundation.h>
#import "Student.m" int main(int argc, const char * argv[]) {
@autoreleasepool {
//
//
////1.基本类型()
//NSLog(@"Hello, World!");
//DataTypes_Clazz *stu = [[DataTypes_Clazz alloc] init];
//[stu release];
//2.基本语法 //创建方式1
Student *sPo = [Student alloc];
sPo = [sPo init];
[sPo setAge:()];
NSLog(@"sPo.Age:%d",[sPo getAge]); //创建方式2
Student *sPo2 = [[Student alloc] init];
[sPo2 setAge:()];//设置值
NSLog(@"sPo2.Age:%d",[sPo2 getAge]); //创建方式3
//NSString *ns = [[NSString alloc] init];
NSString *ns2 = @""; Student *sPo3 = [[Student alloc] initWithAge:() s:(ns2)];
[sPo3 setAge:()];//设置值
NSLog(@"sPo3.Age:%d",[sPo3 getAge]);
NSLog(@"sPo3.S:%p",[sPo3 getS]); } return ;
}
应该是#import "Student.h",一不小心就犯了这个种低级错误。