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;
}