iOS开发过程中常见错误问题及解决方案
错误原因:ld: x duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)


在网上查了一下:
duplicate symbol的大概意思是,编译器认为你重复定义了一些东西。
linker command failed with exit code 1,则可能是项目引入了多个相同的文件。
结合本人开发中发现此类的问题,解决办法如下:
方法1:查看有问题的文件是否有重复引用。或头文件是否加载了.m
方法2:将有问题的文件删除,重新加载进去。然后:clean->build.
在开发中解决RegexKitlLite的类似问题办法:
_rkl_NSExceptionForRegex in RegexKitLite.o "_u_strlen", referenced from: _rkl_userInfoDictionary in RegexKitLite.o "_uregex_clone", referenced from: -[RKLBlockEnumerationHelper initWithRegex:options:string:range:error:]in RegexKitLite.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status
解决办法:
在项目的编译设置中找到Other Linker Flags,然后在后面字段空白处双击,添加“-licucore”就ok了。
开发中常见问题总结:
一下内容均为个人学习使用,有不足之处请拍砖。
使用代码创建窗口,没有反应,无法进入 didFinishLaunchingWithOptions方法.
报错描述:使用代码创建窗口,没有反应,无法进入 didFinishLaunchingWithOptions方法.
报错原因:没有正确重写didFinishLaunchingWithOptions方法,或者修改错写了方法没发现
解决方案:正确重写didFinishLaunchingWithOptions方法
reason: 'couldn't find a common superview for ...UILabel:0x7f8ec05c3ab0 frame = (0 0; 0 0);
报错原因 couldn't find a common superview for ... frame = (0 0; 0 0);使用masonry前没有把对象加入父控件
解决方案:在masonry控制对象约束前把对象增加进入某控件
[self.viewaddSubview:label];
Duplicate declaration of method 错误原因:复制方法的声明(重复定义,重复声明)
duplicate symbols for architecture 错误原因:重复导入.m文件或者错误import .m文件
解决方案:删除相同的声明,定义
Application windows are expected to have a root view controller at the end of application launch'
报错原因:没有设置窗口的根控制器
解决方案:self.window.rootViewController= VC;//设置根控制器
Could not find a storyboard named 'main' in bundle NSBundle
报错原因:没有找到名称为main 的storyboard 默认是Main.storyboard
解决方案:UIStoryboard*storyboard = [UIStoryboardstoryboardWithName:@"main"bundle:nil];m改成大写
CUICatalog: Invalid asset name supplied: (null)
报错原因:Incompatible pointer types sending 'UIImage *' to parameter of type 'NSString * _Nonnull'
模型类型与视图使用模型设置数据时不匹配
解决方案: 检查模型类型,使得视图对象里使用其时一致。
错误描述 : Static table views are only valid when embedded in UITableViewController instances
错误原因 : 错误的使用了talbe View的静态cell , 静态的cell只能在 UITableViewController 的实例对象 中使用
解决方案 : 使用动态的cell ,在table View的属性content 中选择Dynamic prototypes
configureCellForDisplay:forIndexPath没有绑定Identifier
错误描述:-[UITableView _configureCellForDisplay:forIndexPath:]
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView后面一堆UITableView的属性
错误原因:没有分配,绑定cellForRowAtIndexPath方法中对象cell的ID,导致对象没有创建
解决方案:分配,绑定storyboard中tableViewCell的属性ID同创建cellID
[约束警告] Unable to simultaneously satisfy constraints. 可能有重复约束
原因:系统自动判断 代码 和 编辑器中可能有重复约束,可能会出错
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
解决方案:修改某个对象约束的优先级
setValue:forUndefinedKey:]:this class is not key value coding-compliant for the key xxxx
原因:模型的属性和plist文件不匹配
根本原因:属性缺失错误key后面的XX //找属性,数据类型,基本数据类型是不是多了*
1.找不到同名的plist数据和模型属性
改正:修改plist或模型的名称保持一致
2.模型不是指针类型的写了*号
改正:修改模型的类型或者去掉*号
原因:xib文件没有选择(链接)视图名称 导致模型给视图赋值报错e.g.shopView.shop= shop;
解决方案:修改xib的Custom Class
报错描述:Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
报错原因:没有设置指向控制器的箭头 is Inital View Controller
解决方案:属性页面 View Controller 设置is Inital View Controller为YES
变量冲突 copyWithZone unrecognized selector sent to instance
报错描述:-[UILabel copyWithZone:]: unrecognized selector sent to instance 0x7fff21746b20
报错原因 :属性和变量名冲突
解决方案:修改属性或者变量名
坏指针 使用代理方法时EXC_BAD_ACCESS
错误描述:
错误原因:写错了 让代理执行代理方法前的判断语句,写成了执行语句.
if([self.delegateperformSelector:@selector(addVC:andAdditem:)]) {
GLaddItem*additem = [GLaddItemaddItemWithName:self.nameTextF.textandNum:self.tellTextF.text];
[self.delegateaddVC:selfandAdditem:additem];
[self.navigationControllerpopViewControllerAnimated:YES];
}
解决方案:把performSelector方法改成respondsToSelector
if([self.delegaterespondsToSelector:@selector(addVC:andAdditem:)]) {
GLaddItem*additem = [GLaddItemaddItemWithName:self.nameTextF.textandNum:self.tellTextF.text];
[self.delegateaddVC:selfandAdditem:additem];
[self.navigationControllerpopViewControllerAnimated:YES];
}
坏指针 EXC_BAD_ACCESS Conflicting return type in implementation of 'addItem': ‘数据类型x' vs ‘返回值'
错误描述: Conflicting return type in implementation of 'addItem': 'GLaddItem *' vs 'void'
运行时 , 访问变量时 , 导致坏指针
错误原因: 定义的方法名和变量名重复
解决方案:修改方法名或变量名称
loaded the ’xxx’ view outlet was not set
错误描述'-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "GLEditController" nib but the view outlet was not set.'
报错原因:通过xib描述的控制器没有连续view
解决方案: 在xib中连接Owner的view
Incompatible pointer to integer conversion assigning to 'UITableViewCellSeparatorStyle' (aka 'enum UITableViewCellSeparatorStyle') from 'UISwitch *'
提示 赋值不正确,对象应该是个枚举值
isEqualToString,length 模型类,模型对象使用混乱
-[GLWine isEqualToString:]
-[GLWine length]: unrecognized selector sent to instance
错误原因:赋值了不正确的对象 模型数组里面是模型类对象,不是模型对象
解决方法:先创建模型类对象,再使用模型对象
GLWine*wine =self.wines[indexPath.row];
cell.imageView.image= [UIImageimageNamed:wine.image];
字典转模型没有值,报错[__NSCFString objectForKeyedSubscript:] [__NSCFDictionary length]
没有值:
1.控制器重写模型数组的get方法中首先没有初始化数组
_wines= [NSMutableArrayarray];没初始化添加的对象为空null
2[__NSCFString objectForKeyedSubscript:]: unrecognized selector sent to instance
[__NSCFDictionary length]: unrecognized selector sent to instance
Incompatible pointer types assigning to 'NSString *' from 'NSDictionary *'
报错原因:没有写完整字典,注意在模型对象中用字典赋值的字典书写完整性,forin一般是遍历数组,
解决方法:检查字典书写完整性,并根据数据源(plist或网络)修改
tip提示:若是字典里dict[@"cars”]字典key输入不正确,只会导致没有数据然而不会报错.
tableView代理对象没有实现方法
[ViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
0.代理对象没有声明对应的协议
Assigning to 'id _Nullable' from incompatible type 'ViewController *const __strong'self.tableView.dataSource=self;或者拖线给控制器(其他代理对象)
1.代理对象没有实现必须实现的协议方法1
Method 'tableView:numberOfRowsInSection:' in protocol 'UITableViewDataSource' not implemented
2.代理对象没有实现必须实现的协议方法2
Method 'tableView:numberOfRowsInSection:' in protocol 'UITableViewDataSource' not implemented-[ViewController tableView:numberOfRowsInSection:]
3.代理对象没有实现必须实现的协议方法3Method 'tableView:cellForRowAtIndexPath:' declared here
-[UITableView _configureCellForDisplay:forIndexPath:]
解决方法 必须实现:
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView//不实现返回1
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section
-(UITableViewCell*)tableView
写错标点
报错: Expected ‘]’ or ‘,’
原因: 1.数组连接符号用错 解决方案:需要用 , 逗号链接
2.数组最后一个元素写了连接符号 解决方案:去掉最后一个元素后的连接符号
3.Expected ‘;’ after expression 简写数组,最后没有写分号 解决方案:加上语句结束符号 ;
约束错误
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
无法同时满足的约束。
可能至少在以下列表中的约束之一是一个你不想要。
试试这个: (1) 看看每个约束和试着去弄了,你不会指望;
(2) 找到添加不必要的约束或限制的代码并修复它。
错误原因1://把A对象的底部等于B右边,对应连线找不到
make.bottom.equalTo(blueView.right);
错误原因2://同一个对象重复写了同一个约束
make.top.equalTo(blueView.top);
make.top.equalTo(blueView.bottom);
Could not load NIB in bundle with name XXX
原因reason: 'Could not load NIB in bundle: 'NSBundle 找不到要读取的nib
(loaded)' with name 'GLshopView''
解决方案:把xib的名字改成何视图类名一样
Auto property synthesis will not synthesize property 'title'; it will be implemented by its superclass, use @dynamic to acknowledge intention
错误原因:自动属性合成不会合成属性title;它将由它的超类,使用承认意图 @dynamic 执行
UILabel...title
改正:UILabel不要使用title 作为属性标识符
No visible @interface for 'NSArray<__kindof UIView *>' declares the selector ‘removeLastObject'
错误原因:NSArray是不可变数组 不能使用删除最后一个元素
解决方案:使用NSMutableArray 或者[self.shoptable.subviews.lastObjectremoveFromSuperview];
-[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
-[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]' -[__NSArrayM objectAtIndex:]: index 6 beyond bounds [0 .. 5]'
index 0 beyond bounds for empty array
错误原因:数组下标越界了
解决方案:打印检查数组的个数,并根据需要修改
unrecognized selector sent to instance
原因:调用了一个不存在的方法,方法被删掉/注释/名称修改
解决:认真检查方法名,使用正确并且存在的方法名
not key value for the key... 多余连线
原因:IBOutlet属性代码被删掉/注释了,但是属性连线还在
根本原因:属性缺失错误key后面的XX //找属性
解决:将storyboard残留的连线删掉,或在把线连上
Receiver type 'NSTextAlignment' (aka 'enum NSTextAlignment') is not an Objective-C class
错误原因 :is not an Objective-C class属性返回值是个枚举,后面写了个类调用方法
解决方案:直接写枚举值
链接:https://www.jianshu.com/p/12babc2cc406
來源:简书
异常错误补充
错误提示:Duplicate declaration of method 'awakeFromNib'
错误原因:多次重复实现awakeFromNib方法
CUICatalog: Invalid asset name supplied: '(null)'
错误原因:因为在使用的时候 [UIImage imageNamed:]时,图片不存在或者传入的图片名为nil.
错误提示:message sent to deallocated instance
错误原因:那应该是你在A里面引用了B, 导致了你释放不掉, 然后你第二次进入之后, 指针指向了B2, 所以没有指针指向B1了, 所以B1就被销毁了...
解决方案:查看控制器中是否有重复引用存在。
错误提示:FirstPage/Controller/FirstTimeUpMainPageViewController/FirstTimeUpMainPageViewController2/CYKmodel.m'
clang: error: no input files
错误原因;模型路径移动,存在缺显示找不到
解决方案:clean -> run
错误提示:*** Assertion failure in -[MASViewConstraint install], /Users/xujianfu..../Pods/Masonry/Masonry/MASViewConstraint.m:343
2018-08-24 13:51:36.795553+0800 OneOneFour[21060:907702] invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
libc++abi.dylib: terminate_handler unexpectedly threw an exception
错误原因:因为报错在MASViewConstraint,第一反应是Masonry出了问题,但项目其他用到Masonry的地方正常,明显不是Masonry的原因。
用Masonry为自定义的View添加约束,但这个自定义的View没有添加到父视图......
解决方案:在进行Masonry进行布局约束之前看是否已经添加到父视图中。
错误提示:WF: _WebFilterIsActive returning: NO
解决方案:iOS10下在UIWebView加载的页面,把UIWebView更换为WKWebView, 就能在iOS10系统正常加载该pdf链接了.(WKWebView只支持iOS8以后的系统,否则项目运行报错.),
错误提示:-[__NSCFConstantString size]: unrecognized selector sent to instance 0x106889fd0
错误代码:
[button setImage:@"down_selected" forState:UIControlStateNormal];
修改后:
[button setImage:[UIImage imageNamed:@"down_selected"] forState:UIControlStateNormal];
iOS开发过程中常见错误问题及解决方案的更多相关文章
- C# 开发过程中常见错误记录及解决说明
1.异常了类型: 1.1.1.1 异常错误信息:An error occurred while updating the entries. See the inner exception for de ...
- iOS开发过程中使用Core Data应避免的十个错误
原文出处: informit 译文出处:cocoachina Core Data是苹果针对Mac和iOS平台开发的一个框架,主要用来储存数据.对很多开发者来说,Core Data比较容易入手,但很 ...
- ios开发——错误总结篇&开发中常见错误和警告总结(四)
ios开发——开发总结&开发中常见错误和警告总结(四) 网易彩票实战总结(错误) 错误总结之类的实现 经典错误之重复定义与导入错误 经典错误关于父类的实现 通知对象: 控制器的定义 Xcode ...
- 将web项目导入到eclipse中常见错误
将web项目导入到eclipse中常见错误 错误1:string cannot be resolved to a type 原因:这种情况一般是因为你的JDK版本没有设置好,或者设置的有不一致的 ...
- iOS开发中常见的一些异常
iOS开发中常见的异常包括以下几种NSInvalidArgumentExceptionNSRangeExceptionNSGenericExceptionNSInternallnconsistency ...
- iOS项目中常见的文件
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ...
- samba配置中常见错误收集.txt
在命令行输入命令: ~$ smbclient -L \\127.0.0.1按要求输入密码后,提示出错:session setup failed: NT_STATUS_LOGON_FAILURE 这是因 ...
- python编程中常见错误
python编程培训中常见错误最后,我想谈谈使用更多python函数(数据类型.函数.模块.类等)时可能遇到的问题.由于篇幅有限,我们试图将其简化,特别是一些高级概念.有关更多详细信息,请阅读学习py ...
- Unity项目开发过程中常见的问题,你遇到过吗?
最近看到有朋友问一个unity游戏开发团队,需要掌握哪些知识之类的问题.事实上Unity引擎是一个很灵活的引擎,根据团队开发游戏类型的不同,对人员的要求也有差异,所以不能一概而论.但是,一些在Unit ...
随机推荐
- asp.net 2.0里也可以用JSON的使用方法
本人找到一份,可以在asp.net2.0里实现JSON方式传送数据的方法.但是原方法,不能在数据中带有{.}.[.]."等,所以我做特意做了转意. 全部代码如下. /// <summa ...
- (转)初步认识拓展UnityEditor编辑器定制
初步认识拓展UnityEditor编辑器定制 热度 9529 2015-9-4 18:50 |个人分类:Unity3d| 编辑器, 拓展 我相信无数初学者看别人游戏都经常看到他们的Inspector中 ...
- SlidingMenu官方实例分析6——ResponsiveUIActivity
ResponsiveUIActivity 这个类实现的是一个响应适UI设计重点是布局的设计: layout布局如下: layout-large-land布局如下: layout-xlarge布局如下: ...
- day12闭包,装饰器
一.闭包:内部函数引用了外部函数的变量. # f1() #闭包的定义 #内部的函数引用了外部函数的变量 # def f1(b): #闭包的常用状态 # def f2(): # print(b) # r ...
- uva 12730(期望经典)
选自: http://blog.csdn.net/myhelperisme/article/details/39724515 用dp(n)表示有n个位置时的期望值,那么,对于一个刚进来的人来说,他有 ...
- 次小生成树模板(poj1679)
prim #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath&g ...
- 爬虫实战【8】Selenium解析淘宝宝贝-获取多个页面
作为全民购物网站的淘宝是在学习爬虫过程中不可避免要打交道的一个网站,而是淘宝上的数据真的很多,只要我们指定关键字,将会出现成千上万条数据. 今天我们来讲一下如何从淘宝上获取某一类宝贝的信息,比如今天我 ...
- JavaScript处理数据完成左侧二级菜单的搭建
我们在项目中应用的后台管理框架基本上都是大同小异,左侧是一个二级菜单,点击选中的菜单,右侧对应的页面展示.我把前端页面封装数据的过程整理了一下,虽然不一定适合所有的管理页面,仅作为案例来参考,只是希望 ...
- Server Objects Extension(SOE)开发(二)
前言 SOE的提供了REST和Soap两种模板,只要在模板特定的方法中添加自己的业务逻辑代码即可,开发流程非常的简单便捷.那怎么知道自己的业务逻辑代码该写在模板的那个方法里面呢?这就需要很好的理解SO ...
- 洛谷 P3393 逃离僵尸岛
洛谷 这道题目其实是最短路裸题. 首先看到题目,要求的到"被占点"距离不大于S的点,自然想到了以"被占点"为源点,求一遍最短路,处理出"危险点&quo ...