iOS常见问题解决

前言

整理之前iOS开发中遇到的问题,集合一下。很大部分来自StackOverFlow。

问题1:Xcode release下调试报错[Project Name] was compiled with optimization - stepping may behave oddly; variables may not be available

解决:Build Setting中的optimization level release改为与debug一样的模式。

问题2:Xcode代码中类和方法等字体变黑文件失去关联symbol not found

解决:Xcode用得久了,代码中类和方法等字体变黑文件失去关联symbol not found,连智能提示有时候都没有,这里是因为工程索引文件被破坏导致,可通过以下方法解决:

一、Organizer -> Projects ->把所有工程中的Derived Data 删除Delete掉。

二、进入~/Library/Developer/Xcode/DerivedData 这个文件夹,把里面相关工程的文件夹删掉。

问题3:提交SVN Target没有显示出来

解决:需要勾选Autocreate schemes

问题4:property follows cocoa naming convention for returning 'owned’ objects

注意:

  • 代码中不能使用retain, release, retain, autorelease
  • 不重载dealloc(如果是释放对象内存以外的处理,是可以重载该函数的,但是不能调用[super dealloc])
  • 不能使用NSAllocateObject, NSDeallocateObject
  • 不能在C结构体中使用对象指针
  • id与void *间的如果cast时需要用特定的方法(__bridge关键字)
  • 不能使用NSAutoReleasePool、而需要@autoreleasepool块
  • 不能使用“new”开始的属性名称 (如果使用会有下面的编译错误”Property’s synthesized getter follows Cocoa naming convention for returning ‘owned’ objects”)

问题5:"No previous prototype for function" warning警告错误

解决:warning:No previous prototype for function "randomPoint"。如何取消这个警告错误呢?方法尝试了这两种都可以:

  • 1.方法上加修饰符static
  • 2.或者Project-Info -> TARGETS ->Build Settings -> LLVM GCC4.2 - Warnings组 -> Missing Function Prototypes Yes->No

问题6:Code signing is required for product type 'Application' in SDK 'iOS5.1'

解决:One possible solution which works for me:

Search "code sign" in Build settings
Change everything in code signing identity to "iOS developer", which are "Don't code sign" originally.

问题7:The common causes for "Undefined symbols for architecture armv7"

  • You import a header and do not link against the correct library. This is common, especially for headers for libraries like QuartzCore since it is not included in projects by default. To resolve:
  • Add the correct libraries in the Link Binary With Libraries section of the Build Phases.
  • If you want to add a library outside of the default search path you can include the path in the Library Search Paths value in the Build Settings and add
    -l{library_name_without_lib_and_suffix} (eg. for libz.a use -lz) to the Other Linker Flags section of Build Settings.
  • You copy files into your project but forgot to check the target to add the files to. To resolve:
  • Open the Build Phases for the correct target, expand Compile Sources and add the missing .m files. If this is your issue please upvote Cortex's answer below as well.
  • You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:
  • If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).
  • Optionally, you could create a fat static library that contains both architectures.

问题8:'_compress2', referenced from:+[UMANUtil deflatedDataPrefixedWith:level:source:] in libMobClickLibrary.a(UMANUtil.o)ld: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决:在Other Linker Flags里加入-lz

问题9:objc_msgSend()报错Too many arguments to function call ,expected 0,have3

解决:Build Setting--> Apple LLVM 6.0 - Preprocessing--> Enable Strict Checking of objc_msgSend Calls 改为 NO

问题10:dyld: Library not loaded: /System/Library/Frameworks/Social.framework/SocialReferenced from: /var/mobile/Applications/00D3E0A7-4FF6-451E-B11C-87D7A189F425/sample.app/sample Reason: image not found

解决:把Build Phases 里Social.framework后边的选项修改成为Optional就可以了

问题11:Xcode release下调试报错[Project Name] was compiled with optimization - stepping may behave oddly; variables may not be available

解决:Build Setting中的optimization level release改为与debug一样的模式。

问题12:is invalid in c99

解决: build setting -> c language dialect -> GNU89

问题13: Xcode build .c文件失败

原因:对应的.pch文件中,没有针对Objecttive-C的特殊编译,是统一指定的,建议加入,

ifdef OBJC

endif

环绕 #import ***

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,564评论 5 6
  • ios 常见问题解决 一,libxml/HTMLparser.h file not find 第一种方法: 点击左...
    rlqs阅读 3,915评论 0 1
  • 忙是最近的主旋律。 清晨4点多起床,继续完善全校的课程表安排工作。 早晨6点40出发,先送儿子去九中上学,然后一路...
    甲午之印阅读 129评论 0 0
  • 姓名:黄礼龙 公司:余姚大发化纤有限公司 2017.6.16-18上海盛和塾264期 《六项精进》学员 组号:乐观...
    黄礼龙阅读 189评论 0 0
  • 很久以前喜欢说情话,写情诗。而现在只爱静静地坐在你的身旁,不发一言也感到很美。 坚持原创,转载请务必联系本人,谢谢!
    珠海红叶原创阅读 88评论 0 1