Security controls
Some of the security features implemented within the iOS SDK could make application development slower, if those couldn't be disabled during the development phase. For example, the root detection feature will not allow running applications on an iOS simulator, since it behaves as a rooted device. The iOS SDK gives a possibility to turn off those features by implementing the SecurityController
class within your application. This class, if present, will be picked up by the iOS SDK and the configuration you specified will be applied.
It's strongly advised to release applications with all security controls enabled and debug logs disabled. Security controls should only be turned off during development.
Debug detection
The iOS SDK has an ability to detect if the app runs with a debugger attached. If debug mode detection is enabled and a debugger is detected, the iOS SDK will not allow the successful completion of any of the flows. All flows will end in an error that states that the device is not suitable to communicate with the backend. Also a special event will be logged in the event log indicating that a connection from potentially unreliable device was made.
Root detection
The iOS SDK is capable of detecting whenever a device running the application is jail-broken. If detection is enabled and the device is jail-broken, the iOS SDK will not allow the successful completion of any of the flows. All flows will end in an error that states that the device is not suitable to communicate with the backend. Also, a special event will be logged in the event log indicating that a connection from a potentially unreliable device was made.
Debug logs
The iOS SDK has an additional option to print debug logs to the console if needed. The iOS SDK will log its network communication (HTTP request or response paths and status codes) and every method call to the public API.
How to configure security controls
You may want to disable root or debug detection (or both), for example during the development process. The iOS SDK uses the NSClassFromString
method to search for a class called SecurityController
. The object should contain a static BOOL method named debugDetection
or rootDetection
, for example:
//SecurityController.h
#ifdef DEBUG
@interface SecurityController : NSObject
+ (BOOL)rootDetection;
+ (BOOL)debugDetection;
+ (BOOL)debugLogs;
@end
#endif
//SecurityController.m
#ifdef DEBUG
@implementation SecurityController
+ (BOOL)debugDetection
{
return NO;
}
+ (BOOL)rootDetection
{
return NO;
}
+ (BOOL)debugLogs
{
return YES;
}
@end
#endif
This way, you can (temporarily) disable both security controls and turn debug logs on. To ensure that your application will not be released with security controls disabled, it's advised to add the SecurityController
class only for debug builds. It can be accomplished by using #ifdef
DEBUG macro.