Skip to content

Commit

Permalink
fix(ios) : Debug macros behaviour in framework implemented using shar…
Browse files Browse the repository at this point in the history
…ed configuration
  • Loading branch information
vijaysingh-axway committed Jan 9, 2019
1 parent 45445ec commit ae362b2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
15 changes: 6 additions & 9 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiBase.h
Expand Up @@ -5,6 +5,7 @@
* Please see the LICENSE included with this distribution for details.
*/

#import "TiSharedConfig.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

Expand Down Expand Up @@ -522,16 +523,12 @@ enum {
}
#endif

#if defined(DEBUG) || defined(DEVELOPER)
#define DebugLog(...) \
{ \
NSLog(__VA_ARGS__); \
#define DebugLog(...) \
{ \
if ([TiSharedConfig defaultConfig].debugEnabled) { \
NSLog(__VA_ARGS__); \
} \
}
#else
#define DebugLog(...) \
{ \
}
#endif

#define VAL_OR_NSNULL(foo) (((foo) != nil) ? ((id)foo) : [NSNull null])

Expand Down
Expand Up @@ -66,9 +66,7 @@
@property (nonatomic, readonly) UIStatusBarStyle defaultStatusBarStyle;
@property (nonatomic, readonly) BOOL statusBarVisibilityChanged;
@property (nonatomic, readonly) TiViewProxy<TiKeyboardFocusableView> *keyboardFocusedProxy;
#if defined(DEBUG) || defined(DEVELOPER)
- (void)shutdownUi:(id)arg;
#endif
- (UIImage *)defaultImageForOrientation:(UIDeviceOrientation)orientation resultingOrientation:(UIDeviceOrientation *)imageOrientation idiom:(UIUserInterfaceIdiom *)imageIdiom;

@end
Expand Up @@ -685,9 +685,11 @@ - (UIView *)topWindowProxyView
}
}

#if defined(DEBUG) || defined(DEVELOPER)
- (void)shutdownUi:(id)arg
{
if (![TiSharedConfig defaultConfig].debugEnabled) {
return;
}
//FIRST DISMISS ALL MODAL WINDOWS
UIViewController *topVC = [self topPresentedController];
if (topVC != self) {
Expand Down Expand Up @@ -724,7 +726,6 @@ - (void)shutdownUi:(id)arg
DebugLog(@"[WARN] Could not resume. No selector _resumeRestart: found for arg");
}
}
#endif

#pragma mark - TiControllerContainment
- (BOOL)canHostWindows
Expand Down Expand Up @@ -1187,9 +1188,9 @@ - (void)refreshOrientationWithDuration:(id)unused

if ([[UIApplication sharedApplication] statusBarOrientation] != target) {
forcingRotation = YES;
#if defined(DEBUG) || defined(DEVELOPER)
DebugLog(@"Forcing rotation to %d. Current Orientation %d. This is not good UI design. Please reconsider.", target, [[UIApplication sharedApplication] statusBarOrientation]);
#endif
if ([TiSharedConfig defaultConfig].debugEnabled) {
DebugLog(@"Forcing rotation to %d. Current Orientation %d. This is not good UI design. Please reconsider.", target, [[UIApplication sharedApplication] statusBarOrientation]);
}
#ifdef FORCE_WITH_MODAL
[self forceRotateToOrientation:target];
#else
Expand Down
6 changes: 6 additions & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/Misc/TiSharedConfig.h
Expand Up @@ -109,6 +109,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, strong, nullable) UIColor *defaultBackgroundColor;

/**
Indicates whether debug is enabled or not.
*/

@property (nonatomic, assign) BOOL debugEnabled;

+ (TiSharedConfig *)defaultConfig;

NS_ASSUME_NONNULL_END
Expand Down
4 changes: 3 additions & 1 deletion iphone/iphone/main.m
Expand Up @@ -61,7 +61,9 @@ int main(int argc, char *argv[])
alpha:1.0f];
#endif
[[TiSharedConfig defaultConfig] setDefaultBackgroundColor:defaultBgColor];

#if defined(DEBUG) || defined(DEVELOPER)
[[TiSharedConfig defaultConfig] setDebugEnabled:YES];
#endif
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"TiUIApplication", @"TiApp");
[pool release];
Expand Down
4 changes: 4 additions & 0 deletions support/iphone/main.m
Expand Up @@ -56,6 +56,10 @@ int main(int argc, char *argv[])
#endif
[[TiSharedConfig defaultConfig] setDefaultBackgroundColor:defaultBgColor];

#if defined(DEBUG) || defined(DEVELOPER)
[[TiSharedConfig defaultConfig] setDebugEnabled:YES];
#endif

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"TiUIApplication", @"TiApp");
[pool release];
Expand Down

0 comments on commit ae362b2

Please sign in to comment.