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.
手機上調(diào)試一啟動就會出現(xiàn)上面那個錯誤,一啟動就報錯榕栏,然后就會閃退。([AppName]那里是我的應(yīng)用的名字少漆。)
解決方法:
把Architecture中的PlatForm指明為"IOS"臼膏,而不是默認(rèn)的"iphone".
Unexpected 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.
檢查了下自己的代碼,發(fā)現(xiàn)是Apple公開的示损,檢查網(wǎng)絡(luò)可達(dá)性的類Reachability的加載是這樣的:
Class Reach = NSClassFromString(@"Reachability");
NSObject *r = [Reach performSelector:NSSelectorFromString(@"reachabilityWithHostName:") withObject:@"www.baidu.com"];
但是工程中忘了加入這個類了渗磅。應(yīng)該是運行期間試圖去加載公開的reachability類,但是公開的類沒有在工程中,結(jié)果勾到了私有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錯誤
出現(xiàn)此錯誤的原因就是下面的方法里面
- (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;聲明并初始化后柏腻,經(jīng)過一系列條件判斷處理后纸厉,因為自己的一些邏輯不夠嚴(yán)謹(jǐn),reusableview還是以nil返回了五嫂。
2017年8月9日更新:
bc++abi.dylib`__cxa_throw:
這兩天研究視頻播放颗品,集成RTMP視頻出現(xiàn)的異常,剛好看到一篇博客沃缘,樓主使用[AVAudioPlayer Play]時出現(xiàn)了異常躯枢。。槐臀。記錄下來:
由于xcode中設(shè)置了當(dāng)所有異常出現(xiàn)時的斷點锄蹂,,解決辦法是將all改為Objective-C:
當(dāng)程序運行的時候突然停在這了峰档,就是出現(xiàn)了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
這個錯場景是,在故事版做入口胧卤,與手動創(chuàng)建window做入口時唯绍。在設(shè)置Deployment Info中Main Interface時,設(shè)置為空枝誊。之后設(shè)置回“Main”况芒,報這個錯。
由空設(shè)置為“Main.storyboard”就可以了叶撒。
'Project Name' was compiled with optimization
工程在編譯之后被優(yōu)化了绝骚,所以導(dǎo)致單步的時候程序表現(xiàn)異常,變量也都不能訪問了祠够。這是由于編譯的時候選擇的是 release皮壁,而 release 的時候是會做很多優(yōu)化,導(dǎo)致上述結(jié)果哪审。
release模式調(diào)試程序蛾魄,嘗試查看變量的值時會遇到。改為Debug湿滓。
failed to get the task for process XXX
調(diào)試時證書設(shè)置問題滴须,project和targets的證書都必須是開發(fā)證書,AdHoc和發(fā)布證書會出現(xiàn)此問題叽奥。
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看看
此證書的簽發(fā)者無效Missing iOS Distribution signing identity
打包上傳AppStore時報錯魔市。Develop證書和Distribution證書都提示“此證書的簽發(fā)者無效”,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加入的特性枫夺。
相關(guān)的另一個:null passed to a callee that requires a non-null argument以及這個
Could not launch "My App" process launch failed: Security
不受信任的開發(fā)者
您的設(shè)備管理設(shè)置不允許在此臺iPhone上使用開發(fā)者"XXX"的應(yīng)用
您可以在"設(shè)置"中允許使用這些應(yīng)用
設(shè)置 -> 通用 -> 描述文件 -> "開發(fā)者的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工具反編譯一下橡庞,之前源碼編譯的結(jié)果较坛。
Program received signal SIGSEGV, Segmentation fault。SIGSEGV錯誤了解一下
-[UICachedDeviceWhiteColor shadowColor]: unrecognized selector sent to instance 0x156f22f0
這個問題好像是參數(shù)類型寫錯了或者有的參數(shù)直接傳入的nil扒最,時間久了具體忘記怎么解決的了丑勤,只留下兩個參考鏈接,另一個文章吧趣。
CUICatalog: Invalid asset name supplied:
應(yīng)該是素材資源文件夾中的圖片法竞。在代碼中沒有使用除呵。
Class _NSZombie_xxxxxxx is implemented in both ?? and?
把檢查將是對象的開關(guān)打開了。
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爪喘,也看看國內(nèi)的開發(fā)者朋友的看法
"The account 'Apple ID' has no team with ID 'team ID'
報這個錯颜曾,導(dǎo)致無法真機測試。
Xcode Unable to boot device because it cannot be located on disk
The executable was signed with invalid entitlements
Project - TARGETS - 項目目標(biāo)名稱 - Build Settings - Code Signing Entitlements 將其值置為空秉剑。
再次運行即可通過