iOS開發(fā)筆記(三)

前言

日常開發(fā)遇到的問題記錄。

JSON

Invalid type in JSON write (NSConcreteMutableData)
合法的json對象:

  • 1、頂層對象必須是NSArray或者NSDictionary;
  • 2、所有的對象必須是NSString/NSNumber/NSArray/NSDictionary/NSNull的實(shí)例;
  • 3、所有NSDictionary的key必須是NSString類型;
  • 4、數(shù)字對象不能是非數(shù)值或無窮;

內(nèi)購

1、銀行cnaps code查詢

http://www.lianhanghao.com/

2、申請賬號時(shí),無法加入program

蘋果說:

Sorry, you can’t enroll at this time. You can still develop apps and test them on iOS devices using the beta version of Xcode. Learn more

原因: 按照注冊的時(shí)候填寫的出生日期, 年齡未滿18歲。
解決方法:

  • 重新注冊apple id;
  • 在apple.com修改appid的信息;

iOS10

1、未找到應(yīng)用程序的“aps-environment”的授權(quán)字符串

"getting push token failed: Error Domain=NSCocoaErrorDomain Code=3000 "未找到應(yīng)用程序的“aps-environment”的授權(quán)字符串" UserInfo={NSLocalizedDescription=未找到應(yīng)用程序的“aps-environment”的授權(quán)字符串}

解決方案:打開Xcode8,點(diǎn)擊下面的地方。

2、去掉無效log并且保留原來的nslog信息

真機(jī)下設(shè)置OS_ACTIVITY_MODE會(huì)讓nslog的信息消失,可以把nslog改成printf。

#define LYLog(...) printf("%f %s\n",[[NSDate date]timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);

Debug

1、dSYM

當(dāng)把Objective-C代碼編譯成匯編、再轉(zhuǎn)譯成二進(jìn)制機(jī)器碼后,會(huì)生成一個(gè)dSYM文件包(內(nèi)含符號表,負(fù)責(zé)翻譯崩潰報(bào)告成可讀代碼)。
.dSYM文件是一個(gè)目錄,包含一個(gè)十六進(jìn)制的函數(shù)地址映射信息的文件,Debug的symbols都在這個(gè)文件中(包括文件名、函數(shù)名、行號等)。
Xcode項(xiàng)目每次編譯后,都會(huì)生成一個(gè)新的.dSYM文件,故而真機(jī)上的崩潰日志需要檢查對應(yīng)的符號表。


2、crash日志分析

WAKEUPS 錯(cuò)誤
http://stackoverflow.com/questions/25848441/app-shutdown-with-exc-resource-wakeups-exception-on-ios-8-gm
后臺(tái)線程有嚴(yán)格的調(diào)用限制

Background threads in iOS 8 have a hard limit on how many times you can run a sleep/wake cycle on each thread per second, and having a high count here is usually an indication that something is wrong / inefficient in your thread management.

Xcode

1、Xcode斷點(diǎn)失效

  • Clean Project
  • Clean Build Folder
  • Clear Xcode's DerivedData
  • Making sure breakpoints are enabled (Cmd Y)
  • Build Settings are set to Debug
  • Always Show Disassembly enabled and disabled
  • Debugging enabled in run config

最后發(fā)現(xiàn)問題出現(xiàn)在Xcode工程,當(dāng)把老工程的文件全部添加到新工程即可斷點(diǎn)。(老工程新建于2013年,猜測是這個(gè)原因;可惜沒有找到斷點(diǎn)失效的真正原因)

2、Xcode并存

在finder中打開應(yīng)用程序,把xcode改成xcode8,再下載xcode7;

pod相關(guān)

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.

刪除podfile.lock 和 工程,重新pod install

需要注意查看pod install的指令,反饋結(jié)果。

集成報(bào)錯(cuò)

1、找不到KSYGPUStreamerKit


KSYRTCStreamerKit 繼承 KSYGPUStreamerKit,
但是沒有引入頭文件,使用的是 @class KSYGPUStreamerKit;
于是在使用KSYRTCStreamerKit 必須先導(dǎo)入KSYGPUStreamerKit,
再導(dǎo)入KSYRTCStreamerKit。
給出的demo中,頭文件的引用是

#import <libksyrtclivedy/KSYRTCStreamerKit.h>
#import <libksyrtclivedy/KSYRTCStreamer.h>

#import <libksygpuliveDy/libksygpuimage.h>
#import <libksygpuliveDy/KSYGPUStreamerKit.h>

這樣第三方在集成的時(shí)候,如果按照demo的頭文件引入順序,就會(huì)報(bào)奇怪的錯(cuò)誤。

2、運(yùn)行時(shí)錯(cuò)誤

運(yùn)行時(shí)報(bào)錯(cuò):

dyld: Library not loaded:@rpath/GPUImage.framework/GPUImage Referenced
Reason: image not found

原因是運(yùn)行時(shí)沒找到GPUImage
解決方案:embedd GPUImage.framework

UIWindow

UIWindow是第一個(gè)視圖控件(第一個(gè)對象是UIapplication),負(fù)責(zé)展示app內(nèi)容。
[self.window makekeyandvisible]可以讓窗口成為主窗口,并且顯示出來。
其他的view依賴于Window,Window顯示出來后,view添加在Window上。
UIWindow的三個(gè)級別:WindowNormal 、Alert、StatusBar;

UIKIT_EXTERN const UIWindowLevel UIWindowLevelNormal;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelAlert;
UIKIT_EXTERN const UIWindowLevel UIWindowLevelStatusBar __TVOS_PROHIBITED;

UIAlterView的例子:alert級別;


一個(gè)普通的視圖層級

總結(jié)

作為iOS開發(fā),花在iOS的時(shí)間不是最多,反省反省反省。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容