Xcode - 运行时环境变量( Environment Variables )
源链接:https://viktyz.gitbooks.io/iosnotebook-gitbook/Notes/Note_00140_20160205.html
方案名称
Xcode - 运行时环境变量( Environment Variables )
关键字
Xcode \ 运行时 \ 环境变量 \ Environment Variables
需求场景
- 添加环境变量可以帮助提高调试效率,如调试僵尸对象
参考链接
- 运行时环境变量
- Stack Overflow - List of environment variable in Objective C?
- iOS环境变量设置
- GitHub Gist - OBJC_HELP=1 on Lion
- Apple documentation - Mac OS X Debugging Magic
详细内容
添加方法:
Project -> Scheme -> Edit Scheme ,在 Arguments 下可以添加运行时的环境变量( Environment Variables )
查看列表:打开终端执行以下命令可查看完整列表
$ export OBJC_HELP=1
$ /Applications/Safari.app/Contents/MacOS/Safari
列表说明:
变量名 | 介绍 | 备注 |
---|---|---|
OBJC_PRINT_OPTIONS | list which options are set | 输出OBJC已设置的选项 |
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 方法的调用信息 |
OBJC_PRINT_INITIALIZE_METHODS | log calls to class +initialize methods | 打印 Class 的 + (void)initialize 的调用信息 |
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 的设置过程 |
OBJC_PRINT_PROTOCOL_SETUP | log progress of protocol setup | 打印 Protocol 的设置过程 |
OBJC_PRINT_IVAR_SETUP | log processing of non-fragile ivars | 打印 Ivar 的设置过程 |
OBJC_PRINT_VTABLE_SETUP | log processing of class vtables | 打印 vtable 的设置过程 |
OBJC_PRINT_VTABLE_IMAGES | print vtable images showing overridden methods | 打印 vtable 被覆盖的方法 |
OBJC_PRINT_CACHE_SETUP | log processing of method caches | 打印方法缓存的设置过程 |
OBJC_PRINT_FUTURE_CLASSES | log use of future classes for toll-free bridging | 打印从 CFType 无缝转换到 NSObject 将要使用的类(如 CFArrayRef 到 NSArray * ) |
OBJC_PRINT_GC | log some GC operations | 打印一些垃圾回收操作 |
OBJC_PRINT_PREOPTIMIZATION | log preoptimization courtesy of dyld shared cache | 打印 dyld 共享缓存优化前的问候语 |
OBJC_PRINT_CXX_CTORS | log calls to C++ ctors and dtors for instance variables | 打印类实例中的 C++ 对象的构造与析构调用 |
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 | 打印所有过时的方法调用 |
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 | 打印含有未优化的自定义 retain/release 方法的类 |
OBJC_PRINT_CUSTOM_AWZ | log classes with un-optimized custom allocWithZone methods | 打印含有未优化的自定义 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 | 当子类可能被对父类的修改破坏时打印警告 |
OBJC_DEBUG_FINALIZERS | warn about classes that implement -dealloc but not -finalize | 警告实现了 -dealloc 却没有实现 -finalize 的类 |
OBJC_DEBUG_NIL_SYNC | warn about @synchronized(nil), which does no synchronization | 警告 @synchronized(nil) 调用,这种情况不会加锁 |
OBJC_DEBUG_NONFRAGILE_IVARS | capriciously rearrange non-fragile ivars | 打印突发地重新布置 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,可能内存泄漏 |
OBJC_DEBUG_DUPLICATE_CLASSES | halt when multiple classes with the same name are present | 当出现类重名时停机 |
OBJC_USE_INTERNAL_ZONE | allocate runtime data in a dedicated malloc zone | 在一个专用的 malloc 区分配运行时数据 |
OBJC_DISABLE_GC | force GC OFF, even if the executable wants it on | 强行关闭自动垃圾回收,即使可执行文件需要垃圾回收 |
OBJC_DISABLE_VTABLES | disable vtable dispatch | 关闭 vtable 分发 |
OBJC_DISABLE_PREOPTIMIZATION | disable preoptimization courtesy of dyld shared cache | 关闭 dyld 共享缓存优化前的问候语 |
OBJC_DISABLE_TAGGED_POINTERS | disable tagged pointer optimization of NSNumber et al. | 关闭 NSNumber 等的 tagged pointer 优化 |
OBJC_DISABLE_NONPOINTER_ISA | disable non-pointer isa fields | 关闭 non-pointer isa 字段的访问 |
网友评论