diff --git a/NStackSDK.podspec b/NStackSDK.podspec new file mode 100644 index 0000000..8af1d96 --- /dev/null +++ b/NStackSDK.podspec @@ -0,0 +1,37 @@ +# +# Be sure to run `pod lib lint TuvaUI.podspec' to ensure this is a +# valid spec before submitting. +# +# Any lines starting with a # are optional, but their use is encouraged +# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html +# + +Pod::Spec.new do |s| + s.name = 'NStackSDK' + s.version = '5.1.3' + s.summary = 'NStackSDK is the companion software development kit to the NStack backend.' + +# This description is used to generate tags and improve search results. +# * Think: What does it do? Why did you write it? What is the focus? +# * Try to keep it short, snappy and to the point. +# * Write the description between the DESC delimiters below. +# * Finally, don't worry about the indent, CocoaPods strips it! + s.description = <<-DESC + NStack is Nodes\' "Backend as a Service" product that enables clients to manage many aspects of their products by themselves. + DESC + + s.homepage = 'https://github.com/nstack-io/nstack-ios-sdk' + s.license = { :type => "MIT", :file => "LICENSE" } + s.author = { "Nodes Agency - iOS" => "ios@nodes.dk" } + s.source = { :git => 'https://github.com/nstack-io/nstack-ios-sdk', :tag => s.version.to_s } + + s.ios.deployment_target = "11" + s.swift_version = '5.2' + + s.default_subspecs = "Core" + s.dependency 'NLocalizationManager' + + s.subspec 'Core' do |core| + core.source_files = [ 'NStackSDK/**/*.swift'] + end +end diff --git a/NStackSDK.xcodeproj/project.pbxproj b/NStackSDK.xcodeproj/project.pbxproj index 88dfe46..de33ec2 100644 --- a/NStackSDK.xcodeproj/project.pbxproj +++ b/NStackSDK.xcodeproj/project.pbxproj @@ -93,10 +93,8 @@ 2346FDA2233B6BC40025B68D /* Countries.json in Resources */ = {isa = PBXBuildFile; fileRef = 2346FD6D233B65400025B68D /* Countries.json */; }; 2346FDA3233B6C680025B68D /* Countries.json in Resources */ = {isa = PBXBuildFile; fileRef = 2346FD6D233B65400025B68D /* Countries.json */; }; 23BD95C322CD00DB001759CE /* AppOpenMockRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23BD95C222CD00DB001759CE /* AppOpenMockRepository.swift */; }; - 2909463824211DEF00BA254F /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29A72DF623FFECE500CE8483 /* LocalizationManager.framework */; }; 29A72DF023FFEC9600CE8483 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29A72DEF23FFEC9600CE8483 /* LocalizationManager.framework */; }; 29A72DF323FFECD700CE8483 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29A72DF223FFECD700CE8483 /* LocalizationManager.framework */; }; - 29A72DF723FFECE500CE8483 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29A72DF623FFECE500CE8483 /* LocalizationManager.framework */; }; 29A72DFB23FFECED00CE8483 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29A72DFA23FFECED00CE8483 /* LocalizationManager.framework */; }; 29A72DFF24000DFD00CE8483 /* LocalizationConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A72DFE24000DFD00CE8483 /* LocalizationConfig.swift */; }; 29A72E002400166400CE8483 /* LocalizationConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A72DFE24000DFD00CE8483 /* LocalizationConfig.swift */; }; @@ -186,6 +184,8 @@ A83A140922F2CB5C002A7682 /* SectionKeyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = A83A140822F2CB5C002A7682 /* SectionKeyHelper.swift */; }; A864BBEC22F31AD200CC2BFF /* LocalizationItemIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = A864BBEB22F31AD200CC2BFF /* LocalizationItemIdentifier.swift */; }; A8ECFA3022F44E2D009D2175 /* ProposalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8ECFA2E22F44E2D009D2175 /* ProposalViewController.swift */; }; + B4369B1D242A1A8800156B68 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B4369B1C242A1A8800156B68 /* LocalizationManager.framework */; }; + B4369B1E242A1A8800156B68 /* LocalizationManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B4369B1C242A1A8800156B68 /* LocalizationManager.framework */; }; C0D852CE215A2C390090B7C5 /* Codable+Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D852CD215A2C390090B7C5 /* Codable+Dictionary.swift */; }; C0D852CF215A2C390090B7C5 /* Codable+Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D852CD215A2C390090B7C5 /* Codable+Dictionary.swift */; }; C0D852D0215A2C390090B7C5 /* Codable+Dictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0D852CD215A2C390090B7C5 /* Codable+Dictionary.swift */; }; @@ -327,7 +327,6 @@ 23BD95C222CD00DB001759CE /* AppOpenMockRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppOpenMockRepository.swift; sourceTree = ""; }; 29A72DEF23FFEC9600CE8483 /* LocalizationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalizationManager.framework; path = Carthage/Build/Mac/LocalizationManager.framework; sourceTree = ""; }; 29A72DF223FFECD700CE8483 /* LocalizationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalizationManager.framework; path = Carthage/Build/iOS/LocalizationManager.framework; sourceTree = ""; }; - 29A72DF623FFECE500CE8483 /* LocalizationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalizationManager.framework; path = Carthage/Build/tvOS/LocalizationManager.framework; sourceTree = ""; }; 29A72DFA23FFECED00CE8483 /* LocalizationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalizationManager.framework; path = Carthage/Build/watchOS/LocalizationManager.framework; sourceTree = ""; }; 29A72DFE24000DFD00CE8483 /* LocalizationConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizationConfig.swift; sourceTree = ""; }; 29D7EB5223FAB71900C622EA /* TranslationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TranslationManager.framework; path = Carthage/Build/iOS/TranslationManager.framework; sourceTree = ""; }; @@ -348,7 +347,6 @@ 33E222ED1FA8C5280013CCC3 /* Validation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Validation.swift; path = Classes/Model/Validation.swift; sourceTree = ""; }; 33E223021FA9F4EA0013CCC3 /* IPAddress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = IPAddress.swift; path = Classes/Model/IPAddress.swift; sourceTree = ""; }; 33E2230A1FA9F5010013CCC3 /* Continent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Continent.swift; path = Classes/Model/Continent.swift; sourceTree = ""; }; - 7579C77123C346CE00A05022 /* APIFeedbackManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIFeedbackManager.swift; sourceTree = ""; }; 82CB55491C8DEAC200389D2B /* AppOpenResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppOpenResponse.swift; path = Classes/Model/AppOpenResponse.swift; sourceTree = ""; }; 82CB554A1C8DEAC200389D2B /* LanguageData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LanguageData.swift; path = Classes/Model/LanguageData.swift; sourceTree = ""; }; 839497BE1DC21DBF007FE281 /* Country.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Country.swift; path = Classes/Model/Country.swift; sourceTree = ""; }; @@ -376,6 +374,8 @@ A83A140822F2CB5C002A7682 /* SectionKeyHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SectionKeyHelper.swift; sourceTree = ""; }; A864BBEB22F31AD200CC2BFF /* LocalizationItemIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizationItemIdentifier.swift; sourceTree = ""; }; A8ECFA2E22F44E2D009D2175 /* ProposalViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProposalViewController.swift; sourceTree = ""; }; + B4369B1B242A19DF00156B68 /* NStackSDK.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = NStackSDK.podspec; sourceTree = ""; }; + B4369B1C242A1A8800156B68 /* LocalizationManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalizationManager.framework; path = Carthage/Build/tvOS/LocalizationManager.framework; sourceTree = ""; }; C0D852CD215A2C390090B7C5 /* Codable+Dictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Codable+Dictionary.swift"; sourceTree = ""; }; C0D852D7215A373F0090B7C5 /* Routes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Routes.swift; sourceTree = ""; }; C0D852E2215A42EE0090B7C5 /* URLSession+Request.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+Request.swift"; sourceTree = ""; }; @@ -426,7 +426,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 29A72DF723FFECE500CE8483 /* LocalizationManager.framework in Frameworks */, + B4369B1D242A1A8800156B68 /* LocalizationManager.framework in Frameworks */, E3689BF91D9EBA14004620D6 /* Foundation.framework in Frameworks */, E3689BFA1D9EBA14004620D6 /* UIKit.framework in Frameworks */, ); @@ -437,7 +437,7 @@ buildActionMask = 2147483647; files = ( E3689BEB1D9EB9EB004620D6 /* NStackSDK.framework in Frameworks */, - 2909463824211DEF00BA254F /* LocalizationManager.framework in Frameworks */, + B4369B1E242A1A8800156B68 /* LocalizationManager.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -572,7 +572,6 @@ 29A72DD023FAC8A000CE8483 /* Recovered References */ = { isa = PBXGroup; children = ( - 7579C77123C346CE00A05022 /* APIFeedbackManager.swift */, 29D7EB5223FAB71900C622EA /* TranslationManager.framework */, ); name = "Recovered References"; @@ -611,8 +610,8 @@ children = ( 29A72DEF23FFEC9600CE8483 /* LocalizationManager.framework */, 29A72DF223FFECD700CE8483 /* LocalizationManager.framework */, - 29A72DF623FFECE500CE8483 /* LocalizationManager.framework */, 29A72DFA23FFECED00CE8483 /* LocalizationManager.framework */, + B4369B1C242A1A8800156B68 /* LocalizationManager.framework */, 83100E952333B13C00F84217 /* watchOS */, 83100E942333B13600F84217 /* macOS */, 83100E932333B13100F84217 /* tvOS */, @@ -625,6 +624,7 @@ 30A3D83D1B9DB94100C2D15C = { isa = PBXGroup; children = ( + B4369B1B242A19DF00156B68 /* NStackSDK.podspec */, 30A3D8491B9DB94100C2D15C /* NStackSDK */, 30A3D8551B9DB94100C2D15C /* NStackSDK Tests */, 304C42851BA074CB00AE3D6F /* Frameworks */, @@ -1563,7 +1563,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1619,7 +1619,7 @@ LD_RUNPATH_SEARCH_PATHS = ""; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -1659,7 +1659,6 @@ STRIP_INSTALLED_PRODUCT = NO; SUPPORTS_MACCATALYST = NO; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -1694,7 +1693,6 @@ SUPPORTS_MACCATALYST = NO; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; }; name = Release; }; @@ -1787,7 +1785,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.2; }; @@ -1824,7 +1821,6 @@ SKIP_INSTALL = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; - SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 10.2; }; diff --git a/NStackSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/NStackSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/NStackSDK.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/NStackSDK/APIFeedbackManager.swift b/NStackSDK/APIFeedbackManager.swift deleted file mode 100644 index d324dfc..0000000 --- a/NStackSDK/APIFeedbackManager.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// FeedbackManager.swift -// NStackSDK -// -// Created by Jigna Patel on 06.01.20. -// Copyright © 2020 Nodes ApS. All rights reserved. -// - -import Foundation - -public protocol FeedbackManager { - func postFeedback(_ message: String, completion: @escaping Completion) -} - -internal class APIFeedbackManager: FeedbackManager { - - // MARK: - Properites - internal var repository: FeedbackRepository - // MARK: - Init - init(repository: FeedbackRepository) { - self.repository = repository - } - - public func postFeedback(_ message: String, completion: @escaping Completion) { - repository.postFeedback(message) { (result) in - completion(result) - } - } -} diff --git a/NStackSDK/Classes/Managers/GeographyManager.swift b/NStackSDK/Classes/Managers/GeographyManager.swift index 4bc0101..3931415 100644 --- a/NStackSDK/Classes/Managers/GeographyManager.swift +++ b/NStackSDK/Classes/Managers/GeographyManager.swift @@ -10,7 +10,12 @@ import Foundation #if os(iOS) import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif public class GeographyManager { diff --git a/NStackSDK/Classes/Model/AppOpenData.swift b/NStackSDK/Classes/Model/AppOpenData.swift index 4124f34..812311e 100644 --- a/NStackSDK/Classes/Model/AppOpenData.swift +++ b/NStackSDK/Classes/Model/AppOpenData.swift @@ -12,7 +12,13 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif + struct AppOpenData: Codable { let count: Int? diff --git a/NStackSDK/Classes/Model/Configuration.swift b/NStackSDK/Classes/Model/Configuration.swift index 83c2713..8962bc9 100644 --- a/NStackSDK/Classes/Model/Configuration.swift +++ b/NStackSDK/Classes/Model/Configuration.swift @@ -12,7 +12,12 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif public struct UpdateOptions: OptionSet { public let rawValue: Int diff --git a/NStackSDK/Classes/Model/LocalizationItemProposal.swift b/NStackSDK/Classes/Model/LocalizationItemProposal.swift index d7431d2..68f3aac 100644 --- a/NStackSDK/Classes/Model/LocalizationItemProposal.swift +++ b/NStackSDK/Classes/Model/LocalizationItemProposal.swift @@ -12,7 +12,13 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif + struct LocalizationItemProposal { let value: String diff --git a/NStackSDK/Classes/Model/LocalizationsResponse.swift b/NStackSDK/Classes/Model/LocalizationsResponse.swift index dd7195f..018fb95 100644 --- a/NStackSDK/Classes/Model/LocalizationsResponse.swift +++ b/NStackSDK/Classes/Model/LocalizationsResponse.swift @@ -12,7 +12,12 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif public struct LocalizationsResponse: Codable { let localization: [String: Any] diff --git a/NStackSDK/Classes/NStack Manager/ConnectionManager.swift b/NStackSDK/Classes/NStack Manager/ConnectionManager.swift index af41b20..5cc2839 100644 --- a/NStackSDK/Classes/NStack Manager/ConnectionManager.swift +++ b/NStackSDK/Classes/NStack Manager/ConnectionManager.swift @@ -12,7 +12,12 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif struct DataModel: WrapperModelType { let model: T diff --git a/NStackSDK/Classes/NStack Manager/LocalizationWrapper.swift b/NStackSDK/Classes/NStack Manager/LocalizationWrapper.swift index 7822497..d380623 100644 --- a/NStackSDK/Classes/NStack Manager/LocalizationWrapper.swift +++ b/NStackSDK/Classes/NStack Manager/LocalizationWrapper.swift @@ -14,7 +14,12 @@ import WatchKit #elseif os(macOS) import AppKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif #if os(iOS) || os(tvOS) public typealias NStackLocalizableView = UIView @@ -135,7 +140,7 @@ extension LocalizationWrapper: LocalizationWrappable { /** Fetches a localized string value for the `identifier` and adds that to the `component` - + If a proposed value exists, use that, otherwise fetch a value from the `localizationManager`. */ public func localize(component: NStackLocalizable, for identifier: LocalizationItemIdentifier) { @@ -187,10 +192,10 @@ extension LocalizationWrapper: LocalizationWrappable { /** stores proposed text value locally. - + *Note:* this method does not call the NStack API for saving of the proposal - we do that first and then come back here to store the proposal locally - + - Parameter value: proposed value - Parameter key: NStack key/identifier */ diff --git a/NStackSDK/Classes/NStack Manager/NStack.swift b/NStackSDK/Classes/NStack Manager/NStack.swift index f20385a..2e023b7 100644 --- a/NStackSDK/Classes/NStack Manager/NStack.swift +++ b/NStackSDK/Classes/NStack Manager/NStack.swift @@ -12,7 +12,13 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif + public class NStack { @@ -106,7 +112,7 @@ public class NStack { localizationUrlOverride: configuration.localizationUrlOverride, nmeta: NMeta(environment: configuration.currentEnvironmentAPIString) ) - repository = configuration.useMock ? MockConnectionManager() : ConnectionManager(configuration: apiConfiguration) + repository = ConnectionManager(configuration: apiConfiguration) // Observe if necessary if configuration.updateOptions.contains(.onDidBecomeActive) { @@ -174,7 +180,7 @@ public class NStack { /// *Note:* By default, this is automatically invoked after *NStack.start()* has been called and subsequently on applicationDidBecomeActive. /// To override this behavior, see the properties on the *configuration* struct. /// - /// - Parameter completion: This is run after the call has finished. + /// - Parameter completion: This is run after the call has finished. /// If *error* was nil, localization strings are up-to-date. // swiftlint:disable:next cyclomatic_complexity public func update(_ completion: ((_ error: NStackError.Manager?) -> Void)? = nil) { diff --git a/NStackSDK/Classes/Repository/Repository.swift b/NStackSDK/Classes/Repository/Repository.swift index f592606..8cfa0fe 100644 --- a/NStackSDK/Classes/Repository/Repository.swift +++ b/NStackSDK/Classes/Repository/Repository.swift @@ -14,7 +14,12 @@ import WatchKit #elseif os(macOS) import AppKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif public typealias Result = Swift.Result diff --git a/NStackSDK/Classes/Translations/Translatable.swift b/NStackSDK/Classes/Translations/Translatable.swift index 8f00f51..0f291b5 100644 --- a/NStackSDK/Classes/Translations/Translatable.swift +++ b/NStackSDK/Classes/Translations/Translatable.swift @@ -7,10 +7,17 @@ // import Foundation -import TranslationManager +#if canImport(LocalizationManager) +import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif -public struct Localizable: LocalizableModel { - public subscript(key: String) -> LocalizableSection? { +//import TranslationManager + +public class Localizable: LocalizableModel { + public override subscript(key: String) -> LocalizableSection? { // switch key { // case CodingKeys.oneMoreSection.stringValue: return oneMoreSection // case CodingKeys.otherSection.stringValue: return otherSection @@ -25,15 +32,15 @@ public struct Localizable: LocalizableModel { public var oneMoreSection = OneMoreSection() public var otherSection = OtherSection() public var defaultSection = DefaultSection() - + enum CodingKeys: String, CodingKey { case oneMoreSection case otherSection case defaultSection = "default" } - + public init() { } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) oneMoreSection = try container.decodeIfPresent(OneMoreSection.self, forKey: .oneMoreSection) ?? oneMoreSection @@ -48,21 +55,21 @@ public struct Localizable: LocalizableModel { default: return nil } } - + public final class OneMoreSection: LocalizableSection { public var test2 = "" public var soManyKeys = "" public var test1 = "" - + public init() { } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) test2 = try container.decodeIfPresent(String.self, forKey: .test2) ?? "__test2" soManyKeys = try container.decodeIfPresent(String.self, forKey: .soManyKeys) ?? "__soManyKeys" test1 = try container.decodeIfPresent(String.self, forKey: .test1) ?? "__test1" } - + public subscript(key: String) -> String? { switch key { case CodingKeys.test2.stringValue: return test2 @@ -72,17 +79,17 @@ public struct Localizable: LocalizableModel { } } } - + public final class OtherSection: LocalizableSection { public var otherString = "" - + public init() { } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) otherString = try container.decodeIfPresent(String.self, forKey: .otherString) ?? "__otherString" } - + public subscript(key: String) -> String? { switch key { case CodingKeys.otherString.stringValue: return otherString @@ -90,19 +97,19 @@ public struct Localizable: LocalizableModel { } } } - + public final class DefaultSection: LocalizableSection { public var keyys = "" public var successKey = "" - + public init() { } - + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) keyys = try container.decodeIfPresent(String.self, forKey: .keyys) ?? "__keyys" successKey = try container.decodeIfPresent(String.self, forKey: .successKey) ?? "__successKey" } - + public subscript(key: String) -> String? { switch key { case CodingKeys.keyys.stringValue: return keyys diff --git a/NStackSDK/LocalizationConfig.swift b/NStackSDK/LocalizationConfig.swift index 68775f1..73635a5 100644 --- a/NStackSDK/LocalizationConfig.swift +++ b/NStackSDK/LocalizationConfig.swift @@ -12,7 +12,12 @@ import AppKit #else import UIKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif public struct LocalizationConfig: LocalizationDescriptor { diff --git a/NStackSDKTests/AppOpenMockRepository.swift b/NStackSDKTests/AppOpenMockRepository.swift index 551958a..51ab0c5 100644 --- a/NStackSDKTests/AppOpenMockRepository.swift +++ b/NStackSDKTests/AppOpenMockRepository.swift @@ -14,7 +14,12 @@ import WatchKit #elseif os(macOS) import AppKit #endif +#if canImport(LocalizationManager) import LocalizationManager +#endif +#if canImport(NLocalizationManager) +import NLocalizationManager +#endif class MockConnectionManager: Repository {