diff --git a/AppBox.xcodeproj/project.pbxproj b/AppBox.xcodeproj/project.pbxproj index e339ba1b..8f813c68 100644 --- a/AppBox.xcodeproj/project.pbxproj +++ b/AppBox.xcodeproj/project.pbxproj @@ -45,7 +45,6 @@ E12E6D0A1D8FC77D0054814D /* DashboardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E12E6D081D8FC77D0054814D /* DashboardViewController.m */; }; E13161F21E9777DF00586052 /* CIProjectBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = E13161F11E9777DF00586052 /* CIProjectBuilder.m */; }; E13946121DF2AFCF00B3FAD0 /* XCProject.m in Sources */ = {isa = PBXBuildFile; fileRef = E13946111DF2AFCF00B3FAD0 /* XCProject.m */; }; - E143637B1DF59AFD00FB10CA /* LogViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E143637A1DF59AFD00FB10CA /* LogViewController.m */; }; E14F33341E1A64CA00C3DD34 /* NSApplication+MenuHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E14F33331E1A64CA00C3DD34 /* NSApplication+MenuHandler.m */; }; E15C266A1D7FD5CE004243B9 /* ShowLinkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E15C26691D7FD5CE004243B9 /* ShowLinkViewController.m */; }; E16018F01DEC0BC200E3A377 /* DropboxViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E16018EF1DEC0BC200E3A377 /* DropboxViewController.m */; }; @@ -68,7 +67,6 @@ E18186DC1E8A47C10002509F /* AccountPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E18186DB1E8A47C10002509F /* AccountPreferencesViewController.m */; }; E18186DF1E8A47CD0002509F /* EmailPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E18186DE1E8A47CD0002509F /* EmailPreferencesViewController.m */; }; E18186E21E8A47D60002509F /* HelpPreferencesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E18186E11E8A47D60002509F /* HelpPreferencesViewController.m */; }; - E1853392200E084500E88529 /* ABLog.m in Sources */ = {isa = PBXBuildFile; fileRef = E1853391200E084500E88529 /* ABLog.m */; }; E1902B481E16423200C3E0F6 /* ProjectAdvancedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E1902B471E16423200C3E0F6 /* ProjectAdvancedViewController.m */; }; E1902B531E16617B00C3E0F6 /* NetworkHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = E1902B4E1E16617B00C3E0F6 /* NetworkHandler.m */; }; E1902B541E16617B00C3E0F6 /* UserData.m in Sources */ = {isa = PBXBuildFile; fileRef = E1902B521E16617B00C3E0F6 /* UserData.m */; }; @@ -222,8 +220,6 @@ E13946101DF2AFCF00B3FAD0 /* XCProject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCProject.h; sourceTree = ""; }; E13946111DF2AFCF00B3FAD0 /* XCProject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XCProject.m; sourceTree = ""; }; E13946131DF2AFFF00B3FAD0 /* AppBoxPrefixHeader.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppBoxPrefixHeader.pch; sourceTree = ""; }; - E14363791DF59AFD00FB10CA /* LogViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogViewController.h; sourceTree = ""; }; - E143637A1DF59AFD00FB10CA /* LogViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LogViewController.m; sourceTree = ""; }; E14F33321E1A64CA00C3DD34 /* NSApplication+MenuHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSApplication+MenuHandler.h"; sourceTree = ""; }; E14F33331E1A64CA00C3DD34 /* NSApplication+MenuHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSApplication+MenuHandler.m"; sourceTree = ""; }; E15C26681D7FD5CE004243B9 /* ShowLinkViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShowLinkViewController.h; sourceTree = ""; }; @@ -263,8 +259,6 @@ E18186DE1E8A47CD0002509F /* EmailPreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EmailPreferencesViewController.m; sourceTree = ""; }; E18186E01E8A47D60002509F /* HelpPreferencesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelpPreferencesViewController.h; sourceTree = ""; }; E18186E11E8A47D60002509F /* HelpPreferencesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HelpPreferencesViewController.m; sourceTree = ""; }; - E1853390200E084500E88529 /* ABLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ABLog.h; sourceTree = ""; }; - E1853391200E084500E88529 /* ABLog.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ABLog.m; sourceTree = ""; }; E1902B461E16423200C3E0F6 /* ProjectAdvancedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectAdvancedViewController.h; sourceTree = ""; }; E1902B471E16423200C3E0F6 /* ProjectAdvancedViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectAdvancedViewController.m; sourceTree = ""; }; E1902B4D1E16617B00C3E0F6 /* NetworkHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkHandler.h; sourceTree = ""; }; @@ -511,15 +505,6 @@ path = ProjectModel; sourceTree = ""; }; - E14363781DF59AC700FB10CA /* LogViewController */ = { - isa = PBXGroup; - children = ( - E14363791DF59AFD00FB10CA /* LogViewController.h */, - E143637A1DF59AFD00FB10CA /* LogViewController.m */, - ); - path = LogViewController; - sourceTree = ""; - }; E14F332E1E1A3D1300C3DD34 /* MenuHandler */ = { isa = PBXGroup; children = ( @@ -601,7 +586,6 @@ E16437F01D743B3600CE8B7E /* HomeViewController */, E15C26671D7FD5A9004243B9 /* ShowLinkViewController */, E1AA0F411E2F325F00BA81A1 /* QRCodeViewController */, - E14363781DF59AC700FB10CA /* LogViewController */, E12E6D061D8FC6E20054814D /* DashboardViewController */, E1902B451E16420C00C3E0F6 /* ProjectAdvancedViewController */, E16D72E61E8935060031FB7C /* PreferencesViewController */, @@ -741,15 +725,6 @@ path = HelpPreferencesViewController; sourceTree = ""; }; - E185338F200E082800E88529 /* LogManager */ = { - isa = PBXGroup; - children = ( - E1853390200E084500E88529 /* ABLog.h */, - E1853391200E084500E88529 /* ABLog.m */, - ); - path = LogManager; - sourceTree = ""; - }; E1902B451E16420C00C3E0F6 /* ProjectAdvancedViewController */ = { isa = PBXGroup; children = ( @@ -873,7 +848,6 @@ E1902B4C1E16617B00C3E0F6 /* NetworkHandler */, E19473FC205FD3B700CF12F9 /* UISubClasses */, E19473F0205F9F2900CF12F9 /* ServiceIntegrations */, - E185338F200E082800E88529 /* LogManager */, E1902B501E16617B00C3E0F6 /* UserManager */, DB2629781F95ED8900C4C647 /* Extensions */, E1902B4B1E16617B00C3E0F6 /* MailHandler */, @@ -1048,7 +1022,6 @@ E16437DD1D743A4E00CE8B7E /* AppBox.xcdatamodeld in Sources */, E16437D71D743A4E00CE8B7E /* main.m in Sources */, DB831BCB1FF6B5780065B646 /* ABHudViewController.m in Sources */, - E1853392200E084500E88529 /* ABLog.m in Sources */, E1902B481E16423200C3E0F6 /* ProjectAdvancedViewController.m in Sources */, DBF290D71FA64A590046D5CE /* ProvisioningDetailsViewController.m in Sources */, DB358B66216FB1AC0080CAC0 /* UploadRecord+CoreDataClass.m in Sources */, @@ -1098,7 +1071,6 @@ E18186DF1E8A47CD0002509F /* EmailPreferencesViewController.m in Sources */, E13161F21E9777DF00586052 /* CIProjectBuilder.m in Sources */, 4410D19C26FF851D0046E5F9 /* CoreDataMigration3to4.xcmappingmodel in Sources */, - E143637B1DF59AFD00FB10CA /* LogViewController.m in Sources */, DB2629851F961F4700C4C647 /* DBErrorHandler.m in Sources */, E18186E21E8A47D60002509F /* HelpPreferencesViewController.m in Sources */, E18186CE1E8A3BC00002509F /* PreferencesTabViewController.m in Sources */, @@ -1252,8 +1224,8 @@ INFOPLIST_FILE = AppBox/Info.plist; LD_DYLIB_INSTALL_NAME = ""; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 3.1.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MARKETING_VERSION = 3.2.0; PRODUCT_BUNDLE_IDENTIFIER = com.developerinsider.AppBox; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)"; @@ -1298,8 +1270,8 @@ INFOPLIST_FILE = AppBox/Info.plist; LD_DYLIB_INSTALL_NAME = ""; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.11; - MARKETING_VERSION = 3.1.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; + MARKETING_VERSION = 3.2.0; PRODUCT_BUNDLE_IDENTIFIER = com.developerinsider.AppBox; PRODUCT_NAME = "$(TARGET_NAME)"; USER_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)"; diff --git a/AppBox/AppBox.entitlements b/AppBox/AppBox.entitlements index a0463869..8fa9cdb1 100644 --- a/AppBox/AppBox.entitlements +++ b/AppBox/AppBox.entitlements @@ -4,6 +4,8 @@ com.apple.security.app-sandbox + com.apple.security.files.downloads.read-write + com.apple.security.files.user-selected.read-write com.apple.security.network.client diff --git a/AppBox/AppBoxPrefixHeader.pch b/AppBox/AppBoxPrefixHeader.pch index 08f63627..faa70ad9 100644 --- a/AppBox/AppBoxPrefixHeader.pch +++ b/AppBox/AppBoxPrefixHeader.pch @@ -10,7 +10,7 @@ #define AppBoxPrefixHeader_pch -#import +#import #import #import #import @@ -18,8 +18,8 @@ #import #import #import +#import -#import "ABLog.h" #import "MBProgressHUD+ProgressHud.h" #import "UserData.h" @@ -52,4 +52,6 @@ #import "AppBoxService+CoreDataProperties.h" #import "ProvisionedDevice+CoreDataProperties.h" #import "ProvisioningProfile+CoreDataProperties.h" + +static const DDLogLevel ddLogLevel = DDLogLevelAll; #endif /* AppBoxPrefixHeader_pch */ diff --git a/AppBox/AppDelegate.h b/AppBox/AppDelegate.h index 6907f78a..ede6d32d 100644 --- a/AppBox/AppDelegate.h +++ b/AppBox/AppDelegate.h @@ -13,23 +13,26 @@ @interface AppDelegate : NSObject -@property (nonatomic, strong) NSMutableString *sessionLog; -@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; -@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; -@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; - -+(AppDelegate *)appDelegate; --(void)addSessionLog:(NSString *)sessionLog; --(void)saveCoreDataChanges; --(void)openFileWithPath:(NSString *)filePath; - +//stored properties @property (nonatomic) BOOL processing; @property (nonatomic) BOOL isReadyToBuild; @property (nonatomic) BOOL isInternetConnected; + +//menu iboutlet @property (nonatomic, weak) IBOutlet NSMenuItem *dropboxLogoutButton; @property (nonatomic, weak) IBOutlet NSMenuItem *dropboxSpaceButton; @property (nonatomic, weak) IBOutlet NSMenuItem *dropboxAccountButton; @property (nonatomic, weak) IBOutlet NSMenuItem *dropboxNameButton; +//coredata +@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; +@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; +@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; +-(void)saveCoreDataChanges; + ++(AppDelegate *)appDelegate; +-(void)openLatestLogFile; +-(void)openFileWithPath:(NSString *)filePath; + @end diff --git a/AppBox/AppDelegate.m b/AppBox/AppDelegate.m index 6fb8bd81..7d758329 100644 --- a/AppBox/AppDelegate.m +++ b/AppBox/AppDelegate.m @@ -8,25 +8,66 @@ #import "AppDelegate.h" -@implementation AppDelegate +@implementation AppDelegate { + DDFileLogger *fileLogger; +} - (void)awakeFromNib{ [super awakeFromNib]; //Handle URL Scheme [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLWithEvent:andReply:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + + //Init CocoaLumberjack + DDLogLevel logLevel = [UserData debugLog] ? DDLogLevelDebug : DDLogLevelInfo; + [DDLog addLogger:[DDOSLogger sharedInstance] withLevel:logLevel]; //OS logger + + //File logger + fileLogger = [[DDFileLogger alloc] init]; + fileLogger.doNotReuseLogFiles = true; + fileLogger.logFileManager.maximumNumberOfLogFiles = 7; + [DDLog addLogger:fileLogger withLevel:logLevel]; + DDLogInfo(@"AppBox Started."); //Init AppCenter [[NSUserDefaults standardUserDefaults] registerDefaults: @{ @"NSApplicationCrashOnExceptions": @YES }]; + // Setting userConfirmationHandler as documented on https://docs.microsoft.com/en-us/appcenter/sdk/crashes/macos#ask-for-the-users-consent-to-send-a-crash-log + [MSACCrashes setUserConfirmationHandler:^BOOL(NSArray * _Nonnull errorReports) + { + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = @"Sorry about that!"; + alert.informativeText = @"Do you want to send a crash report so we can fix the issue?"; + + [alert addButtonWithTitle:@"Always send"]; + [alert addButtonWithTitle:@"Send"]; + [alert addButtonWithTitle:@"Don't send"]; + alert.alertStyle = NSAlertStyleWarning; + + switch ([alert runModal]) + { + case NSAlertFirstButtonReturn: + [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationAlways]; + break; + case NSAlertSecondButtonReturn: + [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationSend]; + break; + case NSAlertThirdButtonReturn: + [MSACCrashes notifyWithUserConfirmation:MSACUserConfirmationDontSend]; + break; + default: + break; + + } + return true; // Return true if the SDK should await user confirmation, otherwise return false. + }]; + NSString *appCenter = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"AppCenter"]; [MSACAppCenter start:appCenter withServices: @[[MSACAnalytics class], [MSACCrashes class]]]; - [MSACCrashes notifyWithUserConfirmation: MSACUserConfirmationAlways]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; [center setDelegate:self]; - self.sessionLog = [[NSMutableString alloc] init]; //Default Setting [DefaultSettings setFirstTimeSettings]; @@ -43,15 +84,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { //Check for arguments NSArray *arguments = [[NSProcessInfo processInfo] arguments]; - [ABLog log:@"All Command Line Arguments = %@",arguments]; + DDLogDebug(@"All Command Line Arguments = %@",arguments); for (NSString *argument in arguments) { if ([argument containsString:abArgsIPA]) { NSArray *components = [argument componentsSeparatedByString:abArgsIPA]; - [ABLog log:@"IPA Components = %@",components]; + DDLogDebug(@"IPA Components = %@",components); if (components.count == 2) { [self handleIPAAtPath:[components lastObject]]; } else { - [self addSessionLog:[NSString stringWithFormat:@"Invalid IPA Argument %@",arguments]]; + DDLogInfo(@"Invalid IPA Argument %@",arguments); exit(abExitCodeForInvalidCommand); } break; @@ -62,6 +103,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { } - (void)applicationWillTerminate:(NSNotification *)aNotification { + DDLogInfo(@"AppBox Terminated."); [self saveCoreDataChanges]; } @@ -79,11 +121,11 @@ -(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename{ -(void)openFileWithPath:(NSString *)filePath{ if (self.isReadyToBuild) { - [ABLog log:@"AppBox is ready to use."]; + DDLogDebug(@"AppBox is ready to use."); [[NSNotificationCenter defaultCenter] postNotificationName:abUseOpenFilesNotification object:filePath]; } else { [[NSNotificationCenter defaultCenter] addObserverForName:abAppBoxReadyToUseNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { - [ABLog log:@"AppBox is ready to use. [Block]"]; + DDLogDebug(@"AppBox is ready to use. [Block]"); [[NSNotificationCenter defaultCenter] postNotificationName:abUseOpenFilesNotification object:filePath]; }]; } @@ -93,7 +135,7 @@ -(void)openFileWithPath:(NSString *)filePath{ -(BOOL)setAppBoxAsDefualt{ OSStatus returnStatus = LSSetDefaultRoleHandlerForContentType(CFSTR("com.apple.iTunes.ipa"), kLSRolesAll, (__bridge CFStringRef) [[NSBundle mainBundle] bundleIdentifier]); if (returnStatus != 0) { - NSLog(@"Got an error when setting default application - %d", (int)returnStatus); + DDLogInfo(@"Got an error when setting default application - %d", (int)returnStatus); return NO; } return YES; @@ -105,35 +147,38 @@ +(AppDelegate *)appDelegate{ return ((AppDelegate *)[[NSApplication sharedApplication] delegate]); } --(void)addSessionLog:(NSString *)sessionLog{ - NSLog(@"%@",sessionLog); - [_sessionLog appendFormat: @"%@\n",sessionLog]; - [[NSNotificationCenter defaultCenter] postNotificationName:abSessionLogUpdated object:nil]; +-(void)openLatestLogFile { + NSString *latestLogFile = fileLogger.logFileManager.sortedLogFilePaths.firstObject; + if (latestLogFile == nil) { + DDLogInfo(@"No log file found."); + } else { + [[NSWorkspace sharedWorkspace] openFile:latestLogFile]; + } } //URISchem URL Handler -(void)handleGetURLWithEvent:(NSAppleEventDescriptor *)event andReply:(NSAppleEventDescriptor *)reply{ NSURL *url = [NSURL URLWithString:[[event paramDescriptorForKeyword:keyDirectObject] stringValue]]; - [self addSessionLog:[NSString stringWithFormat:@"Handling URL = %@",url]]; + DDLogInfo(@"Handling URL = %@",url); //Check for Dropbox auth [DBClientsManager handleRedirectURL:url completion:^(DBOAuthResult * _Nullable authResult) { if (authResult != nil) { if ([authResult isSuccess]) { - [[AppDelegate appDelegate] addSessionLog:@"Success! User is logged into Dropbox."]; + DDLogInfo(@"Success! User is logged into Dropbox."); [EventTracker logEventWithType:LogEventTypeAuthDropboxSuccess]; [[NSNotificationCenter defaultCenter] postNotificationName:abDropBoxLoggedInNotification object:nil]; } else if ([authResult isCancel]) { - [[AppDelegate appDelegate] addSessionLog:@"Authorization flow was manually canceled by user."]; + DDLogInfo(@"Authorization flow was manually canceled by user."); [EventTracker logEventWithType:LogEventTypeAuthDropboxCanceled]; [Common showAlertWithTitle:@"Authorization Canceled." andMessage:abEmptyString]; } else if ([authResult isError]) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Error: %@", authResult.errorDescription]]; + DDLogInfo(@"Error: %@", authResult.errorDescription); [EventTracker logEventWithType:LogEventTypeAuthDropboxError]; [Common showAlertWithTitle:@"Authorization Canceled." andMessage:abEmptyString]; } } else if (url != nil) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"query = %@", url.query]]; + DDLogInfo(@"query = %@", url.query); // if (url.query != nil && url.query.length > 0) { // [self handleProjectAtPath:url.query]; // } @@ -144,11 +189,11 @@ -(void)handleGetURLWithEvent:(NSAppleEventDescriptor *)event andReply:(NSAppleEv -(void)handleIPAAtPath:(NSString *)ipaPath { XCProject *project = [CIProjectBuilder xcProjectWithIPAPath:ipaPath]; if (self.isReadyToBuild) { - [self addSessionLog:@"AppBox is ready to upload IPA."]; + DDLogInfo(@"AppBox is ready to upload IPA."); [[NSNotificationCenter defaultCenter] postNotificationName:abBuildRepoNotification object:project]; } else { [[NSNotificationCenter defaultCenter] addObserverForName:abAppBoxReadyToUseNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) { - [self addSessionLog:@"AppBox is ready to upload IPA. [Block]"]; + DDLogInfo(@"AppBox is ready to upload IPA. [Block]"); [[NSNotificationCenter defaultCenter] postNotificationName:abBuildRepoNotification object:project]; }]; } diff --git a/AppBox/Common/CIProjectBuilder/CIProjectBuilder.m b/AppBox/Common/CIProjectBuilder/CIProjectBuilder.m index 4300015d..50edb886 100644 --- a/AppBox/Common/CIProjectBuilder/CIProjectBuilder.m +++ b/AppBox/Common/CIProjectBuilder/CIProjectBuilder.m @@ -47,19 +47,19 @@ + (XCProject *)xcProjectWithIPAPath:(NSString *)ipaPath { //MARK: - Common Arguments +(void)setCommonArgumentsToProject:(XCProject *)project { NSArray *arguments = [[NSProcessInfo processInfo] arguments]; - [ABLog log:@"All Command Line Arguments = %@",arguments]; + DDLogDebug(@"All Command Line Arguments = %@",arguments); for (NSString *argument in arguments) { //Project Emails if ([argument containsString:abArgsEmails]) { NSArray *components = [argument componentsSeparatedByString:abArgsEmails]; - [ABLog log:@"Email Components = %@", components]; + DDLogDebug(@"Email Components = %@", components); if (components.count == 2) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project Emails to \"%@\" from \"%@\"", [components lastObject], project.emails]]; + DDLogInfo(@"Changing project Emails to \"%@\" from \"%@\"", [components lastObject], project.emails); project.emails = [components lastObject]; } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Emails Argument \"%@\"",arguments]]; + DDLogInfo(@"Invalid Emails Argument \"%@\"",arguments); exit(abExitCodeForInvalidCommand); } } @@ -67,12 +67,12 @@ +(void)setCommonArgumentsToProject:(XCProject *)project { //Project Personal Messages else if ([argument containsString:abArgsPersonalMessage]) { NSArray *components = [argument componentsSeparatedByString:abArgsPersonalMessage]; - [ABLog log:@"Personal Message Components = %@", components]; + DDLogDebug(@"Personal Message Components = %@", components); if (components.count == 2) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing project personal message to \"%@\" from \"%@\"", [components lastObject], project.personalMessage]]; + DDLogInfo(@"Changing project personal message to \"%@\" from \"%@\"", [components lastObject], project.personalMessage); project.personalMessage = [components lastObject]; } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Personal Message Argument \"%@\"",arguments]]; + DDLogInfo(@"Invalid Personal Message Argument \"%@\"",arguments); exit(abExitCodeForInvalidCommand); } } @@ -80,12 +80,12 @@ +(void)setCommonArgumentsToProject:(XCProject *)project { //Project Keep Same Link else if ([argument containsString:abArgsKeepSameLink]) { NSArray *components = [argument componentsSeparatedByString:abArgsKeepSameLink]; - [ABLog log:@"Keep Same Links Components = %@", components]; + DDLogDebug(@"Keep Same Links Components = %@", components); if (components.count == 2) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing Keep Same Link to \"%@\" from \"%@\"", [components lastObject], project.keepSameLink]]; + DDLogInfo(@"Changing Keep Same Link to \"%@\" from \"%@\"", [components lastObject], project.keepSameLink); project.keepSameLink = ([[components lastObject] isEqualToString:@"0"] || ((BOOL)[[components lastObject] boolValue]) == NO) ? @0 : @1; } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Keep Same Link Argument \"%@\"",arguments]]; + DDLogInfo(@"Invalid Keep Same Link Argument \"%@\"",arguments); exit(abExitCodeForInvalidCommand); } } @@ -93,14 +93,14 @@ +(void)setCommonArgumentsToProject:(XCProject *)project { //Project dropbox folder name else if ([argument containsString:abArgsDropBoxFolderName]) { NSArray *components = [argument componentsSeparatedByString:abArgsDropBoxFolderName]; - [ABLog log:@"Dropbox folder Components = %@", components]; + DDLogDebug(@"Dropbox folder Components = %@", components); if (components.count == 2) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Changing Dropbox folder name to \"%@\" from \"%@\"", [components lastObject], project.personalMessage]]; + DDLogInfo(@"Changing Dropbox folder name to \"%@\" from \"%@\"", [components lastObject], project.personalMessage); NSString *bundlePath = [NSString stringWithFormat:@"/%@",[components lastObject]]; bundlePath = [bundlePath stringByReplacingOccurrencesOfString:@" " withString:abEmptyString]; project.bundleDirectory = [NSURL URLWithString:bundlePath]; } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Invalid Dropbox Folder Name Argument \"%@\"",arguments]]; + DDLogInfo(@"Invalid Dropbox Folder Name Argument \"%@\"",arguments); exit(abExitCodeForInvalidCommand); } } diff --git a/AppBox/Common/Common.m b/AppBox/Common/Common.m index 522d2281..eb6732a2 100644 --- a/AppBox/Common/Common.m +++ b/AppBox/Common/Common.m @@ -34,7 +34,7 @@ +(NSError *)errorWithDesc:(NSString *)error andCode:(NSInteger)code{ //MARK: - Notifications + (NSModalResponse)showAlertWithTitle:(NSString *)title andMessage:(NSString *)message{ - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"ALERT -\nTitle - %@ Message - %@", title, message]]; + DDLogInfo(@"ALERT -\nTitle - %@ Message - %@", title, message); NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText: title == nil ? @"Error" : title]; [alert setInformativeText:message == nil ? @"" : message]; diff --git a/AppBox/Common/Constants.h b/AppBox/Common/Constants.h index e2ed75a5..7acf275e 100644 --- a/AppBox/Common/Constants.h +++ b/AppBox/Common/Constants.h @@ -40,7 +40,6 @@ static NSString *const FILE_NAME_UNIQUE_JSON = @"appinfo.json"; static NSString *const FILE_NAME_SHARE_URL = @".appbox_share_value.json"; //notification -#define abSessionLogUpdated @"SessionLogUpdated" #define abDropBoxLoggedInNotification @"DropBoxLoggedInNotification" #define abDropBoxLoggedOutNotification @"DropBoxLoggedOutNotification" #define abBuildRepoNotification @"BuildRepoNotification" diff --git a/AppBox/Common/LogManager/ABLog.h b/AppBox/Common/LogManager/ABLog.h deleted file mode 100644 index ff47ea84..00000000 --- a/AppBox/Common/LogManager/ABLog.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ABLog.h -// AppBox -// -// Created by Vineet Choudhary on 16/01/18. -// Copyright © 2018 Developer Insider. All rights reserved. -// - -#import - -@interface ABLog : NSObject - -+(void)log:(NSString *)format, ...; - -@end diff --git a/AppBox/Common/LogManager/ABLog.m b/AppBox/Common/LogManager/ABLog.m deleted file mode 100644 index cdddcea8..00000000 --- a/AppBox/Common/LogManager/ABLog.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// ABLog.m -// AppBox -// -// Created by Vineet Choudhary on 16/01/18. -// Copyright © 2018 Developer Insider. All rights reserved. -// - -#import "ABLog.h" - -@implementation ABLog - -+(void)log:(NSString *)format, ...{ - if ([UserData debugLog]) { - va_list args; - va_start(args, format); - NSLogv(format, args); - va_end(args); - } -} - -@end diff --git a/AppBox/Common/NetworkHandler/NetworkHandler.m b/AppBox/Common/NetworkHandler/NetworkHandler.m index 02b2c940..b20b5c59 100644 --- a/AppBox/Common/NetworkHandler/NetworkHandler.m +++ b/AppBox/Common/NetworkHandler/NetworkHandler.m @@ -17,7 +17,7 @@ +(void)requestWithURL:(NSString *)url withParameters:(id)parmeters andRequestTyp [manager setResponseSerializer: [AFJSONResponseSerializer serializer]]; if (requestType == RequestGET){ [manager GET:url parameters:parmeters headers:nil progress:^(NSProgress * _Nonnull downloadProgress) { - [ABLog log:@"Request In Progress - %@", url]; + DDLogDebug(@"Request In Progress - %@", url); } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSInteger statusCode = ((NSHTTPURLResponse *)task.response).statusCode; completion(responseObject, statusCode, nil); @@ -31,7 +31,7 @@ +(void)requestWithURL:(NSString *)url withParameters:(id)parmeters andRequestTyp }]; }else if (requestType == RequestPOST){ [manager POST:url parameters:parmeters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) { - [ABLog log:@"Request In Progress - %@", url]; + DDLogDebug(@"Request In Progress - %@", url); } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSInteger statusCode = ((NSHTTPURLResponse *)task.response).statusCode; completion(responseObject, statusCode, nil); @@ -53,7 +53,7 @@ +(void)getContentOfURL:(NSString *)url withParameters:(id)parmeters withRequestT [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"application/javascript", @"text/html", @"text/javascript", nil]]; if (requestType == RequestGET){ [manager GET:url parameters:parmeters headers:nil progress:^(NSProgress * _Nonnull downloadProgress) { - [ABLog log:@"Request In Progress - %@", url]; + DDLogDebug(@"Request In Progress - %@", url); } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { completion(responseObject, ((NSHTTPURLResponse *)task.response).statusCode ,nil); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { @@ -61,7 +61,7 @@ +(void)getContentOfURL:(NSString *)url withParameters:(id)parmeters withRequestT }]; }else if (requestType == RequestPOST){ [manager POST:url parameters:parmeters headers:nil progress:^(NSProgress * _Nonnull uploadProgress) { - [ABLog log:@"Request In Progress - %@", url]; + DDLogDebug(@"Request In Progress - %@", url); } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { completion(responseObject, ((NSHTTPURLResponse *)task.response).statusCode ,nil); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { diff --git a/AppBox/Common/ServiceIntegrations/HangoutClient/HangoutClient.m b/AppBox/Common/ServiceIntegrations/HangoutClient/HangoutClient.m index 72c441ba..d953258c 100644 --- a/AppBox/Common/ServiceIntegrations/HangoutClient/HangoutClient.m +++ b/AppBox/Common/ServiceIntegrations/HangoutClient/HangoutClient.m @@ -29,13 +29,13 @@ + (void)sendMessageForProject:(XCProject *)project completion:(void (^) (BOOL su //send message [NetworkHandler requestWithURL:webHookURL withParameters:parameters andRequestType:RequestPOST andCompletetion:^(id responseObj, NSInteger httpStatus, NSError *error) { if (responseObj && error == nil) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Hangout Response - %@", responseObj]]; + DDLogInfo(@"Hangout Response - %@", responseObj); completion(YES); } else if (error) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Hangout Chat Error - %@", error.localizedDescription]]; + DDLogInfo(@"Hangout Chat Error - %@", error.localizedDescription); completion(NO); } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Hangout Chat Error - Unknown Error"]]; + DDLogInfo(@"Hangout Chat Error - Unknown Error"); completion(NO); } }]; diff --git a/AppBox/Common/ServiceIntegrations/MSTeamsClient/MSTeamsClient.m b/AppBox/Common/ServiceIntegrations/MSTeamsClient/MSTeamsClient.m index fc41e8b9..a3861cd2 100644 --- a/AppBox/Common/ServiceIntegrations/MSTeamsClient/MSTeamsClient.m +++ b/AppBox/Common/ServiceIntegrations/MSTeamsClient/MSTeamsClient.m @@ -29,13 +29,13 @@ + (void)sendMessageForProject:(XCProject *)project completion:(void (^) (BOOL su //send message [NetworkHandler requestWithURL:webHookURL withParameters:parameters andRequestType:RequestPOST andCompletetion:^(id responseObj, NSInteger httpStatus, NSError *error) { if (responseObj && error == nil) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Microsoft Team Response - %@", responseObj]]; + DDLogInfo(@"Microsoft Team Response - %@", responseObj); completion(YES); } else if (error) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Microsoft Team Error - %@", error.localizedDescription]]; + DDLogInfo(@"Microsoft Team Error - %@", error.localizedDescription); completion(NO); } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Microsoft Team Error - Unknown Error"]]; + DDLogInfo(@"Microsoft Team Error - Unknown Error"); completion(NO); } }]; diff --git a/AppBox/Common/ServiceIntegrations/SlackClient/SlackClient.m b/AppBox/Common/ServiceIntegrations/SlackClient/SlackClient.m index 83f67392..0c1cd03a 100644 --- a/AppBox/Common/ServiceIntegrations/SlackClient/SlackClient.m +++ b/AppBox/Common/ServiceIntegrations/SlackClient/SlackClient.m @@ -32,13 +32,13 @@ + (void)sendMessageForProject:(XCProject *)project completion:(void (^) (BOOL su //send message [NetworkHandler requestWithURL:channelURL withParameters:parameters andRequestType:RequestPOST andCompletetion:^(id responseObj, NSInteger httpStatus, NSError *error) { if (responseObj && error == nil) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Slack Response - %@", responseObj]]; + DDLogInfo(@"Slack Response - %@", responseObj); completion(YES); } else if (error) { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Slack Error - %@", error.localizedDescription]]; + DDLogInfo(@"Slack Error - %@", error.localizedDescription); completion(NO); } else { - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Slack Error - Unknown Error"]]; + DDLogInfo(@"Slack Error - Unknown Error"); completion(NO); } }]; diff --git a/AppBox/Common/UpdateHandler/UpdateHandler.m b/AppBox/Common/UpdateHandler/UpdateHandler.m index 43e9131e..babd3fa2 100644 --- a/AppBox/Common/UpdateHandler/UpdateHandler.m +++ b/AppBox/Common/UpdateHandler/UpdateHandler.m @@ -32,33 +32,38 @@ + (void)showAlreadyUptoDateAlert{ + (void)isNewVersionAvailableCompletion:(void (^)(bool available, NSURL *url))completion{ @try { - [ABLog log:@"Checking for new version..."]; + DDLogDebug(@"Checking for new version..."); [NetworkHandler requestWithURL:abGitHubLatestRelease withParameters:nil andRequestType:RequestGET andCompletetion:^(id responseObj, NSInteger httpStatus, NSError *error) { //handle error and check for all required keys - if (error == nil && - [((NSDictionary *)responseObj).allKeys containsObject:@"tag_name"] && - [((NSDictionary *)responseObj).allKeys containsObject:@"html_url"]){ - - //get tag name, because it's always be latest version - NSString *tag = [responseObj valueForKey:@"tag_name"]; - NSString *newVesion = [[tag componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:abEmptyString]; - - //get version string from bundle info.plist - NSString *versionString = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]; - NSString *currentVersion = [[versionString componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:abEmptyString]; - - //log current and latest version - [ABLog log:@"\n\nCurrent Version - %@ <=> Latest Version - %@\n\n", versionString, tag]; - - //return result based on version strings - completion(([newVesion compare:currentVersion] == NSOrderedDescending),[NSURL URLWithString:[responseObj valueForKey:@"html_url"]]); - }else{ - completion(false, nil); - } + @try { + if (error == nil && + [((NSDictionary *)responseObj).allKeys containsObject:@"tag_name"] && + [((NSDictionary *)responseObj).allKeys containsObject:@"html_url"]){ + + //get tag name, because it's always be latest version + NSString *tag = [responseObj valueForKey:@"tag_name"]; + NSString *newVesion = [[tag componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:abEmptyString]; + + //get version string from bundle info.plist + NSString *versionString = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"]; + NSString *currentVersion = [[versionString componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:abEmptyString]; + + //log current and latest version + DDLogDebug(@"\n\nCurrent Version - %@ <=> Latest Version - %@\n\n", versionString, tag); + + //return result based on version strings + completion(([newVesion compare:currentVersion] == NSOrderedDescending),[NSURL URLWithString:[responseObj valueForKey:@"html_url"]]); + }else{ + completion(false, nil); + } + } + @catch (NSException *exception) { + [EventTracker logExceptionEvent:exception]; + } }]; } @catch (NSException *exception) { completion(false, nil); - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Exception %@",exception.userInfo]]; + DDLogInfo(@"Exception %@",exception.userInfo); } } diff --git a/AppBox/Common/UploadManager/UploadManager.m b/AppBox/Common/UploadManager/UploadManager.m index 82b174c0..d0eb5a54 100644 --- a/AppBox/Common/UploadManager/UploadManager.m +++ b/AppBox/Common/UploadManager/UploadManager.m @@ -49,20 +49,20 @@ - (void)createNewWorkingDirectory { NSError *error = nil; [[NSFileManager defaultManager] createDirectoryAtPath:workingDirectory withIntermediateDirectories:YES attributes:nil error:&error]; if (error == nil) { - [ABLog log:@"New temporaray working directory %@", workingDirectory]; + DDLogDebug(@"New temporaray working directory %@", workingDirectory); } else { - [ABLog log:@"Unable to create temporary working directory %@", workingDirectory]; + DDLogInfo(@"Unable to create temporary working directory %@", workingDirectory); } } //MARK: - UnZip IPA File -(void)uploadIPAFile:(NSURL *)ipaFileURL{ - [ABLog log:@"Preparing to Upload IPA - %@", ipaFileURL]; + DDLogDebug(@"Preparing to Upload IPA - %@", ipaFileURL); NSString *ipaPath = [ipaFileURL.resourceSpecifier stringByRemovingPercentEncoding]; weakify(self); if ([[NSFileManager defaultManager] fileExistsAtPath:ipaPath]) { - [ABLog log:@"Uploading IPA - %@", ipaPath]; + DDLogDebug(@"Uploading IPA - %@", ipaPath); //Unzip ipa __block NSString *payloadEntry; __block NSString *infoPlistPath; @@ -70,7 +70,8 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ // Create new temp working directory [self createNewWorkingDirectory]; - [ABLog log:@"Extracting Files to - %@", workingDirectory]; + DDLogInfo(@"Extracting IPA file..."); + DDLogDebug(@"Extracting Files to - %@", workingDirectory); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ [SSZipArchive unzipFileAtPath:ipaPath toDestination:self->workingDirectory @@ -87,7 +88,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ [[entry pathComponents] enumerateObjectsUsingBlock:^(NSString * _Nonnull pathComponent, NSUInteger idx, BOOL * _Nonnull stop) { if ((pathComponent.length > 4) && [[pathComponent substringFromIndex:(pathComponent.length-4)].lowercaseString isEqualToString: @".app"]) { - [ABLog log:@"Found payload at path = %@",entry]; + DDLogDebug(@"Found payload at path = %@",entry); payloadEntry = [NSString pathWithComponents:[[entry pathComponents] subarrayWithRange:NSMakeRange(0, idx+1)]]; *stop = YES; } @@ -97,7 +98,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ //Get Info.plist entry NSString *mainInfoPlistPath = [payloadEntry stringByAppendingPathComponent:@"Info.plist"].lowercaseString; if ([entry.lowercaseString isEqualToString:mainInfoPlistPath]) { - [ABLog log:@"Found Info.plist at path = %@",mainInfoPlistPath]; + DDLogDebug(@"Found Info.plist at path = %@",mainInfoPlistPath); infoPlistPath = entry; } @@ -105,14 +106,14 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ if (self.project.mobileProvision == nil){ NSString *mobileProvisionPath = [payloadEntry stringByAppendingPathComponent:@"embedded.mobileprovision"].lowercaseString; if ([entry.lowercaseString isEqualToString:mobileProvisionPath]){ - [ABLog log:@"Found mobileprovision at path = %@",mobileProvisionPath]; + DDLogDebug(@"Found mobileprovision at path = %@",mobileProvisionPath); mobileProvisionPath = [self->workingDirectory stringByAppendingPathComponent: mobileProvisionPath]; self.project.mobileProvision = [[MobileProvision alloc] initWithPath:mobileProvisionPath]; } } //show status and log files entry - [ABLog log:@"%@-%@-%@",[NSNumber numberWithLong:entryNumber], [NSNumber numberWithLong:total], entry]; + DDLogDebug(@"%@-%@-%@",[NSNumber numberWithLong:entryNumber], [NSNumber numberWithLong:total], entry); }); } completionHandler:^(NSString * _Nonnull path, BOOL succeeded, NSError * _Nonnull error) { strongify(self); @@ -120,8 +121,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ if (error) { //show error and return if (self.ciRepoProject) { - NSString *log = [NSString stringWithFormat:@"Error - %@", error.localizedDescription]; - [[AppDelegate appDelegate] addSessionLog:log]; + DDLogInfo(@"Error - %@", error.localizedDescription); exit(abExitCodeUnZipIPAError); } else { [Common showAlertWithTitle:@"AppBox - Error" andMessage:error.localizedDescription]; @@ -131,17 +131,16 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ } //get info.plist - [ABLog log:@"Final Info.plist path = %@",infoPlistPath]; + DDLogDebug(@"Final Info.plist path = %@",infoPlistPath); [self.project setIpaInfoPlist: [NSDictionary dictionaryWithContentsOfFile:[self->workingDirectory stringByAppendingPathComponent:infoPlistPath]]]; //show error if info.plist is nil or invalid if (![self.project isValidProjectInfoPlist]) { - NSString *log = @"AppBox was not able to find Info.plist in your IPA."; if (self.ciRepoProject) { - [[AppDelegate appDelegate] addSessionLog:log]; + DDLogInfo(@"AppBox was not able to find Info.plist in your IPA."); exit(abExitCodeInfoPlistNotFound); } else { - [Common showAlertWithTitle:@"AppBox - Error" andMessage:log]; + [Common showAlertWithTitle:@"AppBox - Error" andMessage:@"AppBox was not able to find Info.plist in your IPA."]; } self.errorBlock(nil, YES); return; @@ -168,7 +167,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ }]; }); }else{ - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"\n\n======\nFile Not Exist - %@\n======\n\n",ipaPath]]; + DDLogInfo(@"\n\n======\nFile Not Exist - %@\n======\n\n",ipaPath); if (self.ciRepoProject) { exit(abExitCodeIPAFileNotFound); } else { @@ -179,7 +178,7 @@ -(void)uploadIPAFile:(NSURL *)ipaFileURL{ } -(void)uploadIPAFileWithoutUnzip:(NSURL *)ipaURL{ - [ABLog log:@"IPA Info.plist %@", self.project.ipaInfoPlist]; + DDLogDebug(@"IPA Info.plist %@", self.project.ipaInfoPlist); //upload ipa self.dbFileType = DBFileTypeIPA; @@ -224,7 +223,7 @@ -(void)handleAfterUniqueJsonMetaDataLoaded{ -(NSDictionary *)getUniqueJsonDict{ NSError *error; NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:[workingDirectory stringByAppendingPathComponent:FILE_NAME_UNIQUE_JSON]] options:kNilOptions error:&error]; - [ABLog log:@"%@ : %@",FILE_NAME_UNIQUE_JSON,dictionary]; + DDLogDebug(@"%@ : %@",FILE_NAME_UNIQUE_JSON,dictionary); return dictionary; } @@ -371,7 +370,7 @@ -(void)loadAppInfoMetaData{ strongify(self); //check there is any rev available if (response && response.isDeleted.boolValue == NO && response.entries.count > 0){ - [ABLog log:@"Loaded Meta Data %@",response]; + DDLogDebug(@"Loaded Meta Data %@",response); self.project.uniqueLinkJsonMetaData = [response.entries firstObject]; } @@ -384,7 +383,7 @@ -(void)loadAppInfoMetaData{ //MARK: - Upload Files -(void)dbUploadFile:(NSString *)file to:(NSString *)path mode:(DBFILESWriteMode *)mode{ - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Uploading - %@", file.lastPathComponent]]; + DDLogInfo(@"Uploading - %@", file.lastPathComponent); //Upload large ipa file with dropbox session api if (_project.ipaFileSize.integerValue > 150 && self.dbFileType == DBFileTypeIPA) { @@ -402,7 +401,7 @@ -(void)dbUploadFile:(NSString *)file to:(NSString *)path mode:(DBFILESWriteMode //reset retry count self->retryCount = 0; - [ABLog log:@"Uploaded file metadata = %@", response]; + DDLogDebug(@"Uploaded file metadata = %@", response); //AppInfo.json file uploaded and creating shared url if(self.dbFileType == DBFileTypeJson){ @@ -547,7 +546,7 @@ -(void)handleChunkUploadWithRouteError:(DBFILESUploadSessionAppendError * _Nulla else if (networkError && retryCount < abOnErrorMaxRetryCount && [[AppDelegate appDelegate] isInternetConnected] && (networkError.tag == DBRequestErrorClient || networkError.tag == DBRequestErrorInternalServer)) { retryCount++; - [[AppDelegate appDelegate] addSessionLog: [NSString stringWithFormat:@"Retrying (%ld) IPA Upload due to some error.", (long)retryCount]]; + DDLogInfo(@"Retrying (%ld) IPA Upload due to some error.", (long)retryCount); [operation start]; } @@ -611,7 +610,7 @@ -(void)dbGetSharedURLForFile:(NSString *)file{ } -(void)handleSharedURLError:(DBRequestError *)error forFile:(NSString *)file{ - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Create Share Link Error - %@",error]]; + DDLogInfo(@"Create Share Link Error - %@",error); //Handle clint side SDK error if ([error isClientError]){ @@ -633,7 +632,7 @@ -(void)handleSharedURLError:(DBRequestError *)error forFile:(NSString *)file{ else if (retryCount < abOnErrorMaxRetryCount) { retryCount++; [self dbCreateSharedURLForFile:file]; - [[AppDelegate appDelegate] addSessionLog: [NSString stringWithFormat:@"Retrying (%ld) Shared URL due to some error.", (long)retryCount]]; + DDLogInfo(@"Retrying (%ld) Shared URL due to some error.", (long)retryCount); } //Handle other errors @@ -677,7 +676,7 @@ -(void)handleSharedURLResult:(NSString *)url{ //if same link enable load appinfo.json otherwise Create short shareable url of manifest else if (self.dbFileType == DBFileTypeManifest){ NSString *shareableLink = [url substringToIndex:url.length-5]; - [ABLog log:@"Manifest Sharable link - %@",shareableLink]; + DDLogDebug(@"Manifest Sharable link - %@",shareableLink); self.project.manifestFileSharableURL = [NSURL URLWithString:shareableLink]; if(self.project.isKeepSameLinkEnabled){ //Download previously uploaded appinfo @@ -686,7 +685,7 @@ -(void)handleSharedURLResult:(NSString *)url{ strongify(self); //check there is any rev available if (response && response.isDeleted.boolValue == NO && response.entries.count > 0){ - [ABLog log:@"Loaded Meta Data %@",response]; + DDLogDebug(@"Loaded Meta Data %@",response); self.project.uniqueLinkJsonMetaData = [response.entries firstObject]; } @@ -701,7 +700,7 @@ -(void)handleSharedURLResult:(NSString *)url{ //create app info file short sharable url else if (self.dbFileType == DBFileTypeJson){ NSString *shareableLink = [url substringToIndex:url.length-5]; - [ABLog log:@"APPInfo Sharable link - %@",shareableLink]; + DDLogDebug(@"APPInfo Sharable link - %@",shareableLink); self.project.uniquelinkShareableURL = [NSURL URLWithString:shareableLink]; NSMutableDictionary *dictUniqueFile = [[self getUniqueJsonDict] mutableCopy]; [dictUniqueFile setObject:shareableLink forKey:UNIQUE_LINK_SHARED]; @@ -723,7 +722,7 @@ -(void)createUniqueShortSharableUrl{ dispatch_async(dispatch_get_main_queue(), ^{ if (error) { self.project.appLongShareableURL = shortURL; - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Error in creating short URL - %@", error.localizedDescription]]; + DDLogInfo(@"Error in creating short URL - %@", error.localizedDescription); } [self createAndUploadJsonWithURL:shortURL]; }); @@ -794,7 +793,7 @@ -(void)deleteBuildDetailsFromAppInfoJSON{ //MARK: - Show Status -(void)showStatus:(NSString *)status andShowProgressBar:(BOOL)showProgressBar withProgress:(double)progress{ //log status in session log - [ABLog log:@"%@",status]; + DDLogDebug(@"%@",status); //start/stop/progress based on showProgressBar and progress if (progress == -1){ diff --git a/AppBox/Model/CoreDataModel/Project+CoreDataClass.m b/AppBox/Model/CoreDataModel/Project+CoreDataClass.m index 1ffb77da..70eea9f1 100644 --- a/AppBox/Model/CoreDataModel/Project+CoreDataClass.m +++ b/AppBox/Model/CoreDataModel/Project+CoreDataClass.m @@ -126,7 +126,7 @@ +(Project *)addProjectWithXCProject:(XCProject *)xcProject{ } } @catch (NSException *exception) { [EventTracker logExceptionEvent:exception]; - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Exception %@",exception.userInfo]]; + DDLogInfo(@"Exception %@",exception.userInfo); } } @@ -147,7 +147,7 @@ +(Project *)addProjectWithXCProject:(XCProject *)xcProject{ } } @catch (NSException *exception) { [EventTracker logExceptionEvent:exception]; - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"Exception %@",exception.userInfo]]; + DDLogInfo(@"Exception %@",exception.userInfo); } return nil; } diff --git a/AppBox/Model/ProjectModel/XCProject.m b/AppBox/Model/ProjectModel/XCProject.m index 6e0f29e6..14937369 100644 --- a/AppBox/Model/ProjectModel/XCProject.m +++ b/AppBox/Model/ProjectModel/XCProject.m @@ -54,16 +54,16 @@ -(void)createManifestWithIPAURL:(NSURL *)ipaURL completion:(void(^)(NSURL *manif NSMutableDictionary *manifestDict = [[NSMutableDictionary alloc] init]; [manifestDict setValue:[NSArray arrayWithObjects:mainItemDict, nil] forKey:@"items"]; - [ABLog log:@"\n\n======\nManifest\n======\n\n %@",manifestDict]; + DDLogDebug(@"\n\n======\nManifest\n======\n\n %@",manifestDict); NSString *manifestPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"manifest.plist"]; if ([manifestDict writeToFile:manifestPath atomically:YES]){ - [ABLog log:@"Menifest File Created and Saved at %@", manifestPath]; + DDLogDebug(@"Menifest File Created and Saved at %@", manifestPath); dispatch_async(dispatch_get_main_queue(), ^{ completion([NSURL fileURLWithPath:manifestPath]); }); }else{ - [[AppDelegate appDelegate] addSessionLog:@"Can't able to save menifest file"]; + DDLogInfo(@"Can't able to save menifest file"); completion(nil); } } diff --git a/AppBox/ViewController/HomeViewController/HomeViewController.m b/AppBox/ViewController/HomeViewController/HomeViewController.m index 3d42472d..ac484962 100644 --- a/AppBox/ViewController/HomeViewController/HomeViewController.m +++ b/AppBox/ViewController/HomeViewController/HomeViewController.m @@ -124,9 +124,7 @@ -(void)setupUploadManager{ - (void)initCIProcess:(NSNotification *)notification { if ([notification.object isKindOfClass:[XCProject class]]) { self.ciRepoProject = notification.object; - if (self.ciRepoProject.ipaFullPath) { - [self initIPAUploadProcessForURL:self.ciRepoProject.ipaFullPath]; - } + [self initIPAUploadProcessForCIProject:self.ciRepoProject]; } } @@ -165,13 +163,22 @@ - (IBAction)selectedFilePathHandler:(NSPathControl *)sender { } } -- (void)initIPAUploadProcessForURL:(NSURL *)ipaURL { +- (void)initIPAUploadProcessForCIProject:(XCProject *)ciProject { + NSURL *ipaURL = ciProject.ipaFullPath; + if (ipaURL == nil) { + return; + } + [self viewStateForProgressFinish:YES]; [self.project setIpaFullPath:ipaURL]; [selectedFilePath setURL:ipaURL]; - [textFieldEmail setStringValue:self.project.emails]; - [textFieldMessage setStringValue:self.project.personalMessage]; - [buttonUniqueLink setState:self.project.keepSameLink.boolValue ? NSOnState : NSOffState]; + if (ciProject.emails.length != 0) { + [textFieldEmail setStringValue:ciProject.emails]; + } + if (ciProject.personalMessage.length != 0) { + [textFieldMessage setStringValue:ciProject.personalMessage]; + } + [buttonUniqueLink setState:ciProject.keepSameLink.boolValue ? NSOnState : NSOffState]; [self actionButtonTapped:buttonAction]; } @@ -222,7 +229,7 @@ - (IBAction)textFieldDevMessageValueChanged:(NSTextField *)sender { - (IBAction)actionButtonTapped:(NSButton *)sender { if (textFieldEmail.stringValue.isEmpty || [MailHandler isAllValidEmail:textFieldEmail.stringValue]){ if ([AppDelegate appDelegate].processing){ - [[AppDelegate appDelegate] addSessionLog:@"A request already in progress."]; + DDLogInfo(@"A request already in progress."); return; } @@ -272,7 +279,7 @@ - (void)dropboxLogoutHandler:(id)sender{ //MARK: - Controller Helpers - -(void)viewStateForProgressFinish:(BOOL)finish{ - [ABLog log:@"Updating view setting for finish - %@", [NSNumber numberWithBool:finish]]; + DDLogDebug(@"Updating view setting for finish - %@", [NSNumber numberWithBool:finish]); [[AppDelegate appDelegate] setProcessing:!finish]; [[AppDelegate appDelegate] setIsReadyToBuild:finish]; @@ -301,7 +308,7 @@ -(void)viewStateForProgressFinish:(BOOL)finish{ -(void)showStatus:(NSString *)status andShowProgressBar:(BOOL)showProgressBar withProgress:(double)progress{ //log status in session log - [[AppDelegate appDelegate]addSessionLog:[NSString stringWithFormat:@"%@",status]]; + DDLogInfo(@"%@",status); //start/stop/progress based on showProgressBar and progress if (progress == -1){ @@ -395,7 +402,7 @@ -(void)logAppUploadEventAndShareURLOnSlackChannel{ if (self.ciRepoProject == nil) { [Common showUploadNotificationWithName:self.project.name andURL:self.project.appShortShareableURL]; } - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@".\n\n\nSHARE URL - %@\n\n\n.", self.project.appShortShareableURL]]; + DDLogInfo(@"\n\n\nSHARE URL - %@\n\n\n.", self.project.appShortShareableURL); if ([UserData userSlackMessage].length > 0) { diff --git a/AppBox/ViewController/LogViewController/LogViewController.h b/AppBox/ViewController/LogViewController/LogViewController.h deleted file mode 100644 index 61ad9e6f..00000000 --- a/AppBox/ViewController/LogViewController/LogViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// LogViewController.h -// AppBox -// -// Created by Vineet Choudhary on 05/12/16. -// Copyright © 2016 Developer Insider. All rights reserved. -// - -#import - -@interface LogViewController : NSViewController{ - IBOutlet NSTextView *textView; -} - -@end diff --git a/AppBox/ViewController/LogViewController/LogViewController.m b/AppBox/ViewController/LogViewController/LogViewController.m deleted file mode 100644 index bcf7accd..00000000 --- a/AppBox/ViewController/LogViewController/LogViewController.m +++ /dev/null @@ -1,69 +0,0 @@ -// -// LogViewController.m -// AppBox -// -// Created by Vineet Choudhary on 05/12/16. -// Copyright © 2016 Developer Insider. All rights reserved. -// - -#import "LogViewController.h" - -@interface LogViewController () - -@end - -@implementation LogViewController{ - BOOL isAutoScrollEnabled; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - //log view - [EventTracker logScreen:@"AppBox Log"]; - - //enable auto scroll - isAutoScrollEnabled = YES; - - //refresh log - [self refreshLog]; - - //add observer for log and scroll - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshLog) name:abSessionLogUpdated object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleScroll:) name:NSScrollViewDidLiveScrollNotification object:nil]; -} - --(void)refreshLog{ - //if auto scroll enabled replace content and scroll to bottom - if (isAutoScrollEnabled){ - textView.string = [[AppDelegate appDelegate] sessionLog]; - weakify(self); - dispatch_async(dispatch_get_main_queue(), ^{ - strongify(self); - [self->textView scrollToEndOfDocument:self]; - }); - } -} - --(void)handleScroll:(NSNotification *)notification{ - if ([notification.object isKindOfClass:[NSScrollView class]] && ([notification.object isEqualTo:textView.enclosingScrollView])){ - //get visiable and bound rect - NSRect boundsRect = [textView bounds]; - NSRect visRect = [textView visibleRect]; - - //Disable auto scroll - isAutoScrollEnabled = NO; - - //enable auto scroll if user scrolled to bottom - if (NSMaxY(visRect) - NSMaxY(boundsRect) == 0.0){ - isAutoScrollEnabled = YES; - weakify(self); - dispatch_async(dispatch_get_main_queue(), ^{ - strongify(self); - [self refreshLog]; - }); - } - } -} - - -@end diff --git a/AppBox/ViewController/MenuHandler/NSApplication+MenuHandler.m b/AppBox/ViewController/MenuHandler/NSApplication+MenuHandler.m index 9af11a59..0978fdf6 100644 --- a/AppBox/ViewController/MenuHandler/NSApplication+MenuHandler.m +++ b/AppBox/ViewController/MenuHandler/NSApplication+MenuHandler.m @@ -22,12 +22,16 @@ - (IBAction)checkForUpdateTapped:(NSMenuItem *)sender { }]; } +//MARK: - File +- (IBAction)viewLogFileTapped:(NSMenuItem *)sender { + [[AppDelegate appDelegate] openLatestLogFile]; +} - (IBAction)preferencesTapped:(NSMenuItem *)sender { [PreferencesTabViewController presentPreferences]; } -//MARK: - File +//MARK: - Accounts - (void)updateAccountsMenu{ [self updateDropboxButton]; @@ -58,8 +62,8 @@ - (void)updateAccountsMenu{ [self updateDropboxButton]; //log space usage - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"DropBox Used Space : %@MB", usage]]; - [[AppDelegate appDelegate] addSessionLog:[NSString stringWithFormat:@"DropBox Available Space : %@MB", allocated]]; + DDLogInfo(@"DropBox Used Space : %@MB", usage); + DDLogInfo(@"DropBox Available Space : %@MB", allocated); //check if dopbox running out of space if ((allocated.integerValue - usage.integerValue) < abDropboxOutOfSpaceWarningSize){ @@ -97,7 +101,6 @@ - (void)updateDropboxButton{ [dropboxSpaceButton setTitle:dropboxSpaceButtonTitle]; } -//MARK: - Accounts - (IBAction)logoutDropBoxTapped:(NSMenuItem *)sender { NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText: @"Are you sure?"]; @@ -110,6 +113,7 @@ - (IBAction)logoutDropBoxTapped:(NSMenuItem *)sender { [sender setEnabled:NO]; } } + - (IBAction)dropboxSpaceTapped:(NSMenuItem *)sender { [self updateAccountsMenu]; } diff --git a/AppBox/ViewController/PreferencesViewController/GeneralPreferencesViewController/PreferencesViewController.xib b/AppBox/ViewController/PreferencesViewController/GeneralPreferencesViewController/PreferencesViewController.xib index 410e28d5..6779322b 100644 --- a/AppBox/ViewController/PreferencesViewController/GeneralPreferencesViewController/PreferencesViewController.xib +++ b/AppBox/ViewController/PreferencesViewController/GeneralPreferencesViewController/PreferencesViewController.xib @@ -1,8 +1,8 @@ - + - + @@ -229,7 +229,7 @@