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閱讀 230,048評論 6 542
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,414評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,169評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,722評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,465評論 6 412
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,823評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,813評論 3 446
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,000評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,554評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,295評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,513評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,035評論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,722評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,125評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,430評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,237評論 3 398
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,482評論 2 379

推薦閱讀更多精彩內容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,519評論 5 6
  • ios 常見問題解決 一,libxml/HTMLparser.h file not find 第一種方法: 點擊左...
    rlqs閱讀 3,897評論 0 1
  • 忙是最近的主旋律。 清晨4點多起床,繼續完善全校的課程表安排工作。 早晨6點40出發,先送兒子去九中上學,然后一路...
    甲午之印閱讀 122評論 0 0
  • 姓名:黃禮龍 公司:余姚大發化纖有限公司 2017.6.16-18上海盛和塾264期 《六項精進》學員 組號:樂觀...
    黃禮龍閱讀 188評論 0 0
  • 很久以前喜歡說情話,寫情詩。而現在只愛靜靜地坐在你的身旁,不發一言也感到很美。 堅持原創,轉載請務必聯系本人,謝謝!
    珠海紅葉原創閱讀 84評論 0 1