Xcode常見警告和錯(cuò)誤

Xcode 升級(jí)后匠题,常常遇到的遇到的警告边涕、錯(cuò)誤缔赠,解決方法從sdk3.2.5升級(jí)到sdk 7.1中間廢棄了很多的方法衍锚,還有一些邏輯關(guān)系更加嚴(yán)謹(jǐn)了。1嗤堰,警告:“xoxoxoxo”? is deprecated解決辦法:查看xoxoxoxo的這個(gè)方法的文檔戴质,替換掉這個(gè)方法即可。2踢匣,警告:Declaration of "struct sockaddr" will not be visible outside of this function解決辦法:在你的開源.m文件中添加 #import3告匠,警告:Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'

解決辦法:類型不匹配。跳到出錯(cuò)的那一行离唬,UIInterfaceOrientation強(qiáng)制轉(zhuǎn)換為UIDeviceOrientation就行了后专。

4,警告:incompatible pointer types assigning to 'MyArrayList*'from 'NSMutableArray'

解決辦法:加入強(qiáng)制轉(zhuǎn)換(MyArrayList*)

5男娄,警告:'&&' within '||'

問題出處:

if (exists && !isDirectory || !exists)………

解決辦法: if ((exists && !isDirectory) || !exists)………

6行贪,警告:Warning:The Copy Bundle Resources build phase contains this target's Info.plist file

解決辦法:將Info.plist文件移到Resources目錄下,而不要直接放在target下模闲。

7建瘫,警告:在使用ASIHttp…第三方庫(kù)的,運(yùn)行報(bào)錯(cuò)尸折。

解決辦法:看你的項(xiàng)目中是否添加CFNetwork.framework啰脚、SystemConfiguration.framework, MobileCoreServices.framework,

CoreGraphics.framework和libz.1.2.3.dylib,如果是sdk5.0以上实夹,改添加libz.1.2.5.dylib

8橄浓,警告:xxxooo,missing required architecture i386 in file

解決辦法:如果是錯(cuò)誤信息的話:Target->Build Settings->Search Paths, 刪除FrameworkSearch Paths 里面內(nèi)容就可以了亮航。

要只是一個(gè)警告的話荸实,真機(jī)調(diào)試可以過。具體解決方法待大神出現(xiàn)缴淋。

9准给,警告:

clang: error: no such file or directory: '/demo2/控件代碼/13/Recorder/Recorder_Prefix.pch'

clang: error: no input files

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1

解決辦法: 在你的主工程文件 target搜素,pch 重抖,找到Prefix Header? ? 把它后面的值露氮,都刪除,再運(yùn)行就解決了钟沛。

10畔规,警告:

“ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute

解決辦法:如果定義了ARC有效,那么必須要有所有者屬性的定義;所以代碼改成下面這樣

@property (nonatomic, strong, readonly) NSString *ss;

11恨统,警告:

io6一下的xib系統(tǒng)均沒有自動(dòng)選擇Use Autolayout叁扫, Supporting iOS 5 and below with xib of iOS 6

解決辦法:Just un-select “Use Autolayout” in the file inspector of the xib’s view and we are back to the familiar autosizing in size inspector and boom, it supports iOS 5 and below.

12三妈,警告:

Warning: Multiple build commands for output file xxx.png

解決辦法:找到項(xiàng)目里xxx.png重復(fù),刪除重復(fù)的資源陌兑。

//以下是升級(jí)到 xcode 5.0.1 之后使用遇到的警告

13沈跨,警告:

“iOS 模擬器”未能安裝此應(yīng)用程序。

解決辦法:刪除模擬器上當(dāng)前要運(yùn)行那個(gè)APP兔综,重新運(yùn)行項(xiàng)目饿凛。就ok

14,警告:

SpringBoard無(wú)法啟動(dòng)應(yīng)用程序 錯(cuò)誤:-3

解決辦法:退出模擬器软驰,重新運(yùn)行這個(gè)項(xiàng)目涧窒。

15,警告:

The server certificate failed to verify.

解決辦法:

1锭亏、打開終端(實(shí)用工具 -->終端)纠吴,在終端中輸入如下命令:

svn ls https://192.100.1.11?0/svn/xxxxxx(注意下面的url更換成你自己的url地址)

然后直接輸入 “ p ”? 確認(rèn),就可以重新連接了慧瘤。

16戴已,警告:

Bitmasking for introspection of Objective-C object pointers is strongly discouraged.

解決辦法:

某數(shù)字& 0x1的時(shí)候是代表要取最低位是否為1,改成了? if(JK_EXPECT_F(((NSUInteger)object)%2))即可锅减。

17糖儡,警告:

Implicit conversion loses integer precision: 'unsigned long' to 'CC_LONG' (aka 'unsigned int').

解決辦法:

CC_MD5(str,strlen(str), r);,改成了? ? CC_MD5(str, (CC_LONG)strlen(str), r);即可怔匣。

18握联,警告:

error: failed to launch '/private/var/mobile/Applications/xxxxx' -- failed to get the task for process 11140.

解決辦法:

重啟你的開發(fā)手機(jī)即可,還有一種可能是你的開發(fā)者證書與發(fā)布證書搞錯(cuò)了每瞒,檢查在xcode中證書是否一直 金闽。

19,警告:

error: ignoring filxxxxxx/libBaiduMobStat.a, missing required architecture x86_64 in filexxxx/libBaiduMobStat.a

解決辦法:

targets ->build setting 下的? architectures 設(shè)置為 standard architetures(armv7,armv7s)? vaild architectures 設(shè)置為armv7,armv7s剿骨。

20代芜,警告:

error: Directory not found for option '-L/Users/joryoubonxx/BaiduStatistic

解決辦法:

刪除? targets ->build setting 下的? library search path不正確的地址,如果還不行,重新添加第三庫(kù)浓利、clean ,重啟Xcode.即可挤庇。

uiview

1,? 錯(cuò)誤信息:? "_OBJC_CLASS_$? xxxxx? ", referenced from:? ? ? objc-class-ref in ViewController.old: symbol(s) not found for architecture i386clang: error: linker command failed with exit code 1 (use -v to see invocation)解決方法: 查看工程荞膘,看是不是沒有導(dǎo)入相關(guān)的框架罚随∮窆ぃ或者工程里添加的有相同".m",".h" 文件2羽资,? 錯(cuò)誤信息:Couldn't register dy.CKRiLiText with the bootstrap server. Error: unknown error code.This generally means that another instance of this process was already running or is hung in the debugger.Current language:? auto; currently objective-c解決方法: 可能是電腦內(nèi)存問題引起,重啟電腦即可解決遵班。如果重啟解決不了問題屠升,那就是你剛剛改動(dòng)的代碼引起的問題潮改。3 、 錯(cuò)誤信息:ios 5是調(diào)試正常的腹暖,ios 6真機(jī)調(diào)試的時(shí)候,出現(xiàn)如下錯(cuò)誤:ld: file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/mac4/Desktop/my desktop/My app/MyApp name 20:09:12? /MyApp name/ZBarSDK/libzbar.a for architecture armv7serror: linker command failed with exit code 1 (use -v to see invocation)解決方法:在Xcode里汇在,點(diǎn)擊相應(yīng)的Target,然后點(diǎn)Build Settings脏答,找到VALID_ARCHS糕殉,看里面的是不是arvm7s,如果不是改成arvm7s就可以了殖告。4 阿蝶、 錯(cuò)誤信息: error: receiver type 'ViewController' for instance message does not declare a method with selector 'hideSearchBar:' [4]ViewController 中沒有聲明一個(gè)方法選擇'hideSearchBar:解決方法:在ViewController .h 中聲明一下這個(gè)方法 “ hideSearchBar ”? 即可。5黄绩、 錯(cuò)誤信息:當(dāng)json從服務(wù)端請(qǐng)求時(shí)得到的字符串羡洁,如果這樣寫的話,會(huì)報(bào)錯(cuò)爽丹,';' after top level declaratorNSString *ss= @"{"recommend":"世界末日","dogname":"機(jī)器人"}";? 解決方法:就是筑煮,把? “? 替換成? \"? 即可。NSString *ss= @"{ \"recommend \": \"世界末日 \", \"dogname \": \"機(jī)器人 \"}";? 6 粤蝎、 錯(cuò)誤信息: error: Existing instance variable '_datasource' for property 'datasource' with? assign attribute must be __unsafe_unretained解決方法:? ? id_datasource; 改為? ? __unsafe_unretained id_datasource:即可

7 真仲、 錯(cuò)誤信息:

error: No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

解決方法:

targets ->build setting 下的 Build Active Architecture Only 設(shè)置 NO? 即可.

31,警告: warning: Semantic Issue: Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'BOOL' (aka 'signed char')解決辦法: 檢查 BOOL *換為BOOL就可以了诽里,檢查是不是多寫一個(gè)? *? 號(hào)袒餐。32:Jsonkit中的警告Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()object->isa 替換為 object_getClass(object)keyObject->isa 替換為 object_getClass(keyObject)(id)keys[idx]->isa 替換為 object_getClass((id)keys[idx])format specifies type 'unsigned long' but the argument has type 'nsuinteger' (aka 'unsigned int')給變量增加(unsigned long)進(jìn)行類型轉(zhuǎn)換33:md5加密(iOS SDK中自帶了CommonCryptoImplicit declaration of function 'CC_MD5' is invalid in C99[plain] view plaincopy? ? #define CC_MD5_DIGEST_LENGTH 16? ? ? +(NSString *)MD5HashForString:(NSString *)input {? ? ? ? ? const char *cStr = [input UTF8String];? ? ? ? ? unsigned char result[CC_MD5_DIGEST_LENGTH];? ? ? ? ? CC_MD5(cStr, strlen(cStr), result);? ? ? ? ? return [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",? ? ? ? ? ? ? ? ? result[0], result[1], result[2], result[3],? ? ? ? ? ? ? ? ? result[4], result[5], result[6], result[7],? ? ? ? ? ? ? ? ? result[8], result[9], result[10], result[11],? ? ? ? ? ? ? ? ? result[12], result[13], result[14], result[15]];? ? ? }? 引入函數(shù)定義的頭文件#import34:ASIDataDecompressor中的警告format specifies type? 'short' but the? argument has type 'int'在+ (NSError *)deflateErrorWithCode:(int)code 和 +(NSError *)inflateErrorWithCode:(int)code中[NSString stringWithFormat:@"Compression of data failed with code %hi",code] 中將code改為 (short)code,類型轉(zhuǎn)換35:Reachability中警告Using 'stringWithString:' with a literal is redundantstatusString = [NSString stringWithString: @"Not Reachable"]; 改為:statusString = @"Not Reachable";36.format specifies type 'id' but the argument has type 'const char *'NSCAssert(NO, @"Unhandled error encountered during SAX parse. msg is %@", msg);改為:NSCAssert(NO, @"Unhandled error encountered during SAX parse. msg is %@", [NSString stringWithUTF8String:msg]);37 Using 'stringWithString:' with a literal is redundant改為:self.locationInput.text = @"captured change";38 在項(xiàng)目中設(shè)置控件的layer屬性時(shí),會(huì)發(fā)生錯(cuò)誤,"Property 'c' cannot be found in forward class object 'CALayer *",這時(shí)需要引入? #import谤狡。

41,錯(cuò)誤

Error launching remote program: failed to get the task for process

解決方法:

把真機(jī)上的軟件灸眼,刪除,然后墓懂,clean 一下焰宣,重新運(yùn)行就可以了。

42,真機(jī)調(diào)試的時(shí)候捕仔,出現(xiàn)? [attachment=49364]? 這正常匕积,但是不識(shí)別機(jī)器的。

解決方法:

把 榜跌, [attachment=49365] 設(shè)置為以上相對(duì)應(yīng)的版本就可以了闪唆。

43,真機(jī)調(diào)試的時(shí)候,出現(xiàn)? ios Broken pipe

解決方法:

:推出xcode

:斷開機(jī)器(iphone,ipad,ipod)鏈接

:重啟iPhone在聯(lián)接xcode钓葫,就可以了悄蕾。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子帆调,更是在濱河造成了極大的恐慌奠骄,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,858評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件番刊,死亡現(xiàn)場(chǎng)離奇詭異含鳞,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)芹务,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門蝉绷,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人枣抱,你說我怎么就攤上這事潜必。” “怎么了沃但?”我有些...
    開封第一講書人閱讀 165,282評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵磁滚,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我宵晚,道長(zhǎng)垂攘,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,842評(píng)論 1 295
  • 正文 為了忘掉前任淤刃,我火速辦了婚禮晒他,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘逸贾。我一直安慰自己陨仅,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,857評(píng)論 6 392
  • 文/花漫 我一把揭開白布铝侵。 她就那樣靜靜地躺著灼伤,像睡著了一般。 火紅的嫁衣襯著肌膚如雪咪鲜。 梳的紋絲不亂的頭發(fā)上狐赡,一...
    開封第一講書人閱讀 51,679評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音疟丙,去河邊找鬼颖侄。 笑死,一個(gè)胖子當(dāng)著我的面吹牛享郊,可吹牛的內(nèi)容都是我干的览祖。 我是一名探鬼主播,決...
    沈念sama閱讀 40,406評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼炊琉,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼展蒂!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,311評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤玄货,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后悼泌,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體松捉,經(jīng)...
    沈念sama閱讀 45,767評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評(píng)論 3 336
  • 正文 我和宋清朗相戀三年馆里,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了隘世。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,090評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡鸠踪,死狀恐怖丙者,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情营密,我是刑警寧澤械媒,帶...
    沈念sama閱讀 35,785評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站评汰,受9級(jí)特大地震影響纷捞,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜被去,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,420評(píng)論 3 331
  • 文/蒙蒙 一主儡、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧惨缆,春花似錦糜值、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,988評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至捣染,卻和暖如春健无,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背液斜。 一陣腳步聲響...
    開封第一講書人閱讀 33,101評(píng)論 1 271
  • 我被黑心中介騙來(lái)泰國(guó)打工累贤, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人少漆。 一個(gè)月前我還...
    沈念sama閱讀 48,298評(píng)論 3 372
  • 正文 我出身青樓臼膏,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親示损。 傳聞我的和親對(duì)象是個(gè)殘疾皇子渗磅,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,033評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容