我不是污王,我是坑王-iOS bug汇总
前言:
我不是污王,我是坑王,当你成为iOS开发者的一员的时候,你就要准备接受这一点,无处不在的坑,就像无处不在的污一样,我们要和他们成为好朋友,一起奋斗,并永远快乐的在一起。
问题1:
打包遇到的问题ERROR ITMS-4238: "Redundant Binary Upload. There already exists a binary upload with build version '3' for train '2.1.0'" at SoftwareAssets/PreReleaseSoftwareAsset
解决办法
改一下build就好,没打包一次需要改变一次,截图为证
```

问题2:
使用权限 [com.apple.developer.in-app-payments] 的 App 必须为[Simplified Chinese]提供隐私政策网址(URL)。如果您的 App 不使用这些权限,请将它们从您的 App 中移除并上传新的二进制文件。
解决办法:
(1),闲的蛋疼是自己害自己,导致应用审核被驳,记住demo才是王道,不要以后后期公司会加入某个功能而提前merge代码
(2),删除集成apple pay相关证书后,关闭apple pay设置开关,后会再上传apple store
问题3:
添加第三方类库造成的linker command failed with exit code 1 (use -v to see invocation)的错误调试
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_FMDatabase", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决办法:
在工作左边导航栏Target-->Build Phases-->compile Sources中,第三库库的所有.m文件都添加到里面,然后编译通过了;

添加.m文件

对于以上错误,根据网友解答我的理解是
我们在使用这些第三方类库文件时直接将其拖拽到工程之中,编译的的时候Xcode也没有自动引用,所以造成这样错误,这就需要我们手动添加。假如我们在工程中新建某个文件就不会出现这样问题;
问题4:
[app上传APP Store报错:ERROR ITMS-90086:"missing 64-bit support.]
bug描述:
**ERROR ITMS-90086:"missing 64-bit support.** beginning on february 1, 2015, new [iOS](http://lib.csdn.net/base/1) apps submitted to the app store must be include 64-bit support and be built with the ios8 SDK......

解决办法:
这是因为现在提交的app必须支持64位,
但是使用cocospod时,在Podfile文件里面加上:
post_installdo |installer| installer.project.targets.eachdo |target| target.build_configurations.eachdo |config| config.build_settings['ARCHS'] ="armv7 arm64" end end end

问题5:
iOS内存错误EXC_BAD_ACCESS的解决方法
解决办法:

问题6:
Xcode在项目更名之后,把项目转移到其他机器出现ld: file not found: /Users/macmini/Library/Developer/Xcode/DerivedData/t的问题

解决办法:
这是因为项目更改工程名导致的问题,我们需要删除TARGETS ->hrb-iOS **Tests** 文件即可

问题7:
ld: library not found for -lHMSegmentedControl
clang: error: linker command failed with exit code 1
解决办法:
1),把Build Active Architecture Only 设为Yes,截图如下

问题8:这个不是问题啦,是如何添加pch文件
Xcode6为什么干掉pch(Precompile Prefix Header)&如何添加pch文件
解决办法:
简单地看:我们在写项目的时候,大部分宏定义,头文件导入都在这里,Xcode6去掉Precompile Prefix Header的主要原因可能在于Prefix Header大大的增加了Build的时间。没有了Prefix Header之后就要通过手动@import来手动导入头文件了,在失去了编程便利性的同时也降低了Build的时间。具体原因
StackOverFlow上讨论的已经比较清晰了
[StackOverFlow:为什么xcode6没有自动创建pch文件呢?](http://stackoverflow.com/questions/24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6)
如何在Xcode6中添加pch(Precompile Prefix Header)?
1,Command+N,打开新建文件窗口:ios->other->PCH file,创建一个pch文件:“工程名-Prefix.pch”:

2,将building setting中的precompile header选项的路径添加“$(SRCROOT)/项目名称/pch文件名”(例如: )

可以了,编译一下程序,如果有错误检查一下添加的路径是否正确。
3,将Precompile Prefix Header为YES,预编译后的pch文件会被缓存起来,可以提高编译速度

问题9:
iOS开发证书及打包问题,这个问题比较蛋疼,用了蛮长的时间在网上查找才解决,下面的方法不错,保存
解决办法:
一、证书选择:
在iOS开发是经常需要打包给测试,打包需要匹配的证书(Certificates)和描述文件(Provisioning Profiles)。在工程PROJECT和TARGET的Build Srttings里Code Signing选择对应的证书和描述文件:

在Provisioning Profiles里选择描述文件,一般有三种:<喎�"http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PGltZyBzcmM9"http://www.2cto.com/uploadfile/Collfiles/20140730/20140730085845133.png" alt="\\\\\\\\\\\\\\\\\\\\\\\\\\\\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写,向上边一样,tianxiangADHoc就是线上测试环境证书,tianxiangDistribution就是发布AppStore时选择的证书,tanxiangdev就是测试环境证书。
Code Signing Identily 就是对应的证书,一般选Automatic即可,Xcode会自动帮你匹配合适的证书,但是注意PROJECT和TARGET里都需要改。
二、自动编译打包:
在选好证书和描述文件后,下边就可以打包,这里还有一个要注意,如果工程中用到DLog,提交AppStore时需要在Edit Scheme里边Archive下的Build Configuration改成release模式,这样log就不会在后台输出:

打包编译时需要选择设备,就不能再用iOS Simulator,需要选你的测试机或者如果没测试机就选择ios Device,然后在导航栏Product下选择Archive,之后Xcode就会自动打包:

打包完成后会自动弹出如下界面:

然后点击Distribution,下边会有3个选项:

第一个选项是你正式提交AppStore审核时候选择的,第二个选项是给测试打包时候选择的,第三个选项后生成一个后缀为.xcarchive的文件,然后导出ipa包的。选完第二项之后还会弹出让你选择描述文件,这时候你就可以根据需要选择dev还是ADHoc,但是需要跟之前在工程里选的证书描述文件一致:

选好后选择Export导出,然后给包一个命名选择一个保存在哪里,点击Save打包就算完成了:

后记:Xcode里已经集成Apple开发者账户功能,你只用输入开发者账号和密码他会帮你自动download证书和描述文件。

点击Xcode选择Preferences:
然后点击Accounts,输入你的Apple iD和密码,然后点击View Details里:
然后点击左下角刷新按钮,刷新完后点击Done即可,上边是证书,下边是描述文件,每次添加完新设备后,也需要在这里重

Down一下证书:

问题10:
xcode每次debug的时候,都进入汇编代码

解决办法:
Debug —>Debug Workflow —> 把always show disassembly 的勾去掉就行

问题11:
ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
//终端提示
appledeiMac:~ apple$ pod install
提示:
[!] The `GuoHongHui [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `GuoHongHui [Release]` target overrides the `LIBRARY_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods/Pods.release.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target.
解决办法:
在Bulid Settings -> Other Linker Flags 和 PODS_ROOT and LIBRARY_SEARCH_PATHS 中添加 $(inherited)
要不然编译通不过
问题12:
//pods出现问题
ld: library not found for -lPods-AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决办法:
在Bulid Settings ->

注释:每次导入出现此问题都需要调整
问题13:
//pod出现问题
/Users/apple/Library/Developer/Xcode/DerivedData/GuoHongHui-cuoamtvlplnyltahdisjznadwpqm/Build/Products/Debug-iphonesimulator/libPods-SDWebImage.a(SDWebImagePrefetcher.o)
ld: 74 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解决办法:
重复导入SDWebImage,删除多余的
问题14:
//pod警告
ld: warning: directory not found for option '-L/Users/apple/Desktop/GuoHongHui/GuoHongHui/Public/UMAnalytics_Sdk_3.5.9'
解决办法:
选择工程, 编译的 (targets)
选择 Build Settings 菜单
查找 Library Search Paths 和 Framework Search Paths, 删掉编译报warning的路径即OK
问题15:
//pod出现问题
**[ruby]** [view plain](http://blog.csdn.net/dqjyong/article/details/37958067#)[copy](http://blog.csdn.net/dqjyong/article/details/37958067#)
最新对mac 10.10的强大功能好奇,于是将系统升级到了10.10,结果发现使用pod出现了下面的问题:
**[ruby]** [view plain](http://blog.csdn.net/dqjyong/article/details/37958067#)[copy](http://blog.csdn.net/dqjyong/article/details/37958067#)
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:6:in `rescue in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:3:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj.rb:30:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods.rb:2:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:32:in `<top (required)>'
from /usr/bin/pod:23:in `load'
from /usr/bin/pod:23:in `<main>'
解决办法:
1. 打开 Xcode 6
2. 进入 Preferences
3. 点击Locations选项
4. 将 Command Line Tools 版本变成 Xcode 6.0
5. 卸载 cocoapods,在终端中输入
$ sudo gem uninstall cocoapods
6. 安装xcodeproj,在终端中输入
$ sudo gem install xcodeproj
7. 安装cocoapods,在终端中输入
$ sudo gem install cocoapods
8. 测试pod是否安装成功,在终端中输入
$ pod --version
问题16:
"_OBJC_CLASS_$_XSExecutionSummaryDetailViewController", referenced from: objc-class-ref in XSExecutionSummaryViewController.o (bug处理)
Undefined symbols for architecture i386: "_OBJC_CLASS_$_XSExecutionSummaryDetailViewController", referenced from: objc-class-ref in XSExecutionSummaryViewController.old: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
_OBJC_CLASS_$_Play", referenced from
遇到的问题:"_OBJC_CLASS_$_Play", referenced from:

解决办法:
Tagert--Build Phases -- Compile Sources 下添加对应的.m文件

问题17:
高德地图添加手势不响应
使用场景,我们公司需要做一个类似房多多点击地图 -- 查看周边配套的效果,测试后高德好像屏蔽了该手势,所以实现下面代理方法去实现
解决办法:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDidClick)];
tap.delegate = self;
[self.mapView addGestureRecognizer:tap];
//ios开发中,默认是在同一时间只能有一个手势被执行,要实现多个手势同时进行,须实现
-
(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
} -
(void)tapDidClick
{
NSLog(@"tapDidClick");
}
问题18:
tableView在没有数据的时候去掉分割线
解决办法:
self.listTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.listTableView.tableFooterView = [UIView new];
问题19:
tableView的局部刷新问题
解决办法:
//局部section刷新
NSIndexSet * nd=[[NSIndexSet alloc]initWithIndex:1];//刷新第二个section
[tview reloadSections:nd withRowAnimation:UITableViewRowAnimationAutomatic];
//局部cell刷新
NSIndexPath *te=[NSIndexPath indexPathForRow:2 inSection:0];//刷新第一个section的第二行
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:te,nil] withRowAnimation:UITableViewRowAnimationMiddle];
问题20:
用按钮做倒计时的时候,有时候会出现btn上的数值是抖动的,如何解决
解决办法:
这个问题网上答案比较难搜索,是无意识尝试得到的结果,其实只要把 按钮的类型设置为 UIButtonTypeCustom ,即可
问题21:
在界面上滚动一个scrollview,那么我们会发现在停止滚动前,控制台不会有任何输出,就好像scrollView在滚动的时候将timer暂停了一样
解决办法:
解析:
在查看相应文档后发现,这其实就是runloop的mode在做怪。runloop可以理解为cocoa下的一种消息循环机制,用来处理各种消息事件,我们在开发的时候并不需要手动去创建一个runloop,因为框架为我们创建了一个默认的runloop,通过[NSRunloop currentRunloop]我们可以得到一个当前线程下面对应的runloop对象,不过我们需要注意的是不同的runloop之间消息的通知方式。
接着上面的话题,在开启一个NSTimer实质上是在当前的runloop中注册了一个新的事件源,而当scrollView滚动的时候,当前的MainRunLoop是处于UITrackingRunLoopMode的模式下,在这个模式下,是不会处理NSDefaultRunLoopMode的消息(因为RunLoop Mode不一样),要想在scrollView滚动的同时也接受其它runloop的消息,我们需要改变两者之间的runloopmode.
代码:
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
问题22:
连接SSH报错REMOTE HOST IDENTIFICATION HAS CHANGED
错误样式
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host isda:f7:3e:ba:f7:00:e6:44:76:f2:58:6e:48:******.
Please contact your system administrator.Add correct host key in /用户home目录/.ssh/known_hosts to get rid of this message.
Offending RSA key in /用户home目录/.ssh/known_hosts:1RSA host key for ip地址 has changed and you have requested strict checking.Host key verification failed.
解决办法:
- cd ~/.ssh
- ssh-keygen -R git.corp.com
- ssh-keygen -l -f ~/.ssh/known_hosts
问题23:
对一个已经释放的对象进行release操作,造成的内存错误EXC_BAD_ACCESS
解决办法:
通过Product->Scheme->Edit Scheme进入下面编辑页面,选中Arguments tab,增加标计位NSZombieEnabled设为YES
截图如下:

问题24:
兼容性问题,无法兼容iPhone5和iPhone 5c

解决办法:
将 Build Active Architectures Only 选项在Debug模式都设成YES,Release模式都设成NO。
截图如下:

问题汇总还在继续,我们还在努力啊,我不是污王,我是坑王。
PS:来简书混,关注是必须的,点赞❤️ 是要给的!