今天在Xcode4开发编译的时候遇到一些错误,上网一查看到有好多人都遇到相同的错误,所以拿出来分享下:
错误1:
ignoring file /Users/hongyufang/SVNDemo/SVNDemo/Libs/libopenssl.a, file was built for archive which is not the architecture being linked (x86_64): /Users/hongyufang/SVNDemo/SVNDemo/Libs/libopenssl.a
这说明你这个工程链接静态库libopenssl.a的时候,工程的Architectures设置不对,可在Build Settings -> Architectures 设置为Standard(32/64 -bit Intel)。
错误2:
duplicate symbol _main in:
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-8CDEF0688F8FF878.o
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-CA858FE46BE3346A.o
duplicate symbol _main in:
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-8CDEF0688F8FF878.o
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-E9176508EEFC0477.o
duplicate symbol _main in:
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-8CDEF0688F8FF878.o
/Users/hongyufang/Library/Developer/Xcode/DerivedData/SVNDemo-czyknsriatcctnhcmkteuhbmejfv/Build/Intermediates/SVNDemo.build/Debug/SVNDemo.build/Objects-normal/i386/main-5AE1FBC181031568.o
ld: 3 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这个说明你这个工程里面有3个相同的函数名main
错误3:
NSString *svnhelperPath = [bundle pathForResource:@"svnhelper" ofType:nil];
这个svnhelperPath 一直为nil,上网查了一下,有这么几种原因:
1.你在创建targets的时候,创建了Command Line Tool类型,那么对不起,[NSBund pathForResource:]取不出来的。
但是我一定要用Command Line Tool类型呢,也不是没有办法,你可以在选中你的主工程targets(Application)类型 ->Build Phases -> Cope Bundle Resources
点击 + 把你需要的targets加进来,就ok了。
2.你在创建targets的时候,直接创建Application类型,ok。