Skip to content

Commit 5de4ca8

Browse files
committed
Add logging for issue #55
1 parent cbf994b commit 5de4ca8

File tree

6 files changed

+34
-14
lines changed

6 files changed

+34
-14
lines changed

ObjCCLIInfra

applesimutils/applesimutils.xcodeproj/xcshareddata/xcschemes/applesimutils.xcscheme

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
argument = "--byType "iPhone Xs Max""
6969
isEnabled = "NO">
7070
</CommandLineArgument>
71+
<CommandLineArgument
72+
argument = "--byUDID &quot;D1645AED-E710-4C54-A292-E52648063807&quot;"
73+
isEnabled = "YES">
74+
</CommandLineArgument>
7175
<CommandLineArgument
7276
argument = "--byOS &quot;12.2&quot;"
7377
isEnabled = "NO">
@@ -77,8 +81,8 @@
7781
isEnabled = "NO">
7882
</CommandLineArgument>
7983
<CommandLineArgument
80-
argument = "--bundle &quot;com.wix.PermissionsTest&quot;"
81-
isEnabled = "NO">
84+
argument = "--bundle &quot;com.wix.PermissionsTestT1&quot;"
85+
isEnabled = "YES">
8286
</CommandLineArgument>
8387
<CommandLineArgument
8488
argument = "--clearKeychain"
@@ -89,16 +93,20 @@
8993
isEnabled = "NO">
9094
</CommandLineArgument>
9195
<CommandLineArgument
92-
argument = "--setPermissions &quot;location=never, notifications=YES&quot;"
96+
argument = "--setPermissions &quot;notifications=YES&quot;"
9397
isEnabled = "NO">
9498
</CommandLineArgument>
99+
<CommandLineArgument
100+
argument = "--setPermissions &quot;health=YES&quot;"
101+
isEnabled = "YES">
102+
</CommandLineArgument>
95103
<CommandLineArgument
96104
argument = "--list &quot;iPhone 8 Plus, OS=iOS 11.0&quot;"
97105
isEnabled = "NO">
98106
</CommandLineArgument>
99107
<CommandLineArgument
100108
argument = "--list"
101-
isEnabled = "YES">
109+
isEnabled = "NO">
102110
</CommandLineArgument>
103111
<CommandLineArgument
104112
argument = "--restartSB"

applesimutils/applesimutils/PrefixHeader.pch

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
#ifndef PrefixHeader_pch
1010
#define PrefixHeader_pch
1111

12+
#import "LNLog.h"
13+
14+
#define debug_log(message) LNLog(LNLogLevelDebug, @"%@ (%s at line %d)", message, __FUNCTION__, __LINE__)
15+
#define logcontinue(message) debug_log(message); continue
16+
#define logreturn(message) debug_log(message); return
17+
1218
#import "Swiftier.h"
1319

1420
#endif /* PrefixHeader_pch */

applesimutils/applesimutils/SetHealthKitPermission.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
3636
dtx_defer {
3737
if(success == NO)
3838
{
39+
debug_log(@"Retrying in one second");
3940
[NSThread sleepForTimeInterval:1];
4041
}
4142
};
@@ -46,7 +47,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
4647
NSURL* healthURL = [self _healthdbURLForSimulatorId:simulatorId osVersion:osVersion];
4748
if ([healthURL checkResourceIsReachableAndReturnError:error] == NO)
4849
{
49-
continue;
50+
logcontinue(@"Health database not found");
5051
}
5152

5253
FMDatabase* db = [[FMDatabase alloc] initWithURL:healthURL];
@@ -59,7 +60,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
5960

6061
if([db open] == NO)
6162
{
62-
continue;
63+
logcontinue(@"Health database failed to open");
6364
}
6465

6566
FMResultSet* resultSet;
@@ -73,7 +74,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
7374

7475
if((resultSet = [db executeQuery:@"select ROWID from sources where bundle_id == :bundle_id" withParameterDictionary:@{@"bundle_id": bundleIdentifier}]) == nil)
7576
{
76-
continue;
77+
logcontinue(@"Unable to execute query");
7778
}
7879

7980
BOOL didHaveRow = [resultSet nextWithError:error];
@@ -100,7 +101,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
100101
NSNumber* syncAnchor = @1;
101102
if((syncAnchorResultSet = [db executeQuery:@"select MAX(sync_anchor) from sources"]) == nil)
102103
{
103-
continue;
104+
logcontinue(@"Unable to execute query");;
104105
}
105106

106107
if([syncAnchorResultSet next] != NO)
@@ -121,13 +122,13 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
121122

122123
if([db executeUpdate:[NSString stringWithFormat:@"insert into sources (%@) VALUES (%@)", query, values] withParameterDictionary:params] == NO)
123124
{
124-
continue;
125+
logcontinue(@"Unable to execute update");;
125126
}
126127

127128
[resultSet close];
128129
if((resultSet = [db executeQuery:@"select ROWID from sources where bundle_id == :bundle_id" withParameterDictionary:@{@"bundle_id": bundleIdentifier}]) == nil)
129130
{
130-
continue;
131+
logcontinue(@"Unable to execute query");
131132
}
132133
[resultSet nextWithError:error];
133134
}
@@ -136,7 +137,7 @@ + (BOOL)setHealthKitPermission:(HealthKitPermissionStatus)permission forBundleId
136137

137138
if(rowID == nil)
138139
{
139-
continue;
140+
logcontinue(@"No row ID found");;
140141
}
141142

142143
__unused BOOL b = [db executeUpdate:@"delete from authorization where source_id == :source_id" withParameterDictionary:@{@"source_id": rowID}];

applesimutils/applesimutils/SetNotificationsPermission.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ + (BOOL)_setSectionInfoData:(id)sectionInfoData forBundleIdentifier:(NSString*)b
8585
}
8686

8787
//Add a retry mechanism to be able to cope with a device which is in the process of booting while this runs.
88+
debug_log(@"Retrying in one second");
8889
[NSThread sleepForTimeInterval:1];
8990
}
9091

applesimutils/applesimutils/SetServicePermission.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ + (BOOL)_changeAccessToService:(NSString*)service
3333
dtx_defer {
3434
if(success == NO)
3535
{
36+
debug_log(@"Retrying in one second");
3637
[NSThread sleepForTimeInterval:1];
3738
}
3839
};
@@ -44,7 +45,7 @@ + (BOOL)_changeAccessToService:(NSString*)service
4445

4546
if ([tccURL checkResourceIsReachableAndReturnError:error] == NO)
4647
{
47-
continue;
48+
logcontinue(@"TCC database is not found");
4849
}
4950

5051
FMDatabase* db = [[FMDatabase alloc] initWithURL:tccURL];
@@ -55,7 +56,10 @@ + (BOOL)_changeAccessToService:(NSString*)service
5556
}
5657
};
5758

58-
if (![db open]) continue;
59+
if (![db open])
60+
{
61+
logcontinue(@"TCC database failed to open");
62+
}
5963

6064
NSString *query;
6165
NSDictionary *parameters;

0 commit comments

Comments
 (0)