2018年3月29日更新。要离职了,整理手边的笔记资料:
iOS运行报错:[APPNAME] WAS COMPILED WITH OPTIMIZATION....
刚升级了Xcode7之后,使用iOS9 SDK,启动app的时候一直报此错
[AppName] was compiled with optimization - stepping may behave oddly; variables may not be available.
手机上调试一启动就会出现上面那个错误,一启动就报错,然后就会闪退。([AppName]那里是我的应用的名字。)
解决方法:
把Architecture中的PlatForm指明为"IOS",而不是默认的"iphone".
795492-20150922084111615-914867190.pngUnexpected Machine Code - Your upload contains both bitcode and native machine code. When you provide bitcode, it's not necessary to include machine code as well. To reduce the size of your upload, use Xcode 7.3 or later, or any other toolchain that removes machine code.
Posting an answer myself, as it seems to be quite a popular question with nobody answering — so the issue is on the Apple side. Some people contacted Apple support and confirmed this. There is no need to recompile anything. The binary with such a warning can be submitted to the AppStore — it will pass the review successfully. I've already did it with a few apps.
Check more details here: "Unexpected Machine Code" warning from iTunes Connect
2018年3月7日更新:
审核遇到提示说使用了私有api的问题:
Guideline 2.5.1 - Performance - Software Requirements
Additionally, your app uses or references the following non-public APIs:
- “PrivateFrameworks, BulletinDistributorCompanion.framework (Reachability)”
The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.
Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account, as well as removal of all associated apps from the App Store.
Next Steps
If you are using third-party libraries, please update to the most recent version of those libraries. If you do not have access to the libraries' source, you may be able to search the compiled binary using the "strings" or "otool" command line tools. The "strings" tool can output a list of the methods that the library calls and "otool -ov" will output the Objective-C class structures and their defined methods. These tools can help you narrow down where the problematic code resides. You could also use the "nm" tool to verify if any third-party libraries are calling these APIs.
Resources
For information on the "nm" tool, please review the "nm tool" Xcode manual page.
检查了下自己的代码,发现是Apple公开的,检查网络可达性的类Reachability的加载是这样的:
Class Reach = NSClassFromString(@"Reachability");
NSObject *r = [Reach performSelector:NSSelectorFromString(@"reachabilityWithHostName:") withObject:@"www.baidu.com"];
但是工程中忘了加入这个类了。应该是运行期间试图去加载公开的reachability类,但是公开的类没有在工程中,结果勾到了私有api的同名类。
公开的Reachability: https://developer.apple.com/library/content/samplecode/Reachability/Introduction/Intro.html
2018年2月26日更新:
*** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:]1555错误
出现此错误的原因就是下面的方法里面
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
不可 alloc 你想要的view 需要通过collectionView的
dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:kProductSectionFooterIdentifier forIndexPath:indexPath
上面的文章,说的是一种情况。
我自己遇到这个情况,是n(n>=0)个section时,自定义collectionView的header和footer,n>1时有个footerView始终在最后一个section部分,其它section的header和footer各司其职。其实『Assertion failure in』很清楚的说明了情况,那就是 UICollectionReusableView *reusableview = nil;声明并初始化后,经过一系列条件判断处理后,因为自己的一些逻辑不够严谨,reusableview还是以nil返回了。
2017年8月9日更新:
bc++abi.dylib`__cxa_throw:
这两天研究视频播放,集成RTMP视频出现的异常,刚好看到一篇博客,楼主使用[AVAudioPlayer Play]时出现了异常。。。记录下来:
由于xcode中设置了当所有异常出现时的断点,,解决办法是将all改为Objective-C:
当程序运行的时候突然停在这了,就是出现了c++异常。这种异常可以忽略不计。解决方法
C++ libraries may throw and catch exceptions internally for all sorts of reasons, for example end of buffer or end of file. Whether this is an appropriate use of exceptions, good coding style or software engineering practice is debatable. As long as an exception does not make it uncaught into your code you should not worry about it.
You say that the routine returns successfully and the desired output is obtained, so nothing is wrong (i.e. it is not a bug).
这是捕捉了C++库中主动抛出的异常。
C++中异常的使用有很多场景,比如buffer见底了,文件到头了。是否是好的实践还存在争议,但是这在C++中是非常常见的。
原文
mac总提示“磁盘容量不足”,于是把之前收集的东西整理下。工作中遇到很多的问题,在解决过程中参考的很多资料存在硬盘里,整理一些,供有需要的参考查阅。都是一些比较有价值的参考资料,以下:
Could not load NIB in bundle
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/containers/Bundle/Application/240CA2AE-472E-4CE4-BFD8-E5DDF53EAF9C/Debug.app> (loaded)' with name 'Main'' First throw call stack: (0x181f12db0 0x181577f80 0x181f12cf8 0x1875473a4 0x187549b24 0x18731b608 0x1870e6638 0x18731a49c 0x187317764 0x1838b37ac 0x1838b3618 0x1838b39c8 0x181ec909c 0x181ec8b30 0x181ec6830 0x181df0c50 0x1870df94c 0x1870da088 0x1000514a4 0x18198e8b8) libc++abi.dylib: terminating with uncaught exception of type NSException
这个错场景是,在故事版做入口,与手动创建window做入口时。在设置Deployment Info中Main Interface时,设置为空。之后设置回“Main”,报这个错。
由空设置为“Main.storyboard”就可以了。
'Project Name' was compiled with optimization
工程在编译之后被优化了,所以导致单步的时候程序表现异常,变量也都不能访问了。这是由于编译的时候选择的是 release,而 release 的时候是会做很多优化,导致上述结果。
release模式调试程序,尝试查看变量的值时会遇到。改为Debug。
failed to get the task for process XXX
调试时证书设置问题,project和targets的证书都必须是开发证书,AdHoc和发布证书会出现此问题。
Xcode8及之后,让Xcode自动管理会很方便。
_BSMachError: (os/kern) invalid capability (20) _BSMachError: (os/kern) invalid name (15)
I had the same two error messages. In my case, the errors were appearing when I called [[UIApplication sharedApplication] openURL:url] after the user selected a button in an open UIAlertController. I assumed the alert was trying to close at the same time I was trying to open the URL. So, I introduced a slight delay and the error message went away.
dispatch_after(0.2, dispatch_get_main_queue(), ^{ [[UIApplication sharedApplication] openURL:url]; });
Not sure if this helps with your particular problem, but I thought it might be helpful to share.
大家遇到的场景各异,可以去stackOverFlow看看
此证书的签发者无效Missing iOS Distribution signing identity
打包上传AppStore时报错。Develop证书和Distribution证书都提示“此证书的签发者无效”,AppleWWDRCA (Apple Worldwide Developer Relations Certification Authority) 证书过期解决。
Thanks for bringing this to the attention of the community and apologies for the issues you’ve been having. This issue stems from having a copy of the expired WWDR Intermediate certificate in both your System and Login keychains. To resolve the issue, you should first download and install the new WWDR intermediate certificate (by double-clicking on the file). Next, in the Keychain Access application, select the System keychain. Make sure to select “Show Expired Certificates” in the View menu and then delete the expired version of the Apple Worldwide Developer Relations Certificate Authority Intermediate certificate (expired on February 14, 2016). Your certificates should now appear as valid in Keychain Access and be available to Xcode for submissions to the App Store.
As noted in a comment below, the expired certificate also needs to be removed from the login section, as well:
To all that cannot get it working despite the instructions... There are two expired WWDR certs. One is in login keychain, and the other one is in the System. You have to delete both of them in order to make things working
苹果工作人员官方回答了哦,见:Xcode 7 error: “Missing iOS Distribution signing identity for …”。
Pointer is missing a nullability type specifier (__nonnull or __nullable)
Xcode6.3加入的特性。
相关的另一个:null passed to a callee that requires a non-null argument以及这个
Could not launch "My App" process launch failed: Security
不受信任的开发者
您的设备管理设置不允许在此台iPhone上使用开发者"XXX"的应用
您可以在"设置"中允许使用这些应用
设置 -> 通用 -> 描述文件 -> "开发者的AppleID" 选择信任。
Application received signal SIGSEGV (null)
you should find the xxx.app.dSYM and use the dSYMTool
fill in the information such as :
CPU Type: armv7 Slide Address: 0x00004000 Base Address: 0x0008a000
you will know the crash bug
找下dsym,使用dsym工具反编译一下,之前源码编译的结果。
Program received signal SIGSEGV, Segmentation fault。SIGSEGV错误了解一下
-[UICachedDeviceWhiteColor shadowColor]: unrecognized selector sent to instance 0x156f22f0
这个问题好像是参数类型写错了或者有的参数直接传入的nil,时间久了具体忘记怎么解决的了,只留下两个参考链接,另一个文章。
CUICatalog: Invalid asset name supplied:
应该是素材资源文件夹中的图片。在代码中没有使用。
Class _NSZombie_xxxxxxx is implemented in both ?? and?
把检查将是对象的开关打开了。
NSZombies is turned on. Go to product -> scheme -> edit scheme (CMD+SHIFT+.) and under run -> diagnostics uncheck "Enable Zombies".
难道另有隐情:Class Foo is implemented in both MyApp and MyAppTestCase. One of the two will be used. Which one is undefined,也看看国内的开发者朋友的看法
"The account 'Apple ID' has no team with ID 'team ID'
报这个错,导致无法真机测试。
Xcode Unable to boot device because it cannot be located on disk
The executable was signed with invalid entitlements
Project - TARGETS - 项目目标名称 - Build Settings - Code Signing Entitlements 将其值置为空。
再次运行即可通过
网友评论