iOS 遇到的恶心bug

1.报错显示:

clang: error: cannot specify -o when generating multiple output files

clang: error: no input files

解决:

在工程文件targets-->build phases-->compile sources找到了几个空白的文件,删除掉了之后就没有报错了,常见于多人开发

2.报错显示:

view reuse identifier in nib (goods) does not match the identifier used to register the nib (like)

解决:

原因在于cell的注册要在collectionView / tableView 添加进view之前完成,在self.view执行addSubview之前,注册好指定的cell就行了

3.报错显示

ld: 5 duplicate symbols for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation

解决:

重复导入了一些文件,在工程文件target -> build phases -> compile sources中找到提示中出现的文件,删除重复导入的.m文件,如果继续报错,删除原有的,重新导入,,常见于多人开发

4.报错显示:

read failed: the data couldn't be read because it isn't in the correct format.

解决:

国际化语言包常见错误,检查string文件, 书写key值的时候部分后面缺少分号

5.报错显示:

ld: '/Users/***/Desktop/***/Pods/AlipaySDK/alipay/AlipaySDK.framework/AlipaySDK' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture armv7

clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决:

TARGETS->Build Settings->Enable Bitcode,设置成NO

6.报错显示

Undefined symbols for architecture armv7:

"_OBJC_CLASS_$_UNUserNotificationCenter", referenced from:

objc-class-ref in libXG-SDK.a(XGPush.o)

ld: symbol(s) not found for architecture armv7

clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决:

缺少某些类库文件,referenced from前的即是提醒缺少的库,在targets中添加进去即可


7.报错描述

Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)"

服务器需要在header里面添加一些值,所以请求的时候添加数据,打印发现添加的header如下

"Accept-Language" = "zh-Hans-CN;q=1, en-CN;q=0.9, th-CN;q=0.8, ko-CN;q=0.7, zh-Hant-CN;q=0.6";

"User-Agent" = "TopTao/1.0.0 (iPod touch; iOS 9.3.5; Scale/2.00)";

"device_token" = **********;

"device_type" = ios;

token = ****************;

"user_id" = ****;

添加了deviece_token,device_type,token,user_id四个,打印发现其中只有token这个key没有双引号,原因我也还没找出来,服务器那边接收数据发现只能识别到token,iOS这边有问题,安卓没事,iOS用原生和第三方打印出来都是一样的状况

解决方法:

目前的解决方法是服务器做更改,服务器使用的框架对header的解析都是不一样的,在公司里服务端用的是express,改成restify可以识别出来,或者客户端的header的key值使用驼峰命名法,如device_type改成deviceType

8.报错描述:

Cannot synthesize weak property because the current deployment target does not support weak references

解决方法:

1、项目->TARGETS->IOS->Build Settings->Apple LLVM 7,1 - Language - Objective C->WeakReferences inManual Retain Release改为YES

2、如果不行,尝试在podfile文件底下加入下面的代码,'8.0'是对应的部署目标(deployment target) 

post_installdo|installer|

        installer.pods_project.targets.eachdo|target|

                  target.build_configurations.eachdo|config|  

                            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] ='8.0'

                  end

         end

end

原文链接:https://stackoverflow.com/questions/37160688/set-deployment-target-for-cocoapodss-pod

9.报错描述:

/Users/xiao/Library/Developer/Xcode/DerivedData/****-*****/Build/Products/Debug-iphoneos/*****.app: errSecInternalComponent

Command /usr/bin/codesign failed with exit code 1

具体描述

解决方法:签名机制问题,重启电脑

10.报错描述:

cocoaPod 执行 pod init 出现错误:

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

```

/usr/local/bin/pod init

```

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

```

   CocoaPods : 1.3.1

        Ruby : ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]

    RubyGems : 2.6.14

        Host : Mac OS X 10.13.5 (17F77)

       Xcode : 9.4.1 (9F2000)

         Git : git version 2.15.2 (Apple Git-101.1)

Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib

Repositories : master - https://github.com/CocoaPods/Specs.git @ d7d26ef24b15e34a73767ce5712d03584de52516

```

### Plugins

```

cocoapods-deintegrate : 1.0.1

cocoapods-plugins    : 1.0.0

cocoapods-search      : 1.0.0

cocoapods-stats      : 1.0.0

cocoapods-trunk      : 1.3.0

cocoapods-try        : 1.1.0

```

### Error

```

RuntimeError - [Xcodeproj] Unknown object version.

/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.2/lib/xcodeproj/project.rb:217:in `initialize_from_file'

/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.2/lib/xcodeproj/project.rb:102:in `open'

/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/lib/cocoapods/command/init.rb:41:in `validate!'

/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:333:in `run'

/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:in `run'

/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.3.1/bin/pod:55:in `'

/usr/local/bin/pod:23:in `load'

/usr/local/bin/pod:23:in `'

```

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

解决方法:

打开项目,修改 xcodeproj 文件 Project Format   为Xcode 8.0-compatible,然后执行pod init即可成功



11.报错描述:

UICollectionView执行reloadData前,更新布局模式,代码如下:

strongSelf.contacCollectionView.collectionViewLayout = strongSelf.flowLayout;

执行此代码时崩溃,崩溃信息为:

Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

该错误提示一般时访问了僵尸对象(对象已释放)

解决方法:

调试时一直打印对象,发现都还有值,还不懂是什么造成的,最后更改代码后不会崩溃:

strongSelf.contacCollectionView.collectionViewLayout = (UICollectionViewFlowLayout*)strongSelf.contacCollectionView.collectionViewLayout;


12.报错描述:

reason: 'section footer height must not be negative - provided height for section 0 is -0.000001'

原因:

设置UITableView的estimatedSectionFooterHeight时,设置为0.000001,在iOS8,iOS9和iOS10时,应不小于0

解决:

tableView.estimatedSectionFooterHeight = [UIDevice currentDevice].systemVersion.doubleValue < 11.0 ? 0 : 0.000001;


13.报错描述:

ld: warning: ignoring file /Users/... missing required architecture arm64 in file /Users/...

原因:

当前使用的framework或者静态库不支持64位处理器

解决:

在Build Settings中的 Valid Architectures 中删除arm64


14.错误显示:

横屏下使用popoverPresentationController显示出问题,自屏幕中间往下拉伸,竖屏时无问题

原因:

代理方法没有实现完整

解决:

应同时实现一下两个方法:

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {

    return UIModalPresentationNone;

}

//此方法不实现横屏下会出错

- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection{

    return UIModalPresentationNone;

}

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

推荐阅读更多精彩内容

  • 前言 2000年,伊利诺伊大学厄巴纳-香槟分校(University of Illinois at Urbana-...
    星光社的戴铭阅读 15,836评论 8 180
  • 很可能你的应用是与一个支持HTTPS传输数据的服务器交互,但是并没有使用TLS 1.2或更高。在这种情况下,你定义...
    Www刘阅读 3,033评论 0 5
  • 如果一个元素被加了浮动,那么它的层级高于普通元素 以上代码在一个加了浮动的div后面跟一个普通的div,在浏览器中...
    李凯强阅读 505评论 1 3
  • 你好,我是2010届大学生,我叫马永涛,来自陕西,毕业于XA大学HX专业,目前在LS集团(上市公司)技术部工作。 ...
    仲虺阅读 568评论 0 1
  • 许久未曾联系的客户突然发来几条微信,我打开来看竟然是前任公司的年会现场照片,还加了一句:“很想念你,可惜你不在...
    殷佩阅读 1,153评论 0 0