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 <netinet/in.h>

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中證書是否一直 。

19,警告:
error: ignoring filxxxxxx/libBaiduMobStat.a, missing required architecture x86_64 in filexxxx/libBaiduMobStat.a  
解決辦法:
    targets ->build setting 下的  architectures 設置為 standard architetures(armv7,armv7s)   vaild architectures 設置為armv7,armv7s。

20,警告:
error: Directory not found for option ‘-L/Users/joryoubonxx/BaiduStatistic   
解決辦法:
  刪除  targets ->build setting 下的  library search path不正確的地址,如果還不行,重新添加第三庫、clean ,重啟Xcode.即可。

遇到相關的警告,一般編譯器都會提供解決方案,所以,作為新手,我們應該看懂編譯器給我們的提示,這樣我們解決問題就會事半功倍。

 

 

 

處理Xcode 警告 

除了代碼中我們手動加入的

#Waring  標示 所產生的警告,我們都應該重視。下面是一些警告的處理。

 

1,方法過期,或 使用新的api  替換方案

  multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock: 

使用替代方案:

multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: 

 http://cocoadocs.org/docsets/AFNetworking/2.1.0/Classes/AFHTTPRequestSerializer.html

 

 

 2,storyboard 不支持的配置 警告

storyboard: warning: Unsupported Configuration: Plain Style unsupported in a Navigation Item

   原因是你導航欄上的按鈕使用了不支持的 style

see

 

修改 Plain 為Done   fix waring .

http://stackoverflow.com/questions/10945859/plain-style-unsupported-in-a-navigation-item-warning-with-my-customized-bar-bu

 

3,

1)storyboard: warning: Unsupported Configuration: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:.

 

大意是為了在程序中動態訪問Scene,需要給其設置一個Storyboard ID,所以給出了警告,解決方法:設置一個Storyboard ID即可. (基本上sb鍾的所有VC都需要加,才可消除警告,這里根據自己需求。但也可檢查出 sb里面無用的VC,可以干掉)。

 

http://blog.csdn.net/freedom2028/article/details/8589375

 

2)storyboard: warning: Unsupported Configuration: Prototype table cells must have reuse identifiers

必須給sb 里德cell 添加重用標示。(這里看需求。)

 

3)storyboard: warning: Unsupported Configuration: Segues initiated directly from view controllers must have an identifier for use with -[UIViewController performSegueWithIdentifier:sender:]

大意:segues 沒有設置標識,雖然有連線。這種一般都可以廢棄。

 

或 重新添加標示 結合代碼。。

http://stackoverflow.com/questions/24087250/segue-identifier-error

 

4) storyboard Frame for "Table View" will be different at run time.

不全的 約束導致。謹慎修改。可能是代碼中需要。

 

http://stackoverflow.com/questions/18739572/xcode-5-layout-errors-misplaced-view-frame-for-label-will-be-different-at-runt

 

5) storyboard: warning: Ambiguous Layout: Size and vertical position are ambiguous for "Add Address View".

 

同上 ,默林兩顆的 約束,解放方案同上。

 

 

4,storyboard: warning: Ambiguous Layout: Horizontal position is ambiguous for "Scroll View".

自動約束 位置不明確。

 

補全。

 

 

5,Images.xcassets

1), Images.xcassets/: warning: Missing Content: The file "credit_card_light.png" for the image set "credit_card_light" does not exist.

 

credit_card_light.png 不存在。

 

but, 明明存在。

 

show finder 。

 

 

 

文本編輯,Contents.json .對比其他正常的。

 

刪掉上面的

 

      "filename" : "credit_card_light.png"

   

 

fix done.

 

2), Images.xcassets: An iPhone Retina (4-inch) launch image for iOS 7.0 and later is required.

   暫沒有處理,解放方案 參考

http://stackoverflow.com/questions/19732975/adding-ios-7-version-of-iphone-4-inch-launch-image-to-project-breaks-launch-imag

 

 

6,Apple Mach-O Linker Warning

 1)、Directory not found for option “ –L path”

嘗試項目(目標) - > 構建設置 - > search  path

 

and clear it。

http://stackoverflow.com/questions/16644982/apple-mach-o-linker-warning-directory-not-found

 

2)、Apple Mach-O linker Warning: lgnoring file …

 

 

 

http://stackoverflow.com/questions/10535678/apple-mach-o-linker-warning

 

 

 

3), dsymutil warning (armv7) …… .o  unable to open object file

 

 

DWARF with dSYM file

設置為 DWARF

fix done.  這種辦法會再 發布是報錯。**********************

 

http://bribser.co.jp/blog/unity-xcode-dsymutil-error-warning/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM