diff --git a/MVMCore/MVMCore.xcodeproj/project.pbxproj b/MVMCore/MVMCore.xcodeproj/project.pbxproj index 5513981..4f939e6 100644 --- a/MVMCore/MVMCore.xcodeproj/project.pbxproj +++ b/MVMCore/MVMCore.xcodeproj/project.pbxproj @@ -203,6 +203,8 @@ 1DAD0FFD26AAB3FF00216E83 /* ActionRunJavaScriptModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionRunJavaScriptModel.swift; sourceTree = ""; }; 2723337A28BD534D004EAEE0 /* MVMCoreEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreEvent.swift; sourceTree = ""; }; 2723337C28BD53C2004EAEE0 /* Date+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+Extension.swift"; sourceTree = ""; }; + 581FABEE2A71D0E6003A8508 /* mvmcore_dev.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = mvmcore_dev.xcconfig; sourceTree = ""; }; + 5836B8E22A4338DF002553D9 /* mvmcore.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = mvmcore.xcconfig; sourceTree = ""; }; 60CBD0532A02397A00056CB0 /* MVMCoreSessionTimeHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreSessionTimeHandler.swift; sourceTree = ""; }; 881D268F1FCC9D180079C521 /* MVMCoreErrorObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreErrorObject.m; sourceTree = ""; }; 881D26901FCC9D180079C521 /* MVMCoreOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreOperation.m; sourceTree = ""; }; @@ -407,6 +409,8 @@ AF26DDAB1FCE5CF2004E8F65 /* Strings */, 8876D5CC1FB50A9E00EB2E3D /* MVMCore.h */, 8876D5CD1FB50A9E00EB2E3D /* Info.plist */, + 5836B8E22A4338DF002553D9 /* mvmcore.xcconfig */, + 581FABEE2A71D0E6003A8508 /* mvmcore_dev.xcconfig */, ); path = MVMCore; sourceTree = ""; @@ -1018,6 +1022,7 @@ /* Begin XCBuildConfiguration section */ 8876D5CF1FB50A9E00EB2E3D /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 581FABEE2A71D0E6003A8508 /* mvmcore_dev.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; BUILD_LIBRARY_FOR_DISTRIBUTION = YES; @@ -1074,6 +1079,7 @@ MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1081,6 +1087,7 @@ }; 8876D5D01FB50A9E00EB2E3D /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5836B8E22A4338DF002553D9 /* mvmcore.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; BUILD_LIBRARY_FOR_DISTRIBUTION = YES; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.h index 775bd55..05020fc 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.h @@ -51,7 +51,7 @@ - (nonnull NSDictionary *)convertToJsonDictionary:(nonnull MVMCoreRequestParameters *)requestParameters; // Creates a request object with the given parameters. -- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error; +- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nullable *_Nonnull)error; // Sends a given request to the server. When it is finished, it calls request finished, passing along the json object or nil if there is an error. - (nullable NSURLSessionTask *)sendRequest:(nonnull MVMCoreRequestParameters *)requestParameters locationForError:(nonnull NSString *)locationForError requestFinished:(nullable void (^)(id _Nullable jsonObject, MVMCoreErrorObject * _Nullable error))requestFinished; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m index 64d67ce..da78878 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadHandler.m @@ -133,7 +133,7 @@ #pragma mark - Request Functions. -- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error { +- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nullable *_Nonnull)error { NSURL *url = [requestParameters resolveURL:[MVMCoreSessionObject sharedGlobal]]; @@ -235,7 +235,7 @@ NSError *jsonError = nil; NSData *data = nil; -#if DEBUG +#if LOGGING // Pretty print for logging the request parameters. data = [NSJSONSerialization dataWithJSONObject:parameters options:NSJSONWritingPrettyPrinted error:&jsonError]; if (!data) { diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index dd5b822..7618fae 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -167,6 +167,12 @@ // Send a new request to the server. [MVMCoreLoadRequestOperation sendRequest:requestForMissingData loadObject:loadObject completionHandler:^(NSDictionary * _Nullable json) { +#if ENABLE_HARD_CODED_RESPONSE + if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(modifyJSON:)]) { + json = [[MVMCoreObject sharedInstance].globalLoadDelegate modifyJSON:json]; + } +#endif + NSString *serverProcessTime = [(NSDictionary *)json objectChainOfKeysOrIndexes:@[@"ResponseInfo", @"timeStamp"]] ?: @"0"; if(!self.backgroundLoad && loadObject.requestParameters.pageType && serverProcessTime) { @@ -291,6 +297,14 @@ return; } +#if ENABLE_HARD_CODED_RESPONSE + if ([[MVMCoreObject sharedInstance].globalLoadDelegate respondsToSelector:@selector(getJSONForPageType:)]) { + NSDictionary *json = [[MVMCoreObject sharedInstance].globalLoadDelegate getJSONForPageType:requestParameters.pageType]; + completionHandler(json); + return; + } +#endif + loadObject.operation.sessionTask = [[MVMCoreLoadHandler sharedGlobal] sendRequest:requestParameters locationForError:[[MVMCoreLoadHandler sharedGlobal] errorLocationForRequest:loadObject] requestFinished:^(id jsonObject, MVMCoreErrorObject *error) { if ([loadObject.operation checkAndHandleForCancellation]) { diff --git a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h index 65ea153..938b13c 100644 --- a/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h +++ b/MVMCore/MVMCore/MainProtocols/MVMCoreGlobalLoadProtocol.h @@ -41,4 +41,9 @@ /// Checks to see if the operation has content to show. - (BOOL)hasContentToShow:(nonnull MVMCoreLoadObject *)loadObject error:(nullable MVMCoreErrorObject *)error; +#if ENABLE_HARD_CODED_RESPONSE +- (nonnull NSDictionary *)getJSONForPageType:(nonnull NSString *)pageType; +- (nonnull NSDictionary *)modifyJSON:(nonnull NSDictionary *)json; +#endif + @end diff --git a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift index f0d78c2..1e79573 100644 --- a/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift +++ b/MVMCore/MVMCore/Models/ActionType/Client Parameters/ClientParameterHandler.swift @@ -8,7 +8,7 @@ @objcMembers open class ClientParameterHandler: NSObject { - static let DefaultTimeout = 30.0 + public static let DefaultTimeout = 30.0 open func createParametersHandler(_ clientParameterModel: ClientParameterModelProtocol) -> ClientParameterProtocol? { do { diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m index 4fb541a..6978815 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreLoggingHandler.m @@ -50,7 +50,7 @@ #pragma mark - logging delegate - (void)handleDebugMessage:(nullable NSString *)message { -#ifdef DEBUG +#ifdef LOGGING [self printWith:message]; #endif } diff --git a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h index eb9fba9..cef5abb 100644 --- a/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h +++ b/MVMCore/MVMCore/Utility/HardCodedServerResponse/MFHardCodedServerResponse.h @@ -9,8 +9,6 @@ #import #import "MVMCoreRequestParameters.h" -#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG - #if ENABLE_HARD_CODED_RESPONSE @interface MFHardCodedServerResponse : NSObject diff --git a/MVMCore/MVMCore/mvmcore.xcconfig b/MVMCore/MVMCore/mvmcore.xcconfig new file mode 100644 index 0000000..a098409 --- /dev/null +++ b/MVMCore/MVMCore/mvmcore.xcconfig @@ -0,0 +1,20 @@ +// +// mvmcore.xcconfig +// MVMCore +// +// Preprocessor definitions include: +// 1. LOGGING - For enabling logging to the device logs. +// 2. ENABLE_HARD_CODED_RESPONSE - For enabling hard coded responses. +// +// Created by Kyle Hedden on 6/21/23. +// Copyright © 2023 myverizon. All rights reserved. +// + +// Configuration settings file format documentation can be found at: +// https://help.apple.com/xcode/#/dev745c5c974 + +// Refer back to the workspace settings if they exist. +#include? "../../../workspaceSettings.xcconfig" + +// For enabling hardcoded JSON payloads. +//GCC_PREPROCESSOR_DEFINITIONS = $(inherited) ENABLE_HARD_CODED_RESPONSE=1 diff --git a/MVMCore/MVMCore/mvmcore_dev.xcconfig b/MVMCore/MVMCore/mvmcore_dev.xcconfig new file mode 100644 index 0000000..470d90c --- /dev/null +++ b/MVMCore/MVMCore/mvmcore_dev.xcconfig @@ -0,0 +1,23 @@ +// +// mvmcore_dev.xcconfig +// MVMCore +// +// Preprocessor definitions include: +// 1. LOGGING - For enabling logging to the device logs. +// 2. ENABLE_HARD_CODED_RESPONSE - For enabling hard coded responses. +// +// Created by Kyle Hedden on 7/26/23. +// Copyright © 2023 myverizon. All rights reserved. +// + +// Configuration settings file format documentation can be found at: +// https://help.apple.com/xcode/#/dev745c5c974 + +SWIFT_ACTIVE_COMPILATION_CONDITIONS = $(inherited) LOGGING +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) LOGGING=1 + +// Refer back to the workspace settings if they exist. +#include? "../../../workspaceSettings.xcconfig" + +// For enabling hardcoded JSON payloads. +//GCC_PREPROCESSOR_DEFINITIONS = $(inherited) ENABLE_HARD_CODED_RESPONSE=1