Skip to content

Commit

Permalink
CBL-5383 : Add Privacy Manifest File (#3225) (#3228)
Browse files Browse the repository at this point in the history
* Added Privacy Manifest File and bundled it into the framework.

* Made the code that configuring console logging from UserDefaults available only in the Debug build. This means that we don’t need to put the NSUserDefault API usage in the Privacy Manifest file.
  • Loading branch information
pasin authored Feb 14, 2024
1 parent 3c30fa8 commit 8deb3a1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 7 deletions.
50 changes: 50 additions & 0 deletions CouchbaseLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@
40BC51F92AFC40F40090EDD5 /* CBLBlockConflictResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 40BC51F52AFC40930090EDD5 /* CBLBlockConflictResolver.m */; };
40BC51FA2AFC56BB0090EDD5 /* CBLBlockConflictResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 40BC51F52AFC40930090EDD5 /* CBLBlockConflictResolver.m */; };
40BC51FB2AFC56BC0090EDD5 /* CBLBlockConflictResolver.m in Sources */ = {isa = PBXBuildFile; fileRef = 40BC51F52AFC40930090EDD5 /* CBLBlockConflictResolver.m */; };
40EF69622B7C03D300F0CB50 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */; };
40EF69642B7C03EC00F0CB50 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */; };
40EF69662B7C03FE00F0CB50 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */; };
40EF696A2B7C041D00F0CB50 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */; };
69002EB9234E693F00776107 /* CBLErrorMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 69002EA9234E693F00776107 /* CBLErrorMessage.h */; };
69002EBA234E693F00776107 /* CBLErrorMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = 69002EB8234E693F00776107 /* CBLErrorMessage.m */; };
69002EBB234E695400776107 /* CBLErrorMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = 69002EA9234E693F00776107 /* CBLErrorMessage.h */; };
Expand Down Expand Up @@ -2182,6 +2186,7 @@
27F961981ED8D9440060F804 /* CBLReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CBLReachability.m; sourceTree = "<group>"; };
40BC51F42AFC40930090EDD5 /* CBLBlockConflictResolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CBLBlockConflictResolver.h; sourceTree = "<group>"; };
40BC51F52AFC40930090EDD5 /* CBLBlockConflictResolver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CBLBlockConflictResolver.m; sourceTree = "<group>"; };
40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
69002EA9234E693F00776107 /* CBLErrorMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CBLErrorMessage.h; sourceTree = "<group>"; };
69002EB8234E693F00776107 /* CBLErrorMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CBLErrorMessage.m; sourceTree = "<group>"; };
6932D48B2954640000D28C18 /* CBLQueryFullTextIndexExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CBLQueryFullTextIndexExpression.h; path = ../CBLQueryFullTextIndexExpression.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2967,6 +2972,14 @@
name = Frameworks;
sourceTree = "<group>";
};
40EF695E2B7C038000F0CB50 /* Resources */ = {
isa = PBXGroup;
children = (
40EF695F2B7C038000F0CB50 /* PrivacyInfo.xcprivacy */,
);
path = Resources;
sourceTree = "<group>";
};
930C7F7C20FE4F7400C74A12 /* Util */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3695,6 +3708,7 @@
9382354F207D9EA30022328B /* EE */,
9378C5D11E26CC46001BB196 /* xcconfigs */,
9398D92D1E03467C00464432 /* vendor */,
40EF695E2B7C038000F0CB50 /* Resources */,
9388CB7421BCDF8B005CA66D /* Scripts */,
27EF6AF01E32D12C004748DF /* Frameworks */,
9398D9131E03434200464432 /* Products */,
Expand Down Expand Up @@ -4818,6 +4832,7 @@
275F926F1E4D30A4007FD5A2 /* Sources */,
275F92701E4D30A4007FD5A2 /* Frameworks */,
275F92711E4D30A4007FD5A2 /* Headers */,
40EF69632B7C03E300F0CB50 /* Resources */,
93CED8D52048B3D600E6F0A4 /* Remove private headers */,
);
buildRules = (
Expand Down Expand Up @@ -4911,6 +4926,7 @@
9343EF2E207D611600F19A89 /* Sources */,
9343EF8D207D611600F19A89 /* Frameworks */,
9343EF90207D611600F19A89 /* Headers */,
40EF69652B7C03F600F0CB50 /* Resources */,
);
buildRules = (
);
Expand All @@ -4932,6 +4948,7 @@
9343F015207D61AB00F19A89 /* Sources */,
9343F0B1207D61AB00F19A89 /* Frameworks */,
9343F0B4207D61AB00F19A89 /* Headers */,
40EF69692B7C041400F0CB50 /* Resources */,
9343F12D207D61AB00F19A89 /* Remove private headers */,
);
buildRules = (
Expand Down Expand Up @@ -5084,6 +5101,7 @@
9398D90D1E03434200464432 /* Sources */,
9398D90E1E03434200464432 /* Frameworks */,
9398D90F1E03434200464432 /* Headers */,
40EF69612B7C03C600F0CB50 /* Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -5391,6 +5409,38 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
40EF69612B7C03C600F0CB50 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
40EF69622B7C03D300F0CB50 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
40EF69632B7C03E300F0CB50 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
40EF69642B7C03EC00F0CB50 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
40EF69652B7C03F600F0CB50 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
40EF69662B7C03FE00F0CB50 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
40EF69692B7C041400F0CB50 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
40EF696A2B7C041D00F0CB50 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
930B63CE246B9CD1006D94FF /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down
20 changes: 13 additions & 7 deletions Objective-C/CBLLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ @implementation CBLLog {

@synthesize console=_console, file=_file, custom=_custom;

#ifdef DEBUG
static C4LogLevel string2level(NSString* value) {
if (value == nil) {
#ifdef DEBUG
return kC4LogDebug;
#else
return kC4LogVerbose;
#endif
}

switch (value.length > 0 ? toupper([value characterAtIndex: 0]) : 'Y') {
Expand All @@ -68,6 +65,7 @@ static C4LogLevel string2level(NSString* value) {
return kC4LogInfo;
}
}
#endif

static C4LogDomain setNamedLogDomainLevel(const char *domainName, C4LogLevel level) {
C4LogDomain domain = c4log_getDomain(domainName, true);
Expand Down Expand Up @@ -132,9 +130,11 @@ static void sendToCallbackLogger(C4LogDomain d, C4LogLevel l, NSString* message)
if (shouldLogToCustom)
[log.custom logWithLevel: level domain: domain message: message];

#ifdef DEBUG
// Breakpoint if enabled:
if (level >= kCBLLogLevelWarning && [NSUserDefaults.standardUserDefaults boolForKey: @"CBLBreakOnWarning"])
MYBreakpoint(); // stops debugger at breakpoint. You can resume normally.
#endif
}

// Initialize the CBLLog object and register the logging callback.
Expand All @@ -152,15 +152,19 @@ - (instancetype) initWithDefault {
// The most default callback log level:
C4LogLevel callbackLogLevel = kC4LogWarning;

#ifdef DEBUG
// Check if user overrides the default callback log level:
NSString* userLogLevel = [NSUserDefaults.standardUserDefaults objectForKey: @"CBLLogLevel"];
if (userLogLevel)
if (userLogLevel) {
callbackLogLevel = string2level(userLogLevel);
}
if (callbackLogLevel != kC4LogWarning) {
NSLog(@"CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]);
}
#endif

// Enable callback logging:
c4log_writeToCallback(callbackLogLevel, &logCallback, true);
if (callbackLogLevel != kC4LogWarning)
NSLog(@"CouchbaseLite minimum log level is %s", kLevelNames[callbackLogLevel]);

// Set log level for each domains to the lowest:
kCBL_LogDomainDatabase = setNamedLogDomainLevel("DB", kC4LogDebug);
Expand All @@ -175,6 +179,7 @@ - (instancetype) initWithDefault {
setNamedLogDomainLevel("Zip", kC4LogDebug);
setNamedLogDomainLevel("BLIPMessages", kC4LogDebug);

#ifdef DEBUG
// Now map user defaults starting with CBLLog... to log levels:
NSDictionary* defaults = [NSUserDefaults.standardUserDefaults dictionaryRepresentation];
for (NSString* key in defaults) {
Expand All @@ -188,6 +193,7 @@ - (instancetype) initWithDefault {
NSLog(@"CouchbaseLite logging to %s domain at level %s", domainName, kLevelNames[level]);
}
}
#endif

// Keep the current callback log level:
_callbackLogLevel = (CBLLogLevel)callbackLogLevel;
Expand Down
17 changes: 17 additions & 0 deletions Resources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
</array>
</dict>
</plist>

0 comments on commit 8deb3a1

Please sign in to comment.