[英]Using the Macro SEC_IS_BEING_DEBUGGED_RETURN_NIL in iOS app
I learnt about the below piece of code, which is claimed to prevent Method Swizzling to some extent. 我了解了以下代码,声称可以在某种程度上防止方法混乱 。
#ifndef DEBUG
SEC_IS_BEING_DEBUGGED_RETURN_NIL();
#endif
But while including in my project for testing, I get an error. 但是,当将其包含在我的项目中进行测试时,我得到了一个错误。
Implicit declaration of function 'SEC_IS_BEING_DEBUGGED_RETURN_NIL' is invalid in C99
函数'SEC_IS_BEING_DEBUGGED_RETURN_NIL'的隐式声明在C99中无效
Can someone help me out on this error, if I need to include any library header for the same. 如果我需要为同一错误添加任何库标头,有人可以帮助我解决此错误。
I didn't intend to answer my own question. 我无意回答自己的问题。 From the comment above, I did a search for any such implementation.
从上面的评论中,我进行了任何此类实现的搜索。 And Found this In a GitHub Project .
并在GitHub Project中找到了它。 Which is a category of
NSObject
这是
NSObject
的类别
Perhaps, it would help anyone in future
. 也许,它将对
future
任何人有所帮助。
#define SEC_IS_BEING_DEBUGGED_RETURN_NIL() size_t size = sizeof(struct kinfo_proc); \
struct kinfo_proc info; \
int ret, name[4]; \
memset(&info, 0, sizeof(struct kinfo_proc)); \
name[0] = CTL_KERN; \
name[1] = KERN_PROC; \
name[2] = KERN_PROC_PID; \
name[3] = getpid(); \
if ((ret = (sysctl(name, 4, &info, &size, NULL, 0)))) { \
if (ret) return nil; \
} \
if (info.kp_proc.p_flag & P_TRACED) return nil
Credits to maker of this 归功于这个的厂商
// Created by Derek Selander on a happy day.
//由Derek Selander在快乐的一天创建。 //
//
// Copyright (c)//版权(c)
// 2013 Derek Selander.// 2013年Derek Selander。 All rights reserved.
版权所有。 //
//
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.