運(yùn)行時環(huán)境變量
可以通過在終端輸入
export OBJC_HELP=1打印出對應(yīng)的環(huán)境變量-
我們可以通過配置環(huán)境變量,做到一些特殊的處理,比如設(shè)置
OBJC_DISABLE_NONPOINTER_ISA為YES,isa就不會被優(yōu)化,設(shè)置OBJC_PRINT_LOAD_METHODS: log calls to class and category +load methods打印所有l(wèi)oad方法,通過后面的使用說明,也可以知道對應(yīng)的作用,具體設(shè)置環(huán)境變量如下
image.png 一些常用的環(huán)境變量
DYLD_PRINT_STATISTICS:設(shè)置 DYLD_PRINT_STATISTICS 為YES,控制臺就會打印 App 的加載時長,包括整體加載時長和動態(tài)庫加載時長,即main函數(shù)之前的啟動時間(查看pre-main耗時),可以通過設(shè)置了解其耗時部分,并對其進(jìn)行啟動優(yōu)化。
OBJC_DISABLE_NONPOINTER_ISA:杜絕生成相應(yīng)的nonpointer isa(nonpointer isa指針地址 末尾為1 ),生成的都是普通的isa
OBJC_PRINT_LOAD_METHODS:打印 Class 及 Category 的 + (void)load 方法的調(diào)用信息
NSDoubleLocalizedStrings:項目做國際化本地化(Localized)的時候是一個挺耗時的工作,想要檢測國際化翻譯好的語言文字UI會變成什么樣子,可以指定這個啟動項??梢栽O(shè)置 NSDoubleLocalizedStrings 為YES。
NSShowNonLocalizedStrings:在完成國際化的時候,偶爾會有一些字符串沒有做本地化,這時就可以設(shè)置NSShowNonLocalizedStrings 為YES,所有沒有被本地化的字符串全都會變成大寫。
下面列出了打印出來的環(huán)境變量及其作用
| 變量名 | 介紹 | 備注 |
| ---------| --------- | --------- |
|OBJC_PRINT_OPTIONS| list which options are set |輸出OBJC已設(shè)置的選項
|OBJC_PRINT_IMAGES |log image and library names as they are loaded |輸出已load的image信息
|OBJC_PRINT_LOAD_METHODS|log calls to class and category +load methods |打印 Class 及 Category 的 + (void)load 方法的調(diào)用信息
|OBJC_PRINT_INITIALIZE_METHODS |log calls to class +initialize methods |打印 Class 的 + (void)initialize 的調(diào)用信息|
|OBJC_PRINT_RESOLVED_METHODS |log methods created by +resolveClassMethod and +resolveInstanceMethod:| 打印通過 +resolveClassMethod: 或 +resolveInstanceMethod: 生成的類方法|
|OBJC_PRINT_CLASS_SETUP |log progress of class and category setup |打印 Class 及 Category 的設(shè)置過程
|OBJC_PRINT_PROTOCOL_SETUP| log progress of protocol setup |打印 Protocol 的設(shè)置過程
|OBJC_PRINT_IVAR_SETUP |log processing of non-fragile ivars |打印 Ivar 的設(shè)置過程
|OBJC_PRINT_VTABLE_SETUP| log processing of class vtables |打印 vtable 的設(shè)置過程
|OBJC_PRINT_VTABLE_IMAGES |print vtable images showing overridden methods |打印 vtable 被覆蓋的方法
|OBJC_PRINT_CACHE_SETUP |log processing of method caches |打印方法緩存的設(shè)置過程
|OBJC_PRINT_FUTURE_CLASSES |log use of future classes for toll-free bridging |打印從 CFType 無縫轉(zhuǎn)換到 NSObject 將要使用的類(如 CFArrayRef 到 NSArray * )
|OBJC_PRINT_GC |log some GC operations |打印一些垃圾回收操作
|OBJC_PRINT_PREOPTIMIZATION |log preoptimization courtesy of dyld shared cache |打印 dyld 共享緩存優(yōu)化前的問候語
|OBJC_PRINT_CXX_CTORS |log calls to C++ ctors and dtors for instance variables |打印類實例中的 C++ 對象的構(gòu)造與析構(gòu)調(diào)用
|OBJC_PRINT_EXCEPTIONS |log exception handling |打印異常處理
|OBJC_PRINT_EXCEPTION_THROW |log backtrace of every objc_exception_throw() |打印所有異常拋出時的 Backtrace
|OBJC_PRINT_ALT_HANDLERS |log processing of exception alt handlers |打印 alt 操作異常處理
|OBJC_PRINT_REPLACED_METHODS |log methods replaced by category implementations |打印被 Category 替換的方法
|OBJC_PRINT_DEPRECATION_WARNINGS |warn about calls to deprecated runtime functions |打印所有過時的方法調(diào)用
|OBJC_PRINT_POOL_HIGHWATER |log high-water marks for autorelease pools |打印 autoreleasepool 高水位警告
|OBJC_PRINT_CUSTOM_RR |log classes with un-optimized custom retain/release methods |打印含有未優(yōu)化的自定義 retain/release 方法的類
|OBJC_PRINT_CUSTOM_AWZ |log classes with un-optimized custom allocWithZone methods |打印含有未優(yōu)化的自定義 allocWithZone 方法的類
|OBJC_PRINT_RAW_ISA |log classes that require raw pointer isa fields |打印需要訪問原始 isa 指針的類
|OBJC_DEBUG_UNLOAD |warn about poorly-behaving bundles when unloaded |卸載有不良行為的 Bundle 時打印警告
|OBJC_DEBUG_FRAGILE_SUPERCLASSES |warn about subclasses that may have been broken by subsequent changes to superclasses |當(dāng)子類可能被對父類的修改破壞時打印警告
|OBJC_DEBUG_FINALIZERS |warn about classes that implement -dealloc but not -finalize |警告實現(xiàn)了 -dealloc 卻沒有實現(xiàn) -finalize 的類
|OBJC_DEBUG_NIL_SYNC |warn about @synchronized(nil), which does no synchronization |警告 @synchronized(nil) 調(diào)用,這種情況不會加鎖
|OBJC_DEBUG_NONFRAGILE_IVARS |capriciously rearrange non-fragile ivars |打印突發(fā)地重新布置 non-fragile ivars 的行為
|OBJC_DEBUG_ALT_HANDLERS |record more info about bad alt handler use |記錄更多的 alt 操作錯誤信息
|OBJC_DEBUG_MISSING_POOLS |warn about autorelease with no pool in place, which may be a leak |警告沒有 pool 的情況下使用 autorelease,可能內(nèi)存泄漏
|OBJC_DEBUG_DUPLICATE_CLASSES |halt when multiple classes with the same name are present |當(dāng)出現(xiàn)類重名時停機(jī)
|OBJC_USE_INTERNAL_ZONE |allocate runtime data in a dedicated malloc zone |在一個專用的 malloc 區(qū)分配運(yùn)行時數(shù)據(jù)
|OBJC_DISABLE_GC |force GC OFF, even if the executable wants it on |強(qiáng)行關(guān)閉自動垃圾回收,即使可執(zhí)行文件需要垃圾回收
|OBJC_DISABLE_VTABLES |disable vtable dispatch |關(guān)閉 vtable 分發(fā)
|OBJC_DISABLE_PREOPTIMIZATION |disable preoptimization courtesy of dyld shared cache |關(guān)閉 dyld 共享緩存優(yōu)化前的問候語
|OBJC_DISABLE_TAGGED_POINTERS |disable tagged pointer optimization of NSNumber et al. |關(guān)閉 NSNumber 等的 tagged pointer 優(yōu)化
|OBJC_DISABLE_NONPOINTER_ISA |disable non-pointer isa fields |關(guān)閉 non-pointer isa 字段的訪問
