iOS底层原理:苹果开源 objc4-818 源码项目的编译和调试(二)

简介: 作为一名iOS程序员,探索OC底层原理永不止息,同时也是永远的痛,最开始只能靠猜测!后面慢慢找到了苹果官方开源的源码来辅助看一下,但是尽管这样,还是显得不太直观!如果objc源码能够像我们自己创建的项目一样直接编译调试,像我们自己的代码一样能够直接 LLDB 调试,流程跟踪,那简直不要太爽。废话不多说,开炮~ 哦,不是,是开干~!🚀
报错9:'os/tsd.h' file not found


同样是找到文件位置,tsd.h文件在xnu-7195.141.2/libsyscall/os目录下

解决方式:


  1. tsd.hxnu-7195.141.2/libsyscall/os目录下copy到JQDependencies/os/目录下
报错10:'System/pthread_machdep.h' file not found

同样是找到文件位置,pthread_machdep.h文件在Libc-825.40.1/pthreads目录下。

注意:经过一番探索,我发现pthread_machdep.h只在Libc-825.40.1及以下版本才有


image.png

解决方式:


  1. pthread_machdep.hLibc-825.40.1/pthreads目录下copy到JQDependencies/System/目录下


报错11:'CrashReporterClient.h' file not found


同样是找到文件位置,CrashReporterClient.h文件在Libc-825.40.1/include目录下。


解决方式:

  1. CrashReporterClient.hLibc-825.40.1/include目录下copy到JQDependencies/目录下


image.png


导入CrashReporterClient.h文件后,如果还报错,用以下两种方式解决:

  • 第一种:需要在 Build Settings -> Preprocessor Macros 中加入:LIBC_NO_LIBCRASHREPORTERCLIENT


image.png

第二种:在CrashReporterClient.h中添加如下宏定义

image.png


报错12:Typedef redefinition with different types ('int' vs 'volatile OSSpinLock' (aka 'volatile int'))

pthread_lock_t重复定义了

解决方式:

  • 注释掉 在*pthread_machdep.h文件中的定义


image.png

报错13:


Static declaration of '_pthread_has_direct_tsd' follows non-static declaration
和 Static declaration of '_pthread_getspecific_direct' follows non-static declaration

解决方式:

  • 把这些声明在*pthread_machdep.h文件中注释掉就行

image.png

报错14:/JQDependencies/os/lock_private.h:288:37: Expected ','


image.png

解决方式:


  • 把这个函数中的bridgeos(4.0)参数删除即可
报错15:Use of undeclared identifier 'dyld_fall_2020_os_versions'

** 解决方式:**

  • 注释掉就行



image.png


报错16:'objc-shared-cache.h' file not found


同样是找到文件位置,objc-shared-cache.h文件在dyld-852.2/include目录下。


解决方式:


  1. objc-shared-cache.hdyld-852.2/include目录下copy到JQDependencies/目录下
报错17:'objc-bp-assist.h' file not found

解决方式:


  • 注释掉objc-bp-assist.h这个文件的引用
报错18:Use of undeclared identifier 'dyld_platform_version_macOS_10_13'

解决方式:


  • 注释掉该段代码


image.png

报错19:Use of undeclared identifier 'dyld_platform_version_macOS_10_11'

解决方式:

  • 注释掉该段代码

image.png


报错20:Use of undeclared identifier 'dyld_fall_2018_os_versions'

解决方式:


  • 注释掉该段代码


image.png


image.png

报错21:'_simple.h' file not found


同样是找到文件位置,_simple.h'文件在libplatform-libplatform-220.100.1/private目录下。

解决方式:


  1. _simple.hlibplatform-libplatform-220.100.1/private目录下copy到JQDependencies/目录下
报错22:'os/linker_set.h' file not found

同样是找到文件位置,linker_set.h'文件在xnu-7195.141.2/bsd/sys目录下。

解决方式:

  1. linker_set.hxnu-7195.141.2/bsd/sys目录下copy到JQDependencies/os目录下
报错23:'Cambria/Traps.h' file not found

解决方式:


  • 文件开源网站找不到 ,选择注释头文件引用


image.png


报错24:'Block_private.h' file not foun


同样是文件缺失,Block_private.h这个文件在

libclosure-79/目录下


解决方式:


  1. Block_private.hlibclosure-79/目录下copy到JQDependencies/目录下
报错25:'kern/restartable.h' file not found

同样是文件缺失,restartable.h这个文件在

xnu-7195.141.2/osfmk/kern/目录下

解决方式:


  1. JQDependencies/目录下创建一个kern文件夹
  2. restartable.hxnu-7195.141.2/osfmk/kern/目录下copy到JQDependencies/kern/目录下


报错26:**Use of undeclared identifier 'oah_is_current_process_translated' 和

Use of undeclared identifier 'objc_thread_get_rip'**


image.png

解决方式:


  • objc_cache.mm文件中注释掉1121-1128行,保留1127行,如图:

image.png


报错27:'os/feature_private.h' file not found

解决方式:


  • 这个引用头文件直接注释掉

image.png

报错28:'os/reason_private.h' file not found

同样是文件缺失,reason_private.h这个文件在

xnu-7195.141.2/libkern/os/目录下


解决方式:


  1. reason_private.hxnu-7195.141.2/libkern/os/目录下copy到JQDependencies/os/目录下



相关文章
|
2月前
|
存储 运维 安全
iOS加固原理与常见措施:保护移动应用程序安全的利器
iOS加固原理与常见措施:保护移动应用程序安全的利器
31 0
|
2月前
|
iOS开发 开发者
【教程】苹果 iOS 证书制作教程
【教程】苹果 iOS 证书制作教程
|
3月前
|
iOS开发 开发者
苹果iOS App Store上架操作流程详解:从开发者账号到应用发布
很多开发者在开发完iOS APP、进行内测后,下一步就面临上架App Store,不过也有很多同学对APP上架App Store的流程不太了解,下面我们来说一下iOS APP上架App Store的具体流程,如有未涉及到的部分,大家可以及时咨询,共同探讨。
|
4月前
|
移动开发 前端开发 安全
最强大的 iOS 应用源码保护工具:Ipa Guard,保护你的商业机密代码
最强大的 iOS 应用源码保护工具:Ipa Guard,保护你的商业机密代码
|
4月前
|
移动开发 前端开发 数据安全/隐私保护
【工具】iOS代码混淆工具-iOS源码混淆
【工具】iOS代码混淆工具-iOS源码混淆
44 1
|
4月前
|
存储 运维 安全
iOS加固原理与常见措施:保护移动应用程序安全的利器
iOS加固原理与常见措施:保护移动应用程序安全的利器
41 0
|
3月前
|
安全 前端开发 数据安全/隐私保护
【教程】 iOS混淆加固原理篇
本文介绍了iOS应用程序混淆加固的缘由,编译过程以及常见的加固类型和逆向工具。详细讨论了字符串混淆、类名、方法名混淆、程序结构混淆加密等加固类型,并介绍了常见的逆向工具和代码虚拟化技术。
|
3月前
|
iOS开发 开发者
苹果 iOS App Store 上架操作流程详解:从开发者账号到应用发布
苹果 iOS App Store 上架操作流程详解:从开发者账号到应用发布
|
4月前
|
安全 算法 前端开发
【完整版教程】iOS混淆加固原理篇
在iOS开发中,应用程序的安全性和保护显得尤为重要。由于iOS系统的开放性,一些逆向工具可以轻松地对应用程序进行反编译和分析,从而导致应用程序源代码、算法和敏感信息的泄露。为了保护应用程序的安全性,我们需要对应用程序进行混淆加固。本文将介绍iOS混淆加固的原理和常见的加固类型。
|
4月前
|
iOS开发
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法

相关课程

更多