1. 程式人生 > >Xcode警告、錯誤解決方法總結

Xcode警告、錯誤解決方法總結

從sdk3.2.5升級到sdk 7.1中間廢棄了很多的方法,還有一些邏輯關係更加嚴謹了。
1,警告:“xoxoxoxo”  is deprecated
解決辦法:檢視xoxoxoxo的這個方法的文件,替換掉這個方法即可。

2,警告:Declaration of "struct sockaddr" will not be visible outside of this function
解決辦法:在你的開源.m檔案中新增 #import

3,警告:Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation
'

解決辦法:型別不匹配。跳到出錯的那一行,UIInterfaceOrientation強制轉換為UIDeviceOrientation就行了。

4,警告:incompatible pointer types assigning to 'MyArrayList*'from 'NSMutableArray'
解決辦法:加入強制轉換(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…第三方庫的,執行報錯。
解決辦法:看你的專案中是否新增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 
解決辦法:如果是錯誤資訊的話:
Target->Build Settings->Search Paths, 刪除FrameworkSearch Paths 裡面內容就可以了。
要只是一個警告的話,真機除錯可以過。具體解決方法待大神出現。 

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    把它後面的值,都刪除,再執行就解決了。

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系統均沒有自動選擇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 
解決辦法:找到專案裡xxx.png重複,刪除重複的資源。

//以下是升級到 xcode 5.0.1 之後使用遇到的警告
13,警告:
 “iOS 模擬器”未能安裝此應用程式。
解決辦法:刪除模擬器上當前要執行那個APP,重新執行專案。就ok

14,警告:
SpringBoard無法啟動應用程式 錯誤:-3
解決辦法:退出模擬器,重新執行這個專案。

15,警告:
The server certificate failed to verify.
解決辦法:
1、開啟終端(實用工具 -->終端),在終端中輸入如下命令:
svn ls https://192.100.1.11?0/svn/xxxxxx(注意下面的url更換成你自己的url地址)
然後直接輸入 “ p ”  確認,就可以重新連線了。

16,警告:
Bitmasking for introspection of Objective-C object pointers is strongly discouraged.
解決辦法:
某數字& 0x1的時候是代表要取最低位是否為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.
解決辦法:
    重啟你的開發手機即可,還有一種可能是你的開發者證書與釋出證書搞錯了,檢查在xcode中證書是否一直 。

遇到相關的警告,一般編譯器都會提供解決方案,所以,作為新手,我們應該看懂編譯器給我們的提示,這樣我們解決問題就會事半功倍。 1,  錯誤資訊:
"_OBJC_CLASS_$  xxxxx  ", referenced from:
      objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解決方法:
 檢視工程,看是不是沒有匯入相關的框架。或者工程裡新增的有相同".m",".h" 檔案


2,  錯誤資訊:
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

解決方法: 可能是電腦記憶體問題引起,重啟電腦即可解決。如果重啟解決不了問題,那就是你剛剛改動的程式碼引起的問題。

3 、 錯誤資訊:
ios 5是除錯正常ios 6真機除錯的時候,出現如下錯誤: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裡,點選相應的Target,然後點Build Settings,找到VALID_ARCHS,看裡面的是不是arvm7s,如果不是改成arvm7s就可以了。

4 、 錯誤資訊:
 error: receiver type 'ViewController' for instance message does not declare a method with selector 'hideSearchBar:' [4]
ViewController 中沒有宣告一個方法選擇'hideSearchBar:
解決方法:
在ViewController .h 中宣告一下這個方法 “ hideSearchBar ”  即可。

5、 錯誤資訊:當json從服務端請求時得到的字串,如果這樣寫的話,會報錯,';' after top level declarator
NSString *ss= @"{"recommend":"世界末日","
dogname":"機器人"}";  
解決方法:
就是,把   “   替換成  \"  即可。
NSString *ss= @"{ \"recommend \": \"世界末日 \", \"dogname \": \"機器人 \"}";  

6 、 錯誤資訊:
 error: Existing instance variable '_datasource' for property 'datasource' with  assign attribute must be __unsafe_unretained

解決方法:
     id _datasource; 改為     __unsafe_unretained id _datasource:即可 31警告:
warning: Semantic Issue: Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'BOOL' (aka 'signed char')

解決辦法: 檢查 BOOL *換為BOOL就可以了,檢查是不是多寫一個   *  號。


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)進行型別轉換


33:md5加密(iOS SDK中自帶了CommonCrypto

Implicit 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: @"xxxxxxxxxxxxxxxx",  
                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]];  
    }  

引入函式定義的標頭檔案

#import


34: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,型別轉換


35:Reachability中警告

Using 'stringWithString:' with a literal is redundant

statusString = [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 在專案中設定控制元件的layer屬性時,會發生錯誤,
"Property 'c' cannot be found in forward class object 'CALayer *",


這時需要引入  #import 。 41,錯誤

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

解決方法:
把真機上的軟體,刪除,然後,clean 一下,重新執行就可以了。


42,真機除錯的時候,出現   [attachment=49364]   這正常,但是不識別機器的。

解決方法:

把 , [attachment=49365] 設定為以上相對應的版本就可以了。

43,真機除錯的時候,出現   ios Broken pipe

解決方法:
:推出xcode
:斷開機器(iphone,ipad,ipod)連結
:重啟iPhone在聯接xcode,就可以了。 iOS真機除錯中出現identity(The identity 'iPhone Developer)證書不匹配的問題

提示(null) error: could not read CFBundleIdentifier from Info.plist (null)

相關推薦

Xcode警告錯誤解決方法總結

從sdk3.2.5升級到sdk 7.1中間廢棄了很多的方法,還有一些邏輯關係更加嚴謹了。1,警告:“xoxoxoxo”  is deprecated解決辦法:檢視xoxoxoxo的這個方法的文件,替換掉這個方法即可。2,警告:Declaration of "struct

Xcode 警告錯誤解決方法總結

從sdk3.2.5升級到sdk 7.1中間廢棄了很多的方法,還有一些邏輯關係更加嚴謹了。1,警告:“xoxoxoxo”  is deprecated解決辦法:檢視xoxoxoxo的這個方法的文件,替換掉這個方法即可。2,警告:Declaration of "struct sockaddr" will n

關於android studio編譯時下載更新檔案錯誤解決方法總結

最近計劃用android studio設計一個android程式,開啟後確發現編譯總是報錯,上網找了很多辦法,其中說的最多的是關於下載更新gradle的,這裡稍微提一下: android studio更新gradle常常需要翻牆,可以直接到http://services.gradle.org

級後,常常遇到的遇到的警告錯誤解決方法

1,警告:“xoxoxoxo”  is deprecated解決辦法:檢視xoxoxoxo的這個方法的文件,替換掉這個方法即可。2,警告:Declaration of "struct sockaddr" will not be visible outside of this function解決辦法:在你

[轉][Unity3D]引擎崩潰異常警告BUG與提示總結解決方法

1.U3D經常莫名奇妙崩潰。 一般是由於空異常造成的,多多檢查自己的引用是否空指標。 2.編碼切換警告提示。 警告提示:Some are Mac OS X (UNIX) and some are Windows. This might lead to incorrect line numbers in

Xcode升級後的警告錯誤解決辦法

從sdk3.2.5升級到sdk 7.1中間廢棄了很多的方法,還有一些邏輯關係更加嚴謹了。 1,警告:“xoxoxoxo”  is deprecated 解決辦法:檢視xoxoxoxo的這個方法的文件,替換掉這個方法即可。 2,警告:Declaration of "struc

Win8安裝程序出現25022503錯誤解決方法

tle .html html 安裝 出現 client aec win 下載地址 Win8安裝程序出現2502、2503錯誤解決方法 安裝 sql server 2008 Native Client 官方安裝版 出現2503錯誤; 軟件下載地址:http://www.jb5

mysql主從同步常見錯誤以及解決方法總結

前言 在發生故障切換後,經常遇到的問題就是同步報錯,資料庫很小的時候,dump完再匯入很簡單就處理好了,但線上的資料庫都150G-200G,如果用單純的這種方法,成本太高,故經過一段時間的摸索,總結了幾種處理方法。 生產環境架構圖 目前現網的架構,儲存著兩份資料,通過非同步複製做的高可用叢集,

XCode編譯時出現(dyld): Library not loaded: 錯誤解決方法

編譯時出現錯誤現象: dyld: Library not loaded: @rpath/DFULibrary.framework/DFULibrary Referenced from: /private/var/mobile/Containers/Bundle/Appl

win7 x64下安裝 KB958559 出現 0x80240037 錯誤解決方法(win7 x64 安裝VB6Media Studio 8)

想在win7 X64下執行以前的一些32位程式,比如 VB6 、Media Studio Pro 8 等好用的軟體,之前在win7 x86下還勉強能安裝執行,但是 win7 x64 下是直接連安裝都安裝不了了,以前也用虛擬機器,但是暫時沒這想法,於是查了一下,發現MS已經推出了一個用於win7的

Servlet執行原理及404500405異常原因和解決方法總結

一、Servlet執行原理 比如,在瀏覽器位址列輸入          http://ip:port/web01/hello 整個通訊流程如下圖所示: 分步解釋:          1、瀏覽器依

mysql安裝程式出現25022503錯誤解決方法

當我們在裝較大型軟體的時候總會遇到一些問題,尤其是win8或者更高window系統。最近由於換電腦需要重新安裝MySQL,好不容易下載安裝版,結果提示我不能安裝,於是我就開始了網上搜尋資料的問題,下面方法完美的解決2503的問題。 windows8以後的版本安裝msi軟體(

ros_arduino_bridge功能包集的使用錯誤解決方法總結

歡迎廣大網友批評指正,如需轉載請註明出處。 未能啟動arduino_node節點 在你使用roslaunch ros_arduino_python arduino.launch啟動該節點之後,可能會遇到下面的錯誤: ERROR: cannot

hibernate常見錯誤解決方法總結

1、org.hibernate.PropertyNotFoundException: field [cid] not found on org.sihai.shop.categorySecond.Cat

undefined reference to 錯誤解決方法總結

在編寫C++時,會遇到一類錯誤的錯。 總結起來為幾類 一、是 Linux環境錯誤  具體沒有深入研究,可以參考http://blog.csdn.net/cserchen/article/details/5503556。 二、使用codeblock這類需要自己配置路徑,要把所

Latex錯誤提示與解決方法總結

1. File ended while scanning use of \@writefile: > Runaway argument? > ! File ended while sca

總結eclipse無端報錯和專案出現不知道的錯誤-解決方法

--下列文章是個人在網上找到的資料,幫助和我一樣遇到問題的朋友們解決問題的,如有侵權的可以聯絡我刪除本篇文章哈,在下面留言我就會刪除 的,歡迎一起學習java的朋友關注我一起學習***!!-- 重要提示:            有些同學本來專案是好的或者新導下來沒問題的專

Perl中DBIDBD::mysql模組的安裝和可能出現的錯誤解決方法

使用的軟體版本 DBI-1.604.tar.gz DBD-mysql-4.006.tar.gz 建議使用以上版本搭配,否則可能連線mysql錯誤 一、DBI的安裝  wget http://www.cpan.org/modules/by-module/DBD/DBI-

bash: ./make_ext4fs: No such file or directory 錯誤解決方法

nodes tor for locks exec ++ 能夠 ipp option 一般出現該錯誤是因為應用程序是32位導致的,能夠使用file命令來查看: [email protected]/* */:~/Desktop$ file make_ext4fs

vsftpd的530 Login incorrect錯誤解決方法 vsftpd登錄錯誤

user clas log 現在 nco article oca 服務 有時 530 Login incorrect只有用匿名anonymous才可登錄,其余所有用戶都報530 Login incorrect錯 復制代碼 代碼如下: local_enable=YESwrit