美文网首页iOS面试iOS专题
iOS常见编译错误方案总结

iOS常见编译错误方案总结

作者: 一个人在路上走下去 | 来源:发表于2016-05-28 11:04 被阅读1183次

    错误1

    warning: no rule to process file '$(PROJECT_DIR)/LoadingView.h' of type sourcecode.c.h for architecture armv6
    

    原因: Target里Compile Sources里含有头文件 了,那里面不需要头文件
    解决方法: 从Target里Compile Sources里删除头文件

    图解

    错误2

    ld: 3 duplicate symbols for architecture i386(arm7)
    

    原因:可能是您用了与SDK相同的第三方库。
    解决方法:删除引起错误的第三方法库的实现文件(.m文件)。

    错误3

    Command /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS Build System Support.xcplugin/Contents/Resources/copypng failed with exit code 1
    

    原因: png图像文件拷贝失败,看看信息上面提示Can't find哪个文件,一般都是从文件系统里删除文件而没有通过Xcode删除造成的,Xcode的项目配置文件依然纪录着这个文件的引用。

    解决办法: 给文件系统里增加相应的文件,或者从Xcode的Groups & Files删除它,或者从Target的Copy Bundle Resources里删除它。(图例如上)

    错误4

    file is universal (2 slices) but does not contain a(n) armv7s slice:…… for architecture armv7s
    

    原因:是因为此版本的库还不支持arm7s的环境。
    解决办法: 将Build Settings项中的Valid ArchiteCtures中的arm7s删除即可解决。

    添加一个.a文件到工程中,无法编译提示错误信息:

    ld: warning: ignoring file /Users/.../lib/Release-iphoneos/libPyConvertlib4Ipad.a, file was built for archive which is not the architecture being linked (armv7s): /Users/.../lib/Release-iphoneos/libPyConvertlib4Ipad.a**Undefined symbols for architecture armv7s:** , referenced from:      -[***** *****:] in *****.o
    
    ld: symbol(s) not found for architecture armv7sclang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    用lipo -info 查看.a文件:input file ******.a is not a fat fileNon-fat file: ******.a is architecture:

    原因:armv7说明.a文件只是一个armv7结构,而自己要编译的是要支持armv7和armv7s的fat file。
    解决方法:将architectures属性(包括release和debug)改为:armv7,这样可以编译过去。

    图解

    关于Build Active Architecture Only属性:
    Build Active Architecture Only设置为YES,是为了debug的时候编译速度更快,它只编译当前的architecture版本。而设置为NO时,会编译所有的版本。****一般debug的时候可以选择设置为yes,release的时候要改为no,以适应不同设备。****

    错误5

    linker command failed with exit code 1 (use -vto see invocation)
    

    原因:不能同时有两个一样的.m文件在编译,这样会报这个错误(另外:如果代码中混合有C或者C++代码,那么,也不可以在两个不同名称的mm文件中进行声明或者引用,因为也会导致这个错误的发生)。

    解决办法: 删除一个一样的.m文件。

    错误6

    Code Sign error: The identity 'iPhone Developer: Your Name' doesn't match any valid certificate/private key pair in the default keychain
    

    原因: 签名错误。
    解决办法: Target ->Build Settings -> Code Signing -> 修改签名(根据您自己的签名设置!)

    图解

    错误7

    Duplicate symbol _NN_Decode in /Users/…/libKit.a(UPRsa_nn.o)  for architecture arms7
    
    Command /Developer/…/bin/llvm-g++-4.2 failed with exit code 1
    

    原因:是因为和C++混编模式引起的。
    解决办法: 将Build Settings 设置项里面的Other Linker Flags设置成空即可。

    图解

    错误8

    XCode提示有类似C++语法的错误。
    原因:可能是您在调用接口时没有设置成OC与C++混编模式
    解决方法:将调用接口的实现文件改为.mm的后缀。(常见引入第三方库时,如百度地图等)

    错误9

     file is universal but does not contain a(n) armv6 slice for architecture armv6
    

    原因:可能是您的XCode版本过低。

    错误10

    could not create bundle folder for versioned model *.moda
    

    原因:编译一次会产生一个新的
    解决办法:应该把编译产生出来的moda文件都删了,然后clean下工程,重新build即可

    错误11

    如果在真机中进行测试时出现

    failed to get the task for process
    

    可能是证书出了问题。

    错误12

      expect a type
    

    可能出现了在.h文件中的循环引用。

    错误13

    error:Cannot assign to 'self' outside of a method in the init family
    

    原因:只能在init方法中给self赋值。Xcode判断是否为init方法规则:方法返回id,并且名字以init +大写字母开头+其他 为准则。

    - (id) initWithXXX;
    

    出错代码:

    - (id) Myinit{
     self = [super init];
     ……
    }

    相关文章

      网友评论

        本文标题:iOS常见编译错误方案总结

        本文链接:https://www.haomeiwen.com/subject/empfdttx.html