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

来源:互联网 发布:记工时的软件 编辑:程序博客网 时间:2024/06/05 09:54
  1. 從sdk3.2.5升級到sdk 7.1中間廢棄了很多的方法,還有壹些邏輯關系更加嚴謹了。
  2. 1,警告:“xoxoxoxo”  is deprecated
  3. 解決辦法:查看xoxoxoxo的這個方法的文檔,替換掉這個方法即可。

  4. 2,警告:Declaration of "struct sockaddr" will not be visible outside of this function
  5. 解決辦法:在妳的開源.m文件中添加 #import <netinet/in.h>

  6. 3,警告:Implicit conversion from enumeration type 'UIInterfaceOrientation' to different enumeration type 'UIDeviceOrientation'
  7. 解決辦法:類型不匹配。跳到出錯的那壹行,UIInterfaceOrientation強制轉換為UIDeviceOrientation就行了。

  8. 4,警告:incompatible pointer types assigning to 'MyArrayList*'from 'NSMutableArray'
  9. 解決辦法:加入強制轉換(MyArrayList*)

  10. 5,警告:'&&' within '||'
  11. 問題出處:
  12.     if (exists && !isDirectory || !exists)………
  13.   解決辦法: if ((exists && !isDirectory) || !exists)………

  14. 6,警告:Warning:The Copy Bundle Resources build phase contains this target's Info.plist file
  15. 解決辦法:將Info.plist文件移到Resources目錄下,而不要直接放在target下。


  16. 7,警告:在使用ASIHttp…第三方庫的,運行報錯。
  17. 解決辦法:看妳的項目中是否添加CFNetwork.framework、SystemConfiguration.framework, MobileCoreServices.framework,
  18. CoreGraphics.framework和libz.1.2.3.dylib,如果是sdk5.0以上,改添加libz.1.2.5.dylib

  19. 8,警告:xxxooo,missing required architecture i386 in file
  20. 解決辦法:如果是錯誤信息的話:Target->Build Settings->Search Paths, 刪除FrameworkSearch Paths 裏面內容就可以了。
  21. 要只是壹個警告的話,真機調試可以過。具體解決方法待大神出現。

  22. 9,警告:
  23. clang: error: no such file or directory: '/demo2/控件代碼/13/Recorder/Recorder_Prefix.pch'
  24. clang: error: no input files
  25. Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
  26. 解決辦法: 在妳的主工程文件 target搜素,pch ,找到Prefix Header    把它後面的值,都刪除,再運行就解決了。

  27. 10,警告:
  28. “ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute
  29. 解決辦法:如果定義了ARC有效,那麽必須要有所有者屬性的定義;所以代碼改成下面這樣
  30. @property (nonatomic, strong, readonly) NSString *ss;

  31. 11,警告:
  32. io6壹下的xib系統均沒有自動選擇Use Autolayout, Supporting iOS 5 and below with xib of iOS 6
  33. 解 決辦法: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.

  34. 12,警告:
  35. Warning: Multiple build commands for output file xxx.png
  36. 解決辦法:找到項目裏xxx.png重復,刪除重復的資源。

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

  41. 14,警告:
  42. SpringBoard無法啟動應用程序 錯誤:-3
  43. 解決辦法:退出模擬器,重新運行這個項目。

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

  50. 16,警告:
  51. Bitmasking for introspection of Objective-C object pointers is strongly discouraged.   
  52. 解決辦法:
  53. 某數字& 0x1的時候是代表要取最低位是否為1,改成了  if(JK_EXPECT_F(((NSUInteger)object)%2))即可。

  54. 17,警告:
  55. Implicit conversion loses integer precision: 'unsigned long' to 'CC_LONG' (aka 'unsigned int').   
  56. 解決辦法:
  57.     CC_MD5(str,strlen(str), r);,改成了     CC_MD5(str, (CC_LONG)strlen(str), r);即可。

  58. 18,警告:
  59. error: failed to launch '/private/var/mobile/Applications/xxxxx' -- failed to get the task for process 11140.   
  60. 解決辦法:
  61.     重啟妳的開發手機即可,還有壹種可能是妳的開發者證書與發布證書搞錯了,檢查在xcode中證書是否壹直 。

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





  63. uiview     2012-10-10 12:17
  64. 1,  錯誤信息:
  65.   "_OBJC_CLASS_[        DISCUZ_CODE_1        ]nbsp; xxxxx  ", referenced from:
  66.       objc-class-ref in ViewController.o
  67. ld: symbol(s) not found for architecture i386
  68. clang: error: linker command failed with exit code 1 (use -v to see invocation)
  69. 解決方法:
  70. 查看工程,看是不是沒有導入相關的框架。或者工程裏添加的有相同".m",".h" 文件

  71. 2,  錯誤信息:
  72. Couldn't register dy.CKRiLiText with the bootstrap server. Error: unknown error code.
  73. This generally means that another instance of this process was already running or is hung in the debugger.Current language:  auto; currently objective-c
  74. 解決方法: 可能是電腦內存問題引起,重啟電腦即可解決。如果重啟解決不了問題,那就是妳剛剛改動的代碼引起的問題。

  75. 3 、 錯誤信息:
  76. 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)
  77. 解決方法:在Xcode裏,點擊相應的Target,然後點Build Settings,找到VALID_ARCHS,看裏面的是不是arvm7s,如果不是改成arvm7s就可以了。

  78. 4 、 錯誤信息:
  79. error: receiver type 'ViewController' for instance message does not declare a method with selector 'hideSearchBar:' [4]
  80. ViewController 中沒有聲明壹個方法選擇'hideSearchBar:
  81. 解決方法:
  82. 在ViewController .h 中聲明壹下這個方法 “ hideSearchBar ”  即可。

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

  87. 6 、 錯誤信息:
  88. error: Existing instance variable '_datasource' for property 'datasource' with  assign attribute must be __unsafe_unretained

  89. 解決方法:
  90.      id<ListViewDataSource> _datasource; 改為     __unsafe_unretained id<ListViewDataSource> _datasource:即可

  91. 湘南七少     2012-10-10 16:52
  92. 3q,先閱讀明天升級.哎界面修改壹大堆

  93. uiview     2012-10-16 15:03
  94. 31,警告:
  95. warning: Semantic Issue: Incompatible integer to pointer conversion assigning to 'BOOL *' (aka 'signed char *') from 'BOOL' (aka 'signed char')

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


  97. 32:Jsonkit中的警告

  98. Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()
  99. object->isa 替換為 object_getClass(object)
  100. keyObject->isa 替換為 object_getClass(keyObject)
  101. (id)keys[idx]->isa 替換為 object_getClass((id)keys[idx])

  102. format specifies type 'unsigned long' but the argument has type 'nsuinteger' (aka 'unsigned int')
  103. 給變量增加(unsigned long)進行類型轉換


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

  105. Implicit declaration of function 'CC_MD5' is invalid in C99

  106. [plain] view plaincopy

  107.     #define CC_MD5_DIGEST_LENGTH 16  
  108.     +(NSString *)MD5HashForString:(NSString *)input {  
  109.         const char *cStr = [input UTF8String];  
  110.         unsigned char result[CC_MD5_DIGEST_LENGTH];  
  111.         CC_MD5(cStr, strlen(cStr), result);  
  112.         return [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",  
  113.                 result[0], result[1], result[2], result[3],  
  114.                 result[4], result[5], result[6], result[7],  
  115.                 result[8], result[9], result[10], result[11],  
  116.                 result[12], result[13], result[14], result[15]];  
  117.     }  

  118. 引入函數定義的頭文件

  119. #import <CommonCrypto/CommonDigest.h>


  120. 34:ASIDataDecompressor中的警告

  121. format specifies type  'short' but the  argument has type 'int'

  122. 在+ (NSError *)deflateErrorWithCode:(int)code 和 +(NSError *)inflateErrorWithCode:(int)code中

  123. [NSString stringWithFormat:@"Compression of data failed with code %hi",code] 中

  124. 將code改為 (short)code,類型轉換


  125. 35:Reachability中警告

  126. Using 'stringWithString:' with a literal is redundant

  127. statusString = [NSString stringWithString: @"Not Reachable"];

  128. 改為:statusString = @"Not Reachable";


  129. 36.format specifies type 'id' but the argument has type 'const char *'

  130. NSCAssert(NO, @"Unhandled error encountered during SAX parse. msg is %@", msg);
  131. 改為:NSCAssert(NO, @"Unhandled error encountered during SAX parse. msg is %@", [NSString stringWithUTF8String:msg]);

  132. 37 Using 'stringWithString:' with a literal is redundant
  133. 改為:self.locationInput.text = @"captured change";


  134. 38 在項目中設置控件的layer屬性時,會發生錯誤,
  135. "Property 'c' cannot be found in forward class object 'CALayer *",

  136. 這時需要引入  #import <QuartzCore/CALayer.h>。
0 0
原创粉丝点击