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 ***

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,088评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,715评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,361评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,099评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 60,987评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,063评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,486评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,175评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,440评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,518评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,305评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,190评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,550评论 3 298
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,880评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,152评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,451评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,637评论 2 335

推荐阅读更多精彩内容

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