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文件中添加 #import3,警告: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.即可。

uiview

1,  错误信息:  "_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)解决方法: 查看工程,看是不是没有导入相关的框架。或者工程里添加的有相同".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 declaratorNSString *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:即可

7 、 错误信息:

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

解决方法:

targets ->build setting 下的 Build Active Architecture Only 设置 NO  即可.

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中自带了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]];      }  引入函数定义的头文件#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,类型转换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 在项目中设置控件的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,就可以了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,298评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,701评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,078评论 0 237
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,687评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,018评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,410评论 1 211
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,729评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,412评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,124评论 1 239
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,379评论 2 242
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,903评论 1 257
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,268评论 2 251
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,894评论 3 233
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,014评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,770评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,435评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,312评论 2 260

推荐阅读更多精彩内容