Browse Source

IOSAD-186 conditional code for macOS and iOS (tmp for testing linking all targets)

IOS-217_IOS-2295
buff 2 years ago
committed by Andreas Buff
parent
commit
5cad9d7352
4 changed files with 174 additions and 55 deletions
  1. +16
    -0
      pEpObjCAdapter.xcodeproj/project.pbxproj
  2. +70
    -0
      pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapter_iOS.xcscheme
  3. +28
    -2
      pEpObjCAdapter/Logger.h
  4. +60
    -53
      pEpObjCAdapter/PEPObjCAdapter.m

+ 16
- 0
pEpObjCAdapter.xcodeproj/project.pbxproj View File

@ -36,6 +36,8 @@
1516087B257A4F0A00DD42E0 /* libPEPObjCAdapterTypes_iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 151606FD257A401000DD42E0 /* libPEPObjCAdapterTypes_iOS.a */; platformFilter = ios; };
15160AF1257A58A000DD42E0 /* libpEpEngine.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64289E561B8B70E800FC617B /* libpEpEngine.a */; platformFilter = ios; };
15160D2D257A920F00DD42E0 /* libPEPObjCAdapter_iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1543DC66257943CE0041EFB5 /* libPEPObjCAdapter_iOS.a */; platformFilter = ios; };
15160D93257A99D900DD42E0 /* pEpIOSToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15160D92257A99D900DD42E0 /* pEpIOSToolbox.framework */; platformFilter = ios; };
15160E80257AA06500DD42E0 /* pEp4iosIntern.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15160E7F257AA06500DD42E0 /* pEp4iosIntern.framework */; platformFilter = ios; };
152A9C472010F50400F962ED /* PEPInternalSessionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 152A9C462010F50400F962ED /* PEPInternalSessionTest.m */; };
1543D9E02577EF260041EFB5 /* libpEpEngine_macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1552DCBD2577E0B600A92F71 /* libpEpEngine_macOS.a */; };
1543DA892577FE230041EFB5 /* libPEPObjCAdapterTypes_macOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 150E8FB225755B6900AE2198 /* libPEPObjCAdapterTypes_macOS.a */; };
@ -246,6 +248,10 @@
15160756257A40C300DD42E0 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
15160B29257A594F00DD42E0 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
15160B30257A595800DD42E0 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk/usr/lib/libiconv.tbd; sourceTree = DEVELOPER_DIR; };
15160D7F257A99BF00DD42E0 /* pEpIOSToolbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = pEpIOSToolbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15160D8B257A99CC00DD42E0 /* pEpIOSToolbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = pEpIOSToolbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15160D92257A99D900DD42E0 /* pEpIOSToolbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = pEpIOSToolbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15160E7F257AA06500DD42E0 /* pEp4iosIntern.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = pEp4iosIntern.framework; sourceTree = BUILT_PRODUCTS_DIR; };
15206CA81F8BA183003FF880 /* PEPSessionProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSessionProvider.h; sourceTree = "<group>"; };
15206CA91F8BA183003FF880 /* PEPSessionProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSessionProvider.m; sourceTree = "<group>"; };
152A9C462010F50400F962ED /* PEPInternalSessionTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPInternalSessionTest.m; sourceTree = "<group>"; };
@ -392,7 +398,9 @@
buildActionMask = 2147483647;
files = (
15160AF1257A58A000DD42E0 /* libpEpEngine.a in Frameworks */,
15160D93257A99D900DD42E0 /* pEpIOSToolbox.framework in Frameworks */,
1516087B257A4F0A00DD42E0 /* libPEPObjCAdapterTypes_iOS.a in Frameworks */,
15160E80257AA06500DD42E0 /* pEp4iosIntern.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -625,8 +633,12 @@
43447C51221D448500B6323E /* Frameworks */ = {
isa = PBXGroup;
children = (
15160E7F257AA06500DD42E0 /* pEp4iosIntern.framework */,
15160B30257A595800DD42E0 /* libiconv.tbd */,
15160B29257A594F00DD42E0 /* libz.tbd */,
15160D92257A99D900DD42E0 /* pEpIOSToolbox.framework */,
15160D8B257A99CC00DD42E0 /* pEpIOSToolbox.framework */,
15160D7F257A99BF00DD42E0 /* pEpIOSToolbox.framework */,
1552DA2125766AC700A92F71 /* libpEpEngine.a */,
3A68CB27252E244900F1B71C /* pEp4iosIntern.framework */,
43E1A7A6252B41B300307A7D /* pEpIOSToolbox.framework */,
@ -1256,6 +1268,10 @@
DEVELOPMENT_TEAM = NQLYU6MGPN;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
"IS_IOS_BUILD=1",
"$(inherited)",
);
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;


+ 70
- 0
pEpObjCAdapter.xcodeproj/xcshareddata/xcschemes/PEPObjCAdapter_iOS.xcscheme View File

@ -6,6 +6,76 @@
parallelizeBuildables = "NO"
buildImplicitDependencies = "NO">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "19FF460E1B8B4D1400B43179"
BuildableName = "CocoaLumberjackSwift.framework"
BlueprintName = "CocoaLumberjackSwift"
ReferencedContainer = "container:../CocoaLumberjack/Lumberjack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "19FF46011B8B4CF400B43179"
BuildableName = "CocoaLumberjack.framework"
BlueprintName = "CocoaLumberjack"
ReferencedContainer = "container:../CocoaLumberjack/Lumberjack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3AE6870024FFA5ED00B416ED"
BuildableName = "pEp4iosIntern.framework"
BlueprintName = "pEp4iosIntern"
ReferencedContainer = "container:../pEp_for_iOS_intern/pEp4iosIntern/pEp4iosIntern.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B7911EB321F7358500D7F66F"
BuildableName = "pEpIOSToolbox.framework"
BlueprintName = "pEpIOSToolbox"
ReferencedContainer = "container:../pEp_for_iOS/subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "64796A3E1B455AA5004B1C24"
BuildableName = "libpEpEngine.a"
BlueprintName = "pEpEngine"
ReferencedContainer = "container:../pEpEngine/build-mac/pEpEngine.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"


+ 28
- 2
pEpObjCAdapter/Logger.h View File

@ -9,14 +9,40 @@
#ifndef Logger_h
#define Logger_h
//BUFF: !!! //!!!:
#ifdef IS_IOS_BUILD
//#import <pEpIOSToolbox/pEpIOSToolbox-Swift.h>
#import <pEpIOSToolbox/pEpIOSToolbox-Swift.h>
#define LogInfo(...) [[Log shared] \
logInfoWithMessage:[NSString stringWithFormat:__VA_ARGS__] \
function:[NSString stringWithUTF8String:__FUNCTION__] \
filePath:[NSString stringWithUTF8String:__FILE__] \
fileLine:__LINE__];
#define LogWarn(...) [[Log shared] \
logWarnWithMessage:[NSString stringWithFormat:__VA_ARGS__] \
function:[NSString stringWithUTF8String:__FUNCTION__] \
filePath:[NSString stringWithUTF8String:__FILE__] \
fileLine:__LINE__];
#define LogError(...) [[Log shared] \
logErrorWithMessage:[NSString stringWithFormat:__VA_ARGS__] \
function:[NSString stringWithUTF8String:__FUNCTION__] \
filePath:[NSString stringWithUTF8String:__FILE__] \
fileLine:__LINE__];
#else
//BUFF: //DIRK: //!!!: Mac version loggingneeds to be defined and implemented. Remeber to only use static libs. Ideally we find a nice way without #ifdef IS_IOS_BUILD.
#define LogInfo(...) NSLog(__VA_ARGS__);
#define LogWarn(...) NSLog(__VA_ARGS__);
#define LogError(...) NSLog(__VA_ARGS__);
#endif
//#import <pEpIOSToolbox/pEpIOSToolbox-Swift.h>
//#import <pEpIOSToolbox/pEpIOSToolbox-Swift.h>
//
//#define LogInfo(...) [[Log shared] \


+ 60
- 53
pEpObjCAdapter/PEPObjCAdapter.m View File

@ -8,6 +8,10 @@
@import Foundation;
#ifdef IS_IOS_BUILD
#import <pEp4iosIntern/pEp4iosIntern.h> //DIRK: //BUFF: !!!
#endif
#import "PEPObjCAdapter.h"
#import "PEPObjCAdapter+Internal.h"
#import "NSError+PEP.h"
@ -15,7 +19,6 @@
#import "PEPInternalSession.h"
#import "PEPPassphraseCache.h"
//#import <pEp4iosIntern/pEp4iosIntern.h> //DIRK: //BUFF: !!!
#import "keymanagement.h"
#import "mime.h"
#import "message.h"
@ -166,32 +169,35 @@ static id<PEPPassphraseProviderProtocol> s_passphraseProvider = nil;
*/
+ (NSURL *)createApplicationDirectoryiOS
{
// NSFileManager *fm = [NSFileManager defaultManager];
// NSURL *containerUrl = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupIdentifier];
// NSLog(@"containerUrl '%@'", containerUrl);
//
// if (containerUrl == nil) {
// // Will happen when running tests, so fall back.
// NSArray *appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory
// inDomains:NSUserDomainMask];
// containerUrl = [appSupportDir lastObject];
// }
//
// if (containerUrl == nil) {
// NSLog(@"ERROR: No app container, no application support directory.");
// }
//
// NSURL *dirPath = [containerUrl URLByAppendingPathComponent:s_pEpHomeComponent];
//
// // If the directory does not exist, this method creates it.
// NSError *theError = nil;
// if (![fm createDirectoryAtURL:dirPath withIntermediateDirectories:YES
// attributes:nil error:&theError]) {
// NSLog(@"ERROR: Could not create pEp home directory, directly writing to app container instead.");
// }
//
// return dirPath;
#ifdef IS_IOS_BUILD //BUFF: DIRK: //!!!:
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *containerUrl = [fm containerURLForSecurityApplicationGroupIdentifier:appGroupIdentifier];
NSLog(@"containerUrl '%@'", containerUrl);
if (containerUrl == nil) {
// Will happen when running tests, so fall back.
NSArray *appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory
inDomains:NSUserDomainMask];
containerUrl = [appSupportDir lastObject];
}
if (containerUrl == nil) {
NSLog(@"ERROR: No app container, no application support directory.");
}
NSURL *dirPath = [containerUrl URLByAppendingPathComponent:s_pEpHomeComponent];
// If the directory does not exist, this method creates it.
NSError *theError = nil;
if (![fm createDirectoryAtURL:dirPath withIntermediateDirectories:YES
attributes:nil error:&theError]) {
NSLog(@"ERROR: Could not create pEp home directory, directly writing to app container instead.");
}
return dirPath;
#else
return [NSURL URLWithString:@"//BUFF:!!!!"];
#endif
}
/**
@ -241,33 +247,34 @@ static id<PEPPassphraseProviderProtocol> s_passphraseProvider = nil;
+ (void)copyAssetsIntoDocumentsDirectory:(NSBundle *)rootBundle
bundleName:(NSString *)bundleName
fileName:(NSString *)fileName {
// NSString *systemDir = [NSString stringWithUTF8String:perMachineDirectory];
//
// if(!(systemDir && bundleName && fileName))
// return;
//
// // Check if the database file exists in the documents directory.
// NSString *destinationPath = [systemDir stringByAppendingPathComponent:fileName];
// if (![[NSFileManager defaultManager] fileExistsAtPath:destinationPath]) {
// // The file does not exist in the documents directory, so copy it from bundle now.
// NSBundle *bundleObj = [NSBundle bundleWithPath:
// [[rootBundle resourcePath]
// stringByAppendingPathComponent: bundleName]];
// if (!bundleObj)
// return;
//
// NSString *sourcePath =[[bundleObj resourcePath] stringByAppendingPathComponent: fileName];
//
// NSError *error;
// [[NSFileManager defaultManager]
// copyItemAtPath:sourcePath toPath:destinationPath error:&error];
//
// // Check if any error occurred during copying and display it.
// if (error != nil) {
// NSLog(@"%@", [error localizedDescription]);
// }
// }
#ifdef IS_IOS_BUILD //BUFF: DIRK: //!!!:
NSString *systemDir = [NSString stringWithUTF8String:perMachineDirectory];
if(!(systemDir && bundleName && fileName))
return;
// Check if the database file exists in the documents directory.
NSString *destinationPath = [systemDir stringByAppendingPathComponent:fileName];
if (![[NSFileManager defaultManager] fileExistsAtPath:destinationPath]) {
// The file does not exist in the documents directory, so copy it from bundle now.
NSBundle *bundleObj = [NSBundle bundleWithPath:
[[rootBundle resourcePath]
stringByAppendingPathComponent: bundleName]];
if (!bundleObj)
return;
NSString *sourcePath =[[bundleObj resourcePath] stringByAppendingPathComponent: fileName];
NSError *error;
[[NSFileManager defaultManager]
copyItemAtPath:sourcePath toPath:destinationPath error:&error];
// Check if any error occurred during copying and display it.
if (error != nil) {
NSLog(@"%@", [error localizedDescription]);
}
}
#endif
}
+ (void)setupTrustWordsDB:(NSBundle *)rootBundle {


Loading…
Cancel
Save