iOS調(diào)試警告錯誤問題整理

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".

795492-20150922084111615-914867190.png

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++異常败匹。這種異痴迹可以忽略不計讥巡。解決方法

https://stackoverflow.com/questions/9811512/why-does-audioservicescreatesystemsoundid-throw-an-exception-internally-but-retu

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”就可以了叶撒。

Snip20170420_15.png

'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 將其值置為空秉剑。

再次運行即可通過


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末泛豪,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子侦鹏,更是在濱河造成了極大的恐慌诡曙,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,968評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件略水,死亡現(xiàn)場離奇詭異价卤,居然都是意外死亡,警方通過查閱死者的電腦和手機渊涝,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,601評論 2 382
  • 文/潘曉璐 我一進(jìn)店門慎璧,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人跨释,你說我怎么就攤上這事胸私。” “怎么了鳖谈?”我有些...
    開封第一講書人閱讀 153,220評論 0 344
  • 文/不壞的土叔 我叫張陵岁疼,是天一觀的道長。 經(jīng)常有香客問我缆娃,道長捷绒,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,416評論 1 279
  • 正文 為了忘掉前任贯要,我火速辦了婚禮暖侨,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘郭毕。我一直安慰自己它碎,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 64,425評論 5 374
  • 文/花漫 我一把揭開白布显押。 她就那樣靜靜地躺著,像睡著了一般傻挂。 火紅的嫁衣襯著肌膚如雪乘碑。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,144評論 1 285
  • 那天金拒,我揣著相機與錄音兽肤,去河邊找鬼套腹。 笑死,一個胖子當(dāng)著我的面吹牛资铡,可吹牛的內(nèi)容都是我干的电禀。 我是一名探鬼主播,決...
    沈念sama閱讀 38,432評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼笤休,長吁一口氣:“原來是場噩夢啊……” “哼尖飞!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起店雅,我...
    開封第一講書人閱讀 37,088評論 0 261
  • 序言:老撾萬榮一對情侶失蹤政基,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后闹啦,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體沮明,經(jīng)...
    沈念sama閱讀 43,586評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,028評論 2 325
  • 正文 我和宋清朗相戀三年窍奋,在試婚紗的時候發(fā)現(xiàn)自己被綠了荐健。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,137評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡琳袄,死狀恐怖摧扇,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情挚歧,我是刑警寧澤扛稽,帶...
    沈念sama閱讀 33,783評論 4 324
  • 正文 年R本政府宣布,位于F島的核電站滑负,受9級特大地震影響在张,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜矮慕,卻給世界環(huán)境...
    茶點故事閱讀 39,343評論 3 307
  • 文/蒙蒙 一帮匾、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧痴鳄,春花似錦瘟斜、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,333評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至橡类,卻和暖如春蛇尚,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背顾画。 一陣腳步聲響...
    開封第一講書人閱讀 31,559評論 1 262
  • 我被黑心中介騙來泰國打工取劫, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留匆笤,地道東北人。 一個月前我還...
    沈念sama閱讀 45,595評論 2 355
  • 正文 我出身青樓谱邪,卻偏偏與公主長得像炮捧,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子惦银,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,901評論 2 345

推薦閱讀更多精彩內(nèi)容