您的位置:首页 > 移动开发 > IOS开发

记录开发中遇到的坑或者Bug<持续更新...>

2017-01-13 22:29 821 查看

错误一:

diff: /../Podfile.lock: No such file or directory
diff: /Manifest.lock: No such file or directory
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.


可能复现的场景:

github或者git.OSChina下载使用到CocoaPods的Demo,有的时候因为依赖关系或者版本问题不能编译运行。

解决方案:

1>关闭当前的工作空间,删除掉文件夹中的workspace,

2>终端 cd 到工程文件夹 –> 先执行pod setup –> 再执行pod install 即可

错误二:

Analyzing dependencies
[!] The dependency `SDWebImage (~> 3.6)` is not used in any concrete target.
The dependency `TTTAttributedLabel` is not used in any concrete target.
The dependency `AFNetworking (~> 2.6)` is not used in any concrete target.
The dependency `MJRefresh` is not used in any concrete target.
The dependency `MBProgressHUD` is not used in any concrete target.


出现原因:

使用cocoapods的时候,podfile文件没有指定target

解决方案:

1>打开Podfile –> 指定target

2>例如下:

target 'Demo' do
pod 'SDWebImage',
pod 'TTTAttributedLabel'
pod 'AFNetworking'
pod 'MJRefresh'
pod 'MBProgressHUD'
end


错误三:

To github.com:******.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:******.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


出现原因:

GitHub远程仓库中的有文件不在本地仓库中。

解决方案:

$ git pull --rebase origin master
$ git push -u origin master


错误四:

Use of undeclared identifier 'ddLogLevel'


出现原因:

CocoaLumberjack
框架引起

解决方案:

CocoaLumberjack.h
中加入以下代码

#ifdef DEBUG
static const int ddLogLevel = DDLogLevelVerbose;
#else
static const int ddLogLevel = DDLogLevelError;
#endif
意思是在DEBUG模式下打印DDLogLevelVerbose级别日志,RELEASE模式下只打印DDLogLevelError级别日志。


错误五:

"_OBJC_CLASS_$_CompareResult", referenced from:

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

出现原因可能有很多,其中之一:

一个类中定义了同时另外一个类,比如在Class类的Class.h中又声明了类Class1

@interface Class1 : NSObject
@end


解决方案:

忘记了在Class.m中添加实现,添加以下代码即可

@implementation Class.m
@end


错误五:

警告:
warning: Deprecated: Push segues are deprecated since iOS 8.0
Modal segues are deprecated since iOS 8.0

复现场景:

使用storyboard时,界面跳转使用了Push方式,如图:



可以发现Push和Modal均已过时

解决方案:

使用Action Segue代替原来的Push和Modal方式.

错误六:

警告:
CUICatalog: Invalid asset name supplied

复现场景:

使用到UIImage的imageNamed:方法时传入的参数是@”“引起

解决方案:

传进去有值的参数即可

错误七:

崩溃
[__NSArrayI objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 2]'

复现场景:

OC或Swift数组或字典越界造成

解决方案:

判断后使用:

if (selectedIndex != NSNotFound) {
//使用selectedIndex
}


错误八:
redundant conformance of to protocol

原因:该协议已经被遵守,不需要在此
extension
后遵守,直接实现对应的协防方法即可

复现场景:

比如下面的错误,当前已经是
UITableViewController
,所以不需要写
tableView.dataSource = self
,也不用遵守协议

Redundant conformance of 'TableViewController' to protocol 'UITableViewDataSource'


解决方案:直接在
extension
里面实现协议方法即可

extension TableViewController {
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "ID");
if !(cell != nil)  {
cell = UITableViewCell(style: .default, reuseIdentifier: "ID")
}
cell?.textLabel?.text = "123"
return cell!
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bug 解决bug 记录 iOS 经验