From 5dab74168a8c69c8daeed002c97aa529f60c4253 Mon Sep 17 00:00:00 2001 From: Chante-Gobel_dotd Date: Wed, 8 Apr 2026 11:58:40 +0200 Subject: [PATCH] Migrate demo apps from CocoaPods to SPM - Remove Podfile and Podfile.lock - Add CMPComapiFoundation and SnapKit as SPM dependencies in project.pbxproj - Replace JWT/Base64 CocoaPods with native CommonCrypto JWT implementation in both ObjC and Swift auth managers - Remove CocoaPods bridging header imports (JWT, Base64) from Swift bridging header - Add missing UIKit, CMPComapiFoundation, SnapKit imports across Swift demo app files - Fix Info.plist credentials for both apps (SERVER_SCHEME/SERVER_HOST were swapped) - Update Package.resolved with SnapKit 5.7.1 --- .../project.pbxproj | 169 ++++-------------- .../contents.xcworkspacedata | 7 + .../AppConfigurator/AppConfigurator.swift | 3 +- .../AuthenticationManager.swift | 75 +++++--- .../Subviews/Cells/ChatTextMessageCell.swift | 3 +- .../List/Subviews/MessageStatusView.swift | 1 + .../Chat/List/ViewModel/ChatViewModel.swift | 3 +- ...piFoundationSample-Swift-Bridging-Header.h | 14 -- .../CreateConversationViewModel.swift | 2 +- .../ViewModel/ConversationViewModel.swift | 4 +- .../Authentication/CMPAuthenticationManager.m | 49 +++-- Demo/Podfile | 17 -- Demo/Podfile.lock | 24 --- Package.resolved | 9 + 14 files changed, 142 insertions(+), 238 deletions(-) create mode 100644 Demo/CMPComapiFoundation.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Demo/Podfile delete mode 100644 Demo/Podfile.lock diff --git a/Demo/CMPComapiFoundation.xcodeproj/project.pbxproj b/Demo/CMPComapiFoundation.xcodeproj/project.pbxproj index 1fcea79..bf47183 100644 --- a/Demo/CMPComapiFoundation.xcodeproj/project.pbxproj +++ b/Demo/CMPComapiFoundation.xcodeproj/project.pbxproj @@ -3,11 +3,10 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ - 2FB8043827438E2927866A4F /* Pods_Shared_ComapiFoundationSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 88CD7F048D7EF2A92A6CF1E7 /* Pods_Shared_ComapiFoundationSample.framework */; }; 316EA9A32F59926300F2885F /* CMPComapiFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 316EA9A22F59926300F2885F /* CMPComapiFoundation */; settings = {ATTRIBUTES = (Required, ); }; }; 316EA9A52F59937F00F2885F /* CMPComapiFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 316EA9A42F59937F00F2885F /* CMPComapiFoundation */; }; 316EA9A72F59DACD00F2885F /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 316EA9A62F59DACD00F2885F /* Security.framework */; }; @@ -122,7 +121,7 @@ 89EA5CDA214962AC00C29D08 /* CMPProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89EA5CD9214962AC00C29D08 /* CMPProfileViewController.m */; }; 89EA5CDD214962C900C29D08 /* CMPProfileViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 89EA5CDC214962C900C29D08 /* CMPProfileViewModel.m */; }; 89EA5CE4214967D800C29D08 /* CMPTitledCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 89EA5CE3214967D800C29D08 /* CMPTitledCell.m */; }; - D63DAA36BD425AA948ABB5E2 /* Pods_Shared_ComapiFoundationSample_Swift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4785D7B1A753E2B9F7E8E47 /* Pods_Shared_ComapiFoundationSample_Swift.framework */; }; + AABBCC001111EEEE /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = AABBCC001111FFFF /* SnapKit */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -151,10 +150,6 @@ /* Begin PBXFileReference section */ 316EA99B2F588EA600F2885F /* comapi-sdk-ios-spm */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "comapi-sdk-ios-spm"; path = ..; sourceTree = ""; }; 316EA9A62F59DACD00F2885F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - 631221202849C7DE27DA3D63 /* Pods-Shared-ComapiFoundationSample-Swift.staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample-Swift.staging.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift.staging.xcconfig"; sourceTree = ""; }; - 733AFD283AEAA8BDC519EA07 /* Pods-Shared-ComapiFoundationSample-Swift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample-Swift.debug.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift.debug.xcconfig"; sourceTree = ""; }; - 7C74F3B303747ACCB109769A /* Pods-Shared-ComapiFoundationSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample.debug.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample.debug.xcconfig"; sourceTree = ""; }; - 88CD7F048D7EF2A92A6CF1E7 /* Pods_Shared_ComapiFoundationSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Shared_ComapiFoundationSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8915FE9A225611BC00EB9A4A /* ComapiFoundationSample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ComapiFoundationSample.entitlements; sourceTree = ""; }; 8915FE9B225611C200EB9A4A /* ComapiFoundationSample-Swift.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "ComapiFoundationSample-Swift.entitlements"; sourceTree = ""; }; 89259E7121524F3A00C73A02 /* CMPProfileDetailsView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMPProfileDetailsView.h; sourceTree = ""; }; @@ -330,10 +325,6 @@ 89EA5CDC214962C900C29D08 /* CMPProfileViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CMPProfileViewModel.m; sourceTree = ""; }; 89EA5CE2214967D800C29D08 /* CMPTitledCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CMPTitledCell.h; sourceTree = ""; }; 89EA5CE3214967D800C29D08 /* CMPTitledCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CMPTitledCell.m; sourceTree = ""; }; - 91430C4BDBB9024848F26581 /* Pods-Shared-ComapiFoundationSample.staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample.staging.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample.staging.xcconfig"; sourceTree = ""; }; - BA39311F2D3303F828C826B6 /* Pods-Shared-ComapiFoundationSample-Swift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample-Swift.release.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift.release.xcconfig"; sourceTree = ""; }; - D532954CAED159560A9F530F /* Pods-Shared-ComapiFoundationSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Shared-ComapiFoundationSample.release.xcconfig"; path = "Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample.release.xcconfig"; sourceTree = ""; }; - E4785D7B1A753E2B9F7E8E47 /* Pods_Shared_ComapiFoundationSample_Swift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Shared_ComapiFoundationSample_Swift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -343,7 +334,6 @@ files = ( 316EA9A72F59DACD00F2885F /* Security.framework in Frameworks */, 316EA9A32F59926300F2885F /* CMPComapiFoundation in Frameworks */, - 2FB8043827438E2927866A4F /* Pods_Shared_ComapiFoundationSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -352,7 +342,7 @@ buildActionMask = 2147483647; files = ( 316EA9A52F59937F00F2885F /* CMPComapiFoundation in Frameworks */, - D63DAA36BD425AA948ABB5E2 /* Pods_Shared_ComapiFoundationSample_Swift.framework in Frameworks */, + AABBCC001111EEEE /* SnapKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -363,8 +353,6 @@ isa = PBXGroup; children = ( 316EA9A62F59DACD00F2885F /* Security.framework */, - 88CD7F048D7EF2A92A6CF1E7 /* Pods_Shared_ComapiFoundationSample.framework */, - E4785D7B1A753E2B9F7E8E47 /* Pods_Shared_ComapiFoundationSample_Swift.framework */, ); name = Frameworks; sourceTree = ""; @@ -1049,8 +1037,6 @@ 89957A66213935E0008EE0BE /* ComapiFoundationSample */, 89E459D421ABFDDA002C26AE /* ComapiFoundationSample-Swift */, 89C8DE3F2122DF3C00555495 /* Products */, - F698CE1B51A5412278830598 /* Pods */, - 89E01D3F231685C0005F6A77 /* Config */, 0283F3BFD067A4BC84703AC7 /* Frameworks */, ); sourceTree = ""; @@ -1197,13 +1183,6 @@ path = View; sourceTree = ""; }; - 89E01D3F231685C0005F6A77 /* Config */ = { - isa = PBXGroup; - children = ( - ); - path = Config; - sourceTree = ""; - }; 89E459D421ABFDDA002C26AE /* ComapiFoundationSample-Swift */ = { isa = PBXGroup; children = ( @@ -1281,19 +1260,6 @@ path = Cells; sourceTree = ""; }; - F698CE1B51A5412278830598 /* Pods */ = { - isa = PBXGroup; - children = ( - 7C74F3B303747ACCB109769A /* Pods-Shared-ComapiFoundationSample.debug.xcconfig */, - 91430C4BDBB9024848F26581 /* Pods-Shared-ComapiFoundationSample.staging.xcconfig */, - D532954CAED159560A9F530F /* Pods-Shared-ComapiFoundationSample.release.xcconfig */, - 733AFD283AEAA8BDC519EA07 /* Pods-Shared-ComapiFoundationSample-Swift.debug.xcconfig */, - 631221202849C7DE27DA3D63 /* Pods-Shared-ComapiFoundationSample-Swift.staging.xcconfig */, - BA39311F2D3303F828C826B6 /* Pods-Shared-ComapiFoundationSample-Swift.release.xcconfig */, - ); - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -1301,12 +1267,10 @@ isa = PBXNativeTarget; buildConfigurationList = 89957A78213935E3008EE0BE /* Build configuration list for PBXNativeTarget "ComapiFoundationSample" */; buildPhases = ( - 8E811AE0C1657BB3510F99D5 /* [CP] Check Pods Manifest.lock */, 89957A61213935E0008EE0BE /* Sources */, 89957A62213935E0008EE0BE /* Frameworks */, 89957A63213935E0008EE0BE /* Resources */, 89E39C6922D7559800EF794F /* Embed Frameworks */, - 5DB123F95443F6B038CD2102 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1325,12 +1289,10 @@ isa = PBXNativeTarget; buildConfigurationList = 89E459E221ABFDDD002C26AE /* Build configuration list for PBXNativeTarget "ComapiFoundationSample-Swift" */; buildPhases = ( - 1EA203B13A0231433ABBDB65 /* [CP] Check Pods Manifest.lock */, 89E459CF21ABFDDA002C26AE /* Sources */, 89E459D021ABFDDA002C26AE /* Frameworks */, 89E459D121ABFDDA002C26AE /* Resources */, 8939219623295AE5008C5EDD /* Embed Frameworks */, - D03F70E4F56170E5AA213918 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1340,6 +1302,7 @@ name = "ComapiFoundationSample-Swift"; packageProductDependencies = ( 316EA9A42F59937F00F2885F /* CMPComapiFoundation */, + AABBCC001111FFFF /* SnapKit */, ); productName = SampleAppSwift; productReference = 89E459D321ABFDDA002C26AE /* ComapiFoundationSample-Swift.app */; @@ -1389,6 +1352,9 @@ Base, ); mainGroup = 89C8DE342122DF3C00555495; + packageReferences = ( + AABBCC002222BBBB /* XCRemoteSwiftPackageReference "SnapKit" */, + ); productRefGroup = 89C8DE3F2122DF3C00555495 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -1420,87 +1386,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 1EA203B13A0231433ABBDB65 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Shared-ComapiFoundationSample-Swift-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - 5DB123F95443F6B038CD2102 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample/Pods-Shared-ComapiFoundationSample-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 8E811AE0C1657BB3510F99D5 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Shared-ComapiFoundationSample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; - D03F70E4F56170E5AA213918 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Shared-ComapiFoundationSample-Swift/Pods-Shared-ComapiFoundationSample-Swift-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 89957A61213935E0008EE0BE /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1656,7 +1541,6 @@ /* Begin XCBuildConfiguration section */ 89957A79213935E3008EE0BE /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7C74F3B303747ACCB109769A /* Pods-Shared-ComapiFoundationSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = ComapiFoundationSample/ComapiFoundationSample.entitlements; @@ -1666,7 +1550,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = ComapiFoundationSample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1682,7 +1566,6 @@ }; 89957A7A213935E3008EE0BE /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = D532954CAED159560A9F530F /* Pods-Shared-ComapiFoundationSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = ComapiFoundationSample/ComapiFoundationSample.entitlements; @@ -1692,7 +1575,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = ComapiFoundationSample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1758,7 +1641,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; @@ -1813,7 +1696,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; @@ -1876,7 +1759,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; @@ -1887,7 +1770,6 @@ }; 89E01D3D2316858D005F6A77 /* Staging */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 91430C4BDBB9024848F26581 /* Pods-Shared-ComapiFoundationSample.staging.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = ComapiFoundationSample/ComapiFoundationSample.entitlements; @@ -1897,7 +1779,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = ComapiFoundationSample/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1913,7 +1795,6 @@ }; 89E01D3E2316858D005F6A77 /* Staging */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 631221202849C7DE27DA3D63 /* Pods-Shared-ComapiFoundationSample-Swift.staging.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1924,7 +1805,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "ComapiFoundationSample-Swift/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1948,7 +1829,6 @@ }; 89E459E321ABFDDD002C26AE /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 733AFD283AEAA8BDC519EA07 /* Pods-Shared-ComapiFoundationSample-Swift.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1959,7 +1839,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "ComapiFoundationSample-Swift/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1983,7 +1863,6 @@ }; 89E459E421ABFDDD002C26AE /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BA39311F2D3303F828C826B6 /* Pods-Shared-ComapiFoundationSample-Swift.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; @@ -1994,7 +1873,7 @@ DEVELOPMENT_TEAM = JE27K8BAX2; HEADER_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "ComapiFoundationSample-Swift/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2050,6 +1929,17 @@ }; /* End XCConfigurationList section */ +/* Begin XCRemoteSwiftPackageReference section */ + AABBCC002222BBBB /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ 316EA9A22F59926300F2885F /* CMPComapiFoundation */ = { isa = XCSwiftPackageProductDependency; @@ -2059,6 +1949,11 @@ isa = XCSwiftPackageProductDependency; productName = CMPComapiFoundation; }; + AABBCC001111FFFF /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = AABBCC002222BBBB /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 89C8DE352122DF3C00555495 /* Project object */; diff --git a/Demo/CMPComapiFoundation.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Demo/CMPComapiFoundation.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Demo/CMPComapiFoundation.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Demo/ComapiFoundationSample-Swift/AppConfigurator/AppConfigurator.swift b/Demo/ComapiFoundationSample-Swift/AppConfigurator/AppConfigurator.swift index dbc6747..94eafbb 100644 --- a/Demo/ComapiFoundationSample-Swift/AppConfigurator/AppConfigurator.swift +++ b/Demo/ComapiFoundationSample-Swift/AppConfigurator/AppConfigurator.swift @@ -16,7 +16,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +import UIKit +import CMPComapiFoundation class AppConfigurator: NSObject { let window: UIWindow diff --git a/Demo/ComapiFoundationSample-Swift/Authentication/AuthenticationManager.swift b/Demo/ComapiFoundationSample-Swift/Authentication/AuthenticationManager.swift index 43d265e..f306f1a 100644 --- a/Demo/ComapiFoundationSample-Swift/Authentication/AuthenticationManager.swift +++ b/Demo/ComapiFoundationSample-Swift/Authentication/AuthenticationManager.swift @@ -16,39 +16,62 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -import JWT +import Foundation +import CommonCrypto class JWTokenGenerator { - + struct AuthHeaders { static let HeaderType = "JWT" } - + static func generate(tokenFor nonce: String, profileId: String, issuer: String, audience: String, secret: String) -> String { let now = Date() let exp = Calendar.current.date(byAdding: .day, value: 30, to: now)! - - let base64SecretKey = secret.data(using: .utf8)! - - let headers = ["typ" : NSString.init(string: AuthHeaders.HeaderType)] as [AnyHashable : Any] - - let claims = ["nonce" : NSString.init(string: nonce), - "sub" : NSString.init(string: profileId), - "iss" : NSString.init(string: issuer), - "aud" : NSString.init(string: audience), - "iat" : NSNumber(value: now.timeIntervalSince1970), - "exp" : NSNumber(value: exp.timeIntervalSince1970)] as [AnyHashable : Any] - - let algorithm = JWTAlgorithmFactory.algorithm(byName: "HS256") - - let e = JWTBuilder.encodePayload(claims)! - - let h = e.headers(headers)! - let s = h.secretData(base64SecretKey)! - let b = s.algorithm(algorithm)! - let token = b.encode - - print(token!) - return token! + + let header: [String: Any] = ["alg": "HS256", "typ": AuthHeaders.HeaderType] + let claims: [String: Any] = [ + "nonce": nonce, + "sub": profileId, + "iss": issuer, + "aud": audience, + "iat": Int(now.timeIntervalSince1970), + "exp": Int(exp.timeIntervalSince1970) + ] + + let headerData = try! JSONSerialization.data(withJSONObject: header) + let claimsData = try! JSONSerialization.data(withJSONObject: claims) + + let headerEncoded = base64URLEncode(headerData) + let claimsEncoded = base64URLEncode(claimsData) + let signingInput = "\(headerEncoded).\(claimsEncoded)" + + let signingData = signingInput.data(using: .utf8)! + let secretData = secret.data(using: .utf8)! + let signature = hmacSHA256(data: signingData, key: secretData) + + let token = "\(signingInput).\(signature)" + print(token) + return token + } + + private static func base64URLEncode(_ data: Data) -> String { + return data.base64EncodedString() + .replacingOccurrences(of: "+", with: "-") + .replacingOccurrences(of: "/", with: "_") + .replacingOccurrences(of: "=", with: "") + } + + private static func hmacSHA256(data: Data, key: Data) -> String { + var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH)) + data.withUnsafeBytes { dataBytes in + key.withUnsafeBytes { keyBytes in + CCHmac(CCHmacAlgorithm(kCCHmacAlgSHA256), + keyBytes.baseAddress, key.count, + dataBytes.baseAddress, data.count, + &digest) + } + } + return base64URLEncode(Data(digest)) } } diff --git a/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/Cells/ChatTextMessageCell.swift b/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/Cells/ChatTextMessageCell.swift index 5abd0dc..00a62e1 100644 --- a/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/Cells/ChatTextMessageCell.swift +++ b/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/Cells/ChatTextMessageCell.swift @@ -16,7 +16,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +import UIKit +import SnapKit class ChatTextMessageCell: BaseTableViewCell { diff --git a/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/MessageStatusView.swift b/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/MessageStatusView.swift index 9204233..1cb7359 100644 --- a/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/MessageStatusView.swift +++ b/Demo/ComapiFoundationSample-Swift/Chat/List/Subviews/MessageStatusView.swift @@ -16,6 +16,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import UIKit import SnapKit diff --git a/Demo/ComapiFoundationSample-Swift/Chat/List/ViewModel/ChatViewModel.swift b/Demo/ComapiFoundationSample-Swift/Chat/List/ViewModel/ChatViewModel.swift index 2de33e1..5ef846e 100644 --- a/Demo/ComapiFoundationSample-Swift/Chat/List/ViewModel/ChatViewModel.swift +++ b/Demo/ComapiFoundationSample-Swift/Chat/List/ViewModel/ChatViewModel.swift @@ -16,7 +16,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +import UIKit +import CMPComapiFoundation class ChatViewModel: NSObject { diff --git a/Demo/ComapiFoundationSample-Swift/ComapiFoundationSample-Swift-Bridging-Header.h b/Demo/ComapiFoundationSample-Swift/ComapiFoundationSample-Swift-Bridging-Header.h index d494bb1..866024e 100644 --- a/Demo/ComapiFoundationSample-Swift/ComapiFoundationSample-Swift-Bridging-Header.h +++ b/Demo/ComapiFoundationSample-Swift/ComapiFoundationSample-Swift-Bridging-Header.h @@ -16,18 +16,4 @@ #else @import CMPComapiFoundation; #endif -#if __has_include() -#import -#elif __has_include() -#import -#else -@import Base64; -#endif -#if __has_include() -#import -#elif __has_include() -#import -#else -@import JWT; -#endif diff --git a/Demo/ComapiFoundationSample-Swift/Conversation/Create/ViewModel/CreateConversationViewModel.swift b/Demo/ComapiFoundationSample-Swift/Conversation/Create/ViewModel/CreateConversationViewModel.swift index c5216b5..ffdf25f 100644 --- a/Demo/ComapiFoundationSample-Swift/Conversation/Create/ViewModel/CreateConversationViewModel.swift +++ b/Demo/ComapiFoundationSample-Swift/Conversation/Create/ViewModel/CreateConversationViewModel.swift @@ -16,7 +16,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +import CMPComapiFoundation class CreateConversationViewModel { diff --git a/Demo/ComapiFoundationSample-Swift/Conversation/List/ViewModel/ConversationViewModel.swift b/Demo/ComapiFoundationSample-Swift/Conversation/List/ViewModel/ConversationViewModel.swift index 7e0d41e..fb835e7 100644 --- a/Demo/ComapiFoundationSample-Swift/Conversation/List/ViewModel/ConversationViewModel.swift +++ b/Demo/ComapiFoundationSample-Swift/Conversation/List/ViewModel/ConversationViewModel.swift @@ -16,9 +16,9 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // - +import UIKit import UserNotifications - +import CMPComapiFoundation class ConversationViewModel: NSObject { diff --git a/Demo/ComapiFoundationSample/Authentication/CMPAuthenticationManager.m b/Demo/ComapiFoundationSample/Authentication/CMPAuthenticationManager.m index b3a6d66..20f24be 100644 --- a/Demo/ComapiFoundationSample/Authentication/CMPAuthenticationManager.m +++ b/Demo/ComapiFoundationSample/Authentication/CMPAuthenticationManager.m @@ -17,28 +17,49 @@ // #import "CMPAuthenticationManager.h" +#import -#import +static NSString *base64URLEncode(NSData *data) { + NSString *base64 = [data base64EncodedStringWithOptions:0]; + base64 = [base64 stringByReplacingOccurrencesOfString:@"+" withString:@"-"]; + base64 = [base64 stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; + base64 = [base64 stringByReplacingOccurrencesOfString:@"=" withString:@""]; + return base64; +} @implementation CMPAuthenticationManager + (NSString *)generateTokenForNonce:(NSString *)nonce profileID:(NSString *)profileID issuer:(NSString *)issuer audience:(NSString *)audience secret:(NSString *)secret { NSDate *now = [NSDate date]; NSDate *exp = [NSCalendar.currentCalendar dateByAddingUnit:NSCalendarUnitDay value:30 toDate:now options:0]; - - NSDictionary *headers = @{@"typ" : @"JWT"}; - NSDictionary *payload = @{@"nonce" : nonce, - @"sub" : profileID, - @"iss" : issuer, - @"aud" : audience, - @"iat" : [NSNumber numberWithDouble:now.timeIntervalSince1970], - @"exp" : [NSNumber numberWithDouble:exp.timeIntervalSince1970]}; - + + NSDictionary *header = @{@"alg": @"HS256", @"typ": @"JWT"}; + NSDictionary *payload = @{@"nonce": nonce, + @"sub": profileID, + @"iss": issuer, + @"aud": audience, + @"iat": @((long long)now.timeIntervalSince1970), + @"exp": @((long long)exp.timeIntervalSince1970)}; + + NSData *headerData = [NSJSONSerialization dataWithJSONObject:header options:0 error:nil]; + NSData *payloadData = [NSJSONSerialization dataWithJSONObject:payload options:0 error:nil]; + + NSString *headerEncoded = base64URLEncode(headerData); + NSString *payloadEncoded = base64URLEncode(payloadData); + NSString *signingInput = [NSString stringWithFormat:@"%@.%@", headerEncoded, payloadEncoded]; + + NSData *signingData = [signingInput dataUsingEncoding:NSUTF8StringEncoding]; NSData *secretData = [secret dataUsingEncoding:NSUTF8StringEncoding]; - id algorithm = [JWTAlgorithmFactory algorithmByName:@"HS256"]; - - NSString *token = [JWTBuilder encodePayload:payload].headers(headers).secretData(secretData).algorithm(algorithm).encode; - return token; + + uint8_t digest[CC_SHA256_DIGEST_LENGTH]; + CCHmac(kCCHmacAlgSHA256, + secretData.bytes, secretData.length, + signingData.bytes, signingData.length, + digest); + NSData *signatureData = [NSData dataWithBytes:digest length:CC_SHA256_DIGEST_LENGTH]; + NSString *signature = base64URLEncode(signatureData); + + return [NSString stringWithFormat:@"%@.%@", signingInput, signature]; } @end diff --git a/Demo/Podfile b/Demo/Podfile deleted file mode 100644 index 93d8319..0000000 --- a/Demo/Podfile +++ /dev/null @@ -1,17 +0,0 @@ -platform :ios, '10.0' -use_frameworks! -inhibit_all_warnings! - -abstract_target 'Shared' do - - target 'ComapiFoundationSample' do - pod 'JWT' - end - - target 'ComapiFoundationSample-Swift' do - pod 'JWT' - pod 'SnapKit' - end -end - - diff --git a/Demo/Podfile.lock b/Demo/Podfile.lock deleted file mode 100644 index 4c07033..0000000 --- a/Demo/Podfile.lock +++ /dev/null @@ -1,24 +0,0 @@ -PODS: - - Base64 (1.1.2) - - JWT (2.2.0): - - Base64 (~> 1.1.2) - - SnapKit (5.0.0) - -DEPENDENCIES: - - JWT - - SnapKit - -SPEC REPOS: - trunk: - - Base64 - - JWT - - SnapKit - -SPEC CHECKSUMS: - Base64: cecfb41a004124895a7bcee567a89bae5a89d49b - JWT: cf73c0ab0dac762df3de8a3f1164352089d97780 - SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf - -PODFILE CHECKSUM: 6d83dc0b022cb649ec48e600a63dae1ea31d1c69 - -COCOAPODS: 1.11.2 diff --git a/Package.resolved b/Package.resolved index ccb13f7..a378621 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,14 @@ { "pins" : [ + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit", + "state" : { + "revision" : "2842e6e84e82eb9a8dac0100ca90d9444b0307f4", + "version" : "5.7.1" + } + }, { "identity" : "socketrocketspm", "kind" : "remoteSourceControl",