Skip to content

Commit

Permalink
Pepper log statements for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Dec 20, 2020
1 parent 0cfff79 commit 3ed8ddf
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ObjCCLIInfra
12 changes: 11 additions & 1 deletion applesimutils/applesimutils.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
395046D51EA725FF00557294 /* SetLocationPermission.m in Sources */ = {isa = PBXBuildFile; fileRef = 395046D41EA725FF00557294 /* SetLocationPermission.m */; };
395046D81EA72F1000557294 /* SimUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 395046D71EA72F1000557294 /* SimUtils.m */; };
39676AD61F94BE4100018548 /* ClearKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 39676AD51F94BE4100018548 /* ClearKeychain.m */; };
39A57000258F3FF90067D86B /* DTXLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = 39A56FFF258F3FF90067D86B /* DTXLogging.m */; };
39EAF80624E2F008003F86C3 /* NSTask+InputOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 39EAF80524E2F008003F86C3 /* NSTask+InputOutput.m */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -131,6 +132,9 @@
395046D71EA72F1000557294 /* SimUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimUtils.m; sourceTree = "<group>"; };
39676AD41F94BE4100018548 /* ClearKeychain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClearKeychain.h; sourceTree = "<group>"; };
39676AD51F94BE4100018548 /* ClearKeychain.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ClearKeychain.m; sourceTree = "<group>"; };
39A56FF8258F3FF90067D86B /* DTXLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DTXLogging.h; path = ../../ObjCCLIInfra/DTXLoggingInfra/DTXLogging.h; sourceTree = "<group>"; };
39A56FFF258F3FF90067D86B /* DTXLogging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DTXLogging.m; path = ../../ObjCCLIInfra/DTXLoggingInfra/DTXLogging.m; sourceTree = "<group>"; };
39A57002258F416F0067D86B /* DTXLoggingSubsystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DTXLoggingSubsystem.h; sourceTree = "<group>"; };
39EAF80424E2F008003F86C3 /* NSTask+InputOutput.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSTask+InputOutput.h"; sourceTree = "<group>"; };
39EAF80524E2F008003F86C3 /* NSTask+InputOutput.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSTask+InputOutput.m"; sourceTree = "<group>"; };
39FE99C31F8A6B17006DF8EF /* version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -172,6 +176,9 @@
39470A5322BA878000BDFA5C /* fmdb */,
391596FF1E8CDD0500FDD6F5 /* Handlers */,
3935103B1FCB9A0D001FB466 /* GBCli */,
39A56FF8258F3FF90067D86B /* DTXLogging.h */,
39A56FFF258F3FF90067D86B /* DTXLogging.m */,
39A57002258F416F0067D86B /* DTXLoggingSubsystem.h */,
393510371FCB9972001FB466 /* LNLog.h */,
393510381FCB9972001FB466 /* LNLog.m */,
393510351FCB9972001FB466 /* LNOptionsParser.h */,
Expand Down Expand Up @@ -280,7 +287,7 @@
391596D41E8CBAA900FDD6F5 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1150;
LastUpgradeCheck = 1230;
ORGANIZATIONNAME = Wix;
TargetAttributes = {
391596DB1E8CBAA900FDD6F5 = {
Expand Down Expand Up @@ -384,6 +391,7 @@
391596E01E8CBAA900FDD6F5 /* main.m in Sources */,
395046D81EA72F1000557294 /* SimUtils.m in Sources */,
391597021E8CDD1D00FDD6F5 /* SetNotificationsPermission.m in Sources */,
39A57000258F3FF90067D86B /* DTXLogging.m in Sources */,
393510391FCB9972001FB466 /* LNOptionsParser.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -425,6 +433,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down Expand Up @@ -484,6 +493,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1150"
LastUpgradeVersion = "1230"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -53,7 +53,7 @@
<CommandLineArguments>
<CommandLineArgument
argument = "--booted"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--byId &quot;67CE96F9-6FF2-468D-9C38-96EEBDC7139E&quot;"
Expand Down
11 changes: 11 additions & 0 deletions applesimutils/applesimutils/DTXLoggingSubsystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// DTXLoggingSubsystem.h
// applesimutils
//
// Created by Leo Natan (Wix) on 12/10/17.
// Copyright © 2017 Wix. All rights reserved.
//

#ifndef DTX_LOG_SUBSYSTEM
#define DTX_LOG_SUBSYSTEM "com.wix.applesimutils"
#endif /* DTX_LOG_SUBSYSTEM */
2 changes: 1 addition & 1 deletion applesimutils/applesimutils/NSTask+InputOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface NSTask (InputOutput)

- (int)launchAndWaitUntilExitReturningStandardOutputData:(out NSData* __autoreleasing __nullable * __nullable)stdOutData standardRrrorData:(out NSData *__autoreleasing _Nullable * __nullable)stdErrData;
- (int)launchAndWaitUntilExitReturningStandardOutputData:(out NSData* __autoreleasing __nullable * __nullable)stdOutData standardErrorData:(out NSData *__autoreleasing _Nullable * __nullable)stdErrData;
- (int)launchAndWaitUntilExitReturningStandardOutput:(out NSString* __autoreleasing __nullable * __nullable)stdOut standardRrror:(out NSString *__autoreleasing _Nullable * __nullable)stdErr;

@end
Expand Down
8 changes: 5 additions & 3 deletions applesimutils/applesimutils/NSTask+InputOutput.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@implementation NSTask (InputOutput)

- (int)launchAndWaitUntilExitReturningStandardOutputData:(out NSData* __autoreleasing __nullable * __nullable)stdOutData standardRrrorData:(out NSData *__autoreleasing _Nullable * __nullable)stdErrData
- (int)launchAndWaitUntilExitReturningStandardOutputData:(out NSData* __autoreleasing __nullable * __nullable)stdOutData standardErrorData:(out NSData *__autoreleasing _Nullable * __nullable)stdErrData
{
NSPipe* outPipe = [NSPipe pipe];
NSMutableData* outData = [NSMutableData new];
Expand All @@ -34,7 +34,9 @@ - (int)launchAndWaitUntilExitReturningStandardOutputData:(out NSData* __autorele

dispatch_semaphore_signal(waitForTermination);
};


LNLog(LNLogLevelDebug, @"Running “%@%@", self.launchPath, self.arguments.count > 0 ? [NSString stringWithFormat:@" with argument%@: “%@", self.arguments.count > 1 ? @"s" : @"", [self.arguments componentsJoinedByString:@" "]] : @"");

[self launch];

dispatch_semaphore_wait(waitForTermination, DISPATCH_TIME_FOREVER);
Expand All @@ -57,7 +59,7 @@ - (int)launchAndWaitUntilExitReturningStandardOutput:(out NSString* __autoreleas
NSData* stdOutData;
NSData* stdErrData;

int rv = [self launchAndWaitUntilExitReturningStandardOutputData:&stdOutData standardRrrorData:&stdErrData];
int rv = [self launchAndWaitUntilExitReturningStandardOutputData:&stdOutData standardErrorData:&stdErrData];

if(stdOut != NULL)
{
Expand Down
2 changes: 2 additions & 0 deletions applesimutils/applesimutils/SetHealthKitPermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ + (NSURL*)healthdbURLForSimulatorId:(NSString*)simulatorId osVersion:(NSOperatin

+ (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleIdentifier:(NSString*)bundleIdentifier simulatorIdentifier:(NSString*)simulatorId osVersion:(NSOperatingSystemVersion)osVersion needsSBRestart:(BOOL*)needsSBRestart error:(NSError**)error
{
LNLog(LNLogLevelDebug, @"Setting HealthKit permission");

if(osVersion.majorVersion < 12)
{
*error = [NSError errorWithDomain:@"SetHealthKitPermissionError" code:0 userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Setting health permission is supported for iOS 12 simulators and above (got %@.%@)", @(osVersion.majorVersion), @(osVersion.minorVersion)]}];
Expand Down
2 changes: 2 additions & 0 deletions applesimutils/applesimutils/SetLocationPermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ + (NSURL*)locationdURL

+ (BOOL)setLocationPermission:(NSString*)permission forBundleIdentifier:(NSString*)bundleIdentifier simulatorIdentifier:(NSString*)simulatorId error:(NSError**)error
{
LNLog(LNLogLevelDebug, @"Setting location permission");

NSURL* plistURL = [[SimUtils libraryURLForSimulatorId:simulatorId] URLByAppendingPathComponent:@"Caches/locationd/clients.plist"];

NSData* plistData = [NSData dataWithContentsOfURL:plistURL];
Expand Down
2 changes: 2 additions & 0 deletions applesimutils/applesimutils/SetNotificationsPermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ @implementation SetNotificationsPermission

+ (BOOL)setNotificationsStatus:(NSString*)status forBundleIdentifier:(NSString*)bundleIdentifier displayName:(NSString*)displayName simulatorIdentifier:(NSString*)simulatorId error:(NSError**)error
{
LNLog(LNLogLevelDebug, @"Setting notification permission");

if([status isEqualToString:@"unset"])
{
return [self _setSectionInfoData:nil forBundleIdentifier:bundleIdentifier displayName:displayName simulatorIdentifier:simulatorId error:error];
Expand Down
2 changes: 2 additions & 0 deletions applesimutils/applesimutils/SetServicePermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ + (BOOL)_changeAccessToService:(NSString*)service

+ (BOOL)setPermisionStatus:(NSString*)status forService:(NSString*)service bundleIdentifier:(NSString*)bundleIdentifier simulatorIdentifier:(NSString*)simulatorId operatingSystemVersion:(NSOperatingSystemVersion)operatingSystemVersion error:(NSError**)error;
{
LNLog(LNLogLevelDebug, @"Setting service “%@” permission", service);

return [self _changeAccessToService:service simulatorId:simulatorId operatingSystemVersion:operatingSystemVersion bundleIdentifier:bundleIdentifier status:status error:error];
}

Expand Down
10 changes: 9 additions & 1 deletion applesimutils/applesimutils/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

static void bootSimulator(NSString* simulatorId)
{
LNLog(LNLogLevelDebug, @"Booting simulator “%@", simulatorId);

NSTask* bootTask = [NSTask new];
bootTask.launchPath = [SimUtils xcrunURL].path;
bootTask.arguments = @[@"simctl", @"boot", simulatorId];
Expand All @@ -44,6 +46,8 @@ static void bootSimulator(NSString* simulatorId)

static void shutdownSimulator(NSString* simulatorId)
{
LNLog(LNLogLevelDebug, @"Shutting down simulator “%@", simulatorId);

NSTask* shutdownTask = [NSTask new];
shutdownTask.launchPath = [SimUtils xcrunURL].path;
shutdownTask.arguments = @[@"simctl", @"shutdown", simulatorId];
Expand All @@ -53,12 +57,14 @@ static void shutdownSimulator(NSString* simulatorId)

static NSArray* simulatorDevicesList()
{
LNLog(LNLogLevelDebug, @"Obtaining simulator device list");

NSTask* listTask = [NSTask new];
listTask.launchPath = [SimUtils xcrunURL].path;
listTask.arguments = @[@"simctl", @"list", @"--json"];

NSData* jsonData;
[listTask launchAndWaitUntilExitReturningStandardOutputData:&jsonData standardRrrorData:NULL];
[listTask launchAndWaitUntilExitReturningStandardOutputData:&jsonData standardErrorData:NULL];

NSError* error;
NSDictionary* list = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
Expand Down Expand Up @@ -250,6 +256,8 @@ static NSOperatingSystemVersion operatingSystemFromSimulator(NSDictionary* simul

static BOOL performPermissionsPass(NSString* permissionsArgument, NSString* simulatorIdentifier, NSString* bundleIdentifier, NSDictionary* simulator)
{
LNLog(LNLogLevelDebug, @"Performing permission pass");

NSDictionary<NSString*, NSString*>* argumentToAppleService = @{
@"calendar": @"kTCCServiceCalendar",
@"camera": @"kTCCServiceCamera",
Expand Down
2 changes: 1 addition & 1 deletion fmdb
Submodule fmdb updated 3 files
+1 −0 FMDB.podspec
+1 −0 README.markdown
+425 −0 privacy/README.md

0 comments on commit 3ed8ddf

Please sign in to comment.