├── .gitignore ├── CTNetworkingSwift.podspec ├── CTNetworkingSwift.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CTNetworkingSwift ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CTNetworkingSwift │ ├── CTNetworking.swift │ ├── Components │ │ └── BaseAPIManager │ │ │ ├── CTNetworkingAPIManager.swift │ │ │ ├── Callback.CTNetworkingAPIManager.extension.swift │ │ │ ├── InnerInterceptor.CTNetworkingAPIManager.extension.swift │ │ │ ├── Protocols │ │ │ ├── CTNetworkingAPIManagerCallbackDelegate.swift │ │ │ ├── CTNetworkingAPIManagerChild.swift │ │ │ ├── CTNetworkingAPIManagerInterceptor.swift │ │ │ ├── CTNetworkingAPIManagerPagable.swift │ │ │ ├── CTNetworkingAPIManagerParamSource.swift │ │ │ └── CTNetworkingAPIManagerValidator.swift │ │ │ ├── Reformer.CTNetworkingAPIManager.extension.swift │ │ │ └── private.CTNetworkingAPIManager.extension.swift │ ├── Extensions │ │ ├── Debug.Log.CTMediator.Extension.swift │ │ ├── Debug.Request.extension.swift │ │ ├── Debug.Response.Extension.swift │ │ └── Service.CTMediator.Extension.swift │ └── Services │ │ ├── LoginServiceProtocol.swift │ │ └── ServiceProtocol.swift ├── Demo │ ├── CTNetworkingProtocol.swift │ ├── Test │ │ ├── LogHandleTarget.swift │ │ ├── ServiceTarget.swift │ │ ├── TestAPIManager │ │ │ ├── TestAPIManager.swift │ │ │ └── test.json │ │ └── TestService │ │ │ └── TestService.swift │ └── ViewController │ │ ├── Callback.ViewController.extension.swift │ │ ├── LifeCycle.ViewController.extension.swift │ │ ├── ParamSource.ViewController.extension.swift │ │ ├── TableView.ViewController.extension.swift │ │ └── ViewController.swift └── Info.plist ├── Podfile ├── Podfile.lock └── upload.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.swp 22 | 23 | # Bundler 24 | .bundle 25 | 26 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 27 | # Carthage/Checkouts 28 | 29 | Carthage/Build 30 | 31 | # We recommend against adding the Pods directory to your .gitignore. However 32 | # you should judge for yourself, the pros and cons are mentioned at: 33 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 34 | # 35 | # Note: if you ignore the Pods directory, make sure to uncomment 36 | # `pod install` in .travis.yml 37 | # 38 | Pods/ 39 | CTNetworkingSwift.xcworkspace/ 40 | CTNetworkingSwift.xcodeproj/xcuserdata/ 41 | -------------------------------------------------------------------------------- /CTNetworkingSwift.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint BLAPIManagers.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "CTNetworkingSwift" 19 | s.version = "56" 20 | s.summary = "CTNetworkingSwift." 21 | s.swift_version= "5.1" 22 | 23 | # This description is used to generate tags and improve search results. 24 | # * Think: What does it do? Why did you write it? What is the focus? 25 | # * Try to keep it short, snappy and to the point. 26 | # * Write the description between the DESC delimiters below. 27 | # * Finally, don't worry about the indent, CocoaPods strips it! 28 | s.description = <<-DESC 29 | this is CTNetworkingSwift 30 | DESC 31 | 32 | s.homepage = "https://github.com/casatwy/CTNetworkingSwift" 33 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 34 | 35 | 36 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 37 | # 38 | # Licensing your code is important. See http://choosealicense.com for more info. 39 | # CocoaPods will detect a license file if there is a named LICENSE* 40 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 41 | # 42 | 43 | s.license = "MIT" 44 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" } 45 | 46 | 47 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 48 | # 49 | # Specify the authors of the library, with email addresses. Email addresses 50 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 51 | # accepts just a name if you'd rather not provide an email address. 52 | # 53 | # Specify a social_media_url where others can refer to, for example a twitter 54 | # profile URL. 55 | # 56 | 57 | s.author = { "CasaTaloyum" => "casatwy@msn.com" } 58 | # Or just: s.author = "CasaTaloyum" 59 | # s.authors = { "CasaTaloyum" => "casatwy@msn.com" } 60 | # s.social_media_url = "http://twitter.com/CasaTaloyum" 61 | 62 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 63 | # 64 | # If this Pod runs only on iOS or OS X, then specify the platform and 65 | # the deployment target. You can optionally include the target after the platform. 66 | # 67 | 68 | # s.platform = :ios 69 | # s.platform = :ios, "10.0" 70 | 71 | # When using multiple platforms 72 | s.ios.deployment_target = "10.0" 73 | s.osx.deployment_target = "10.12" 74 | # s.watchos.deployment_target = "2.0" 75 | # s.tvos.deployment_target = "9.0" 76 | 77 | 78 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 79 | # 80 | # Specify the location from where the source should be retrieved. 81 | # Supports git, hg, bzr, svn and HTTP. 82 | # 83 | 84 | s.source = { :git => "https://github.com/casatwy/CTNetworkingSwift.git", :tag => s.version.to_s } 85 | 86 | 87 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 88 | # 89 | # CocoaPods is smart about how it includes source code. For source files 90 | # giving a folder will include any swift, h, m, mm, c & cpp files. 91 | # For header files it will include any header in the folder. 92 | # Not including the public_header_files will make all headers public. 93 | # 94 | 95 | s.source_files = "CTNetworkingSwift/CTNetworkingSwift/**/*.{swift}" 96 | # s.exclude_files = "Classes/Exclude" 97 | 98 | # s.public_header_files = "Classes/**/*.h" 99 | 100 | 101 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 102 | # 103 | # A list of resources included with the Pod. These are copied into the 104 | # target bundle with a build phase script. Anything else will be cleaned. 105 | # You can preserve files from being cleaned, please don't preserve 106 | # non-essential files like tests, examples and documentation. 107 | # 108 | 109 | # s.ios.resource = "CTNetworkingSwift/CTNetworkingSwift/CTNetworkingSwift.js" 110 | # s.ios.resources = "Resources/*.png" 111 | 112 | # s.ios.preserve_paths = "FilesToSave", "MoreFilesToSave" 113 | 114 | 115 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 116 | # 117 | # Link your library with frameworks, or libraries. Libraries do not include 118 | # the lib prefix of their name. 119 | # 120 | 121 | # s.framework = "SomeFramework" 122 | # s.frameworks = "SomeFramework", "AnotherFramework" 123 | 124 | # s.library = "iconv" 125 | # s.libraries = "iconv", "xml2" 126 | 127 | 128 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 129 | # 130 | # If your library depends on compiler flags you can set them in the xcconfig hash 131 | # where they will only apply to your library. If you depend on other Podspecs 132 | # you can include multiple dependencies to ensure it works. 133 | 134 | s.requires_arc = true 135 | 136 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 137 | s.dependency "CTMediator" 138 | s.dependency "Alamofire" 139 | s.dependency "SwiftyJSON" 140 | 141 | end 142 | -------------------------------------------------------------------------------- /CTNetworkingSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4A02B6602408E40D00A761DF /* Service.CTMediator.Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A02B65F2408E40D00A761DF /* Service.CTMediator.Extension.swift */; }; 11 | 4A02B6622408E4D700A761DF /* ServiceTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A02B6612408E4D700A761DF /* ServiceTarget.swift */; }; 12 | 4A22E83F215F6FAC00109F7A /* CTNetworkingAPIManagerPagable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A22E83E215F6FAC00109F7A /* CTNetworkingAPIManagerPagable.swift */; }; 13 | 4A460E7D215DEC2A00C98571 /* Debug.Request.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A460E7C215DEC2A00C98571 /* Debug.Request.extension.swift */; }; 14 | 4A460E7F215DEC3700C98571 /* Debug.Response.Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A460E7E215DEC3700C98571 /* Debug.Response.Extension.swift */; }; 15 | 4A8736632422589700E8B1CA /* private.CTNetworkingAPIManager.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8736622422589700E8B1CA /* private.CTNetworkingAPIManager.extension.swift */; }; 16 | 4A8A12A0215FD4AD004A35BE /* InnerInterceptor.CTNetworkingAPIManager.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A8A129F215FD4AD004A35BE /* InnerInterceptor.CTNetworkingAPIManager.extension.swift */; }; 17 | 4A9374AC215BDD4D00B88CB8 /* TestService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A93748D215BDD4D00B88CB8 /* TestService.swift */; }; 18 | 4A9374AD215BDD4D00B88CB8 /* TestAPIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A93748F215BDD4D00B88CB8 /* TestAPIManager.swift */; }; 19 | 4A9374AE215BDD4D00B88CB8 /* CTNetworkingProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937490215BDD4D00B88CB8 /* CTNetworkingProtocol.swift */; }; 20 | 4A9374AF215BDD4D00B88CB8 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937492215BDD4D00B88CB8 /* ViewController.swift */; }; 21 | 4A9374B0215BDD4D00B88CB8 /* TableView.ViewController.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937493215BDD4D00B88CB8 /* TableView.ViewController.extension.swift */; }; 22 | 4A9374B1215BDD4D00B88CB8 /* ParamSource.ViewController.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937494215BDD4D00B88CB8 /* ParamSource.ViewController.extension.swift */; }; 23 | 4A9374B2215BDD4D00B88CB8 /* Callback.ViewController.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937495215BDD4D00B88CB8 /* Callback.ViewController.extension.swift */; }; 24 | 4A9374B3215BDD4D00B88CB8 /* LifeCycle.ViewController.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937496215BDD4D00B88CB8 /* LifeCycle.ViewController.extension.swift */; }; 25 | 4A9374B4215BDD4D00B88CB8 /* CTNetworking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A937498215BDD4D00B88CB8 /* CTNetworking.swift */; }; 26 | 4A9374B6215BDD4D00B88CB8 /* Reformer.CTNetworkingAPIManager.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A93749C215BDD4D00B88CB8 /* Reformer.CTNetworkingAPIManager.extension.swift */; }; 27 | 4A9374B7215BDD4D00B88CB8 /* CTNetworkingAPIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A93749D215BDD4D00B88CB8 /* CTNetworkingAPIManager.swift */; }; 28 | 4A9374B8215BDD4D00B88CB8 /* CTNetworkingAPIManagerParamSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A93749F215BDD4D00B88CB8 /* CTNetworkingAPIManagerParamSource.swift */; }; 29 | 4A9374B9215BDD4D00B88CB8 /* CTNetworkingAPIManagerInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A0215BDD4D00B88CB8 /* CTNetworkingAPIManagerInterceptor.swift */; }; 30 | 4A9374BA215BDD4D00B88CB8 /* CTNetworkingAPIManagerValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A1215BDD4D00B88CB8 /* CTNetworkingAPIManagerValidator.swift */; }; 31 | 4A9374BB215BDD4D00B88CB8 /* CTNetworkingAPIManagerCallbackDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A2215BDD4D00B88CB8 /* CTNetworkingAPIManagerCallbackDelegate.swift */; }; 32 | 4A9374BC215BDD4D00B88CB8 /* CTNetworkingAPIManagerChild.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A3215BDD4D00B88CB8 /* CTNetworkingAPIManagerChild.swift */; }; 33 | 4A9374BD215BDD4D00B88CB8 /* Callback.CTNetworkingAPIManager.extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A4215BDD4D00B88CB8 /* Callback.CTNetworkingAPIManager.extension.swift */; }; 34 | 4A9374BE215BDD4D00B88CB8 /* ServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A9374A6215BDD4D00B88CB8 /* ServiceProtocol.swift */; }; 35 | 4A95111624B6F4D700361287 /* test.json in Resources */ = {isa = PBXBuildFile; fileRef = 4A95111524B6F4D700361287 /* test.json */; }; 36 | 4AAF5822215BDB5C009E312E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AAF5821215BDB5C009E312E /* AppDelegate.swift */; }; 37 | 4AAF5827215BDB5C009E312E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AAF5825215BDB5C009E312E /* Main.storyboard */; }; 38 | 4AAF5829215BDB5D009E312E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4AAF5828215BDB5D009E312E /* Assets.xcassets */; }; 39 | 4AAF582C215BDB5D009E312E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4AAF582A215BDB5D009E312E /* LaunchScreen.storyboard */; }; 40 | 4AFCFC522421CBF300334313 /* LoginServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AFCFC512421CBF300334313 /* LoginServiceProtocol.swift */; }; 41 | 747ADE5F25669BC900361D6D /* Debug.Log.CTMediator.Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747ADE5E25669BC900361D6D /* Debug.Log.CTMediator.Extension.swift */; }; 42 | 747ADE622566A03200361D6D /* LogHandleTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747ADE612566A03200361D6D /* LogHandleTarget.swift */; }; 43 | B11A445306298D39E166C910 /* Pods_CTNetworkingSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B21A842E0906B61311AD2E9 /* Pods_CTNetworkingSwift.framework */; }; 44 | /* End PBXBuildFile section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 0B21A842E0906B61311AD2E9 /* Pods_CTNetworkingSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CTNetworkingSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | 4A02B65F2408E40D00A761DF /* Service.CTMediator.Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Service.CTMediator.Extension.swift; sourceTree = ""; }; 49 | 4A02B6612408E4D700A761DF /* ServiceTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceTarget.swift; sourceTree = ""; }; 50 | 4A22E83E215F6FAC00109F7A /* CTNetworkingAPIManagerPagable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerPagable.swift; sourceTree = ""; }; 51 | 4A460E7C215DEC2A00C98571 /* Debug.Request.extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debug.Request.extension.swift; sourceTree = ""; }; 52 | 4A460E7E215DEC3700C98571 /* Debug.Response.Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debug.Response.Extension.swift; sourceTree = ""; }; 53 | 4A8736622422589700E8B1CA /* private.CTNetworkingAPIManager.extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = private.CTNetworkingAPIManager.extension.swift; sourceTree = ""; }; 54 | 4A8A129F215FD4AD004A35BE /* InnerInterceptor.CTNetworkingAPIManager.extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InnerInterceptor.CTNetworkingAPIManager.extension.swift; sourceTree = ""; }; 55 | 4A93748D215BDD4D00B88CB8 /* TestService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestService.swift; sourceTree = ""; }; 56 | 4A93748F215BDD4D00B88CB8 /* TestAPIManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestAPIManager.swift; sourceTree = ""; }; 57 | 4A937490215BDD4D00B88CB8 /* CTNetworkingProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingProtocol.swift; sourceTree = ""; }; 58 | 4A937492215BDD4D00B88CB8 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 59 | 4A937493215BDD4D00B88CB8 /* TableView.ViewController.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableView.ViewController.extension.swift; sourceTree = ""; }; 60 | 4A937494215BDD4D00B88CB8 /* ParamSource.ViewController.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParamSource.ViewController.extension.swift; sourceTree = ""; }; 61 | 4A937495215BDD4D00B88CB8 /* Callback.ViewController.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Callback.ViewController.extension.swift; sourceTree = ""; }; 62 | 4A937496215BDD4D00B88CB8 /* LifeCycle.ViewController.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LifeCycle.ViewController.extension.swift; sourceTree = ""; }; 63 | 4A937498215BDD4D00B88CB8 /* CTNetworking.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworking.swift; sourceTree = ""; }; 64 | 4A93749C215BDD4D00B88CB8 /* Reformer.CTNetworkingAPIManager.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reformer.CTNetworkingAPIManager.extension.swift; sourceTree = ""; }; 65 | 4A93749D215BDD4D00B88CB8 /* CTNetworkingAPIManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManager.swift; sourceTree = ""; }; 66 | 4A93749F215BDD4D00B88CB8 /* CTNetworkingAPIManagerParamSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerParamSource.swift; sourceTree = ""; }; 67 | 4A9374A0215BDD4D00B88CB8 /* CTNetworkingAPIManagerInterceptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerInterceptor.swift; sourceTree = ""; }; 68 | 4A9374A1215BDD4D00B88CB8 /* CTNetworkingAPIManagerValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerValidator.swift; sourceTree = ""; }; 69 | 4A9374A2215BDD4D00B88CB8 /* CTNetworkingAPIManagerCallbackDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerCallbackDelegate.swift; sourceTree = ""; }; 70 | 4A9374A3215BDD4D00B88CB8 /* CTNetworkingAPIManagerChild.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CTNetworkingAPIManagerChild.swift; sourceTree = ""; }; 71 | 4A9374A4215BDD4D00B88CB8 /* Callback.CTNetworkingAPIManager.extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Callback.CTNetworkingAPIManager.extension.swift; sourceTree = ""; }; 72 | 4A9374A6215BDD4D00B88CB8 /* ServiceProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceProtocol.swift; sourceTree = ""; }; 73 | 4A95111524B6F4D700361287 /* test.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = test.json; sourceTree = ""; }; 74 | 4AAF581E215BDB5C009E312E /* CTNetworkingSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CTNetworkingSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 75 | 4AAF5821215BDB5C009E312E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 76 | 4AAF5826215BDB5C009E312E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 77 | 4AAF5828215BDB5D009E312E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 78 | 4AAF582B215BDB5D009E312E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 79 | 4AAF582D215BDB5D009E312E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 80 | 4AFCFC512421CBF300334313 /* LoginServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginServiceProtocol.swift; sourceTree = ""; }; 81 | 747ADE5E25669BC900361D6D /* Debug.Log.CTMediator.Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Debug.Log.CTMediator.Extension.swift; sourceTree = ""; }; 82 | 747ADE612566A03200361D6D /* LogHandleTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogHandleTarget.swift; sourceTree = ""; }; 83 | D6E59D57E0CC0C8DF4D88D77 /* Pods-CTNetworkingSwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CTNetworkingSwift.release.xcconfig"; path = "Target Support Files/Pods-CTNetworkingSwift/Pods-CTNetworkingSwift.release.xcconfig"; sourceTree = ""; }; 84 | F0CD37C17C880E7F3657CEEA /* Pods-CTNetworkingSwift.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CTNetworkingSwift.debug.xcconfig"; path = "Target Support Files/Pods-CTNetworkingSwift/Pods-CTNetworkingSwift.debug.xcconfig"; sourceTree = ""; }; 85 | /* End PBXFileReference section */ 86 | 87 | /* Begin PBXFrameworksBuildPhase section */ 88 | 4AAF581B215BDB5C009E312E /* Frameworks */ = { 89 | isa = PBXFrameworksBuildPhase; 90 | buildActionMask = 2147483647; 91 | files = ( 92 | B11A445306298D39E166C910 /* Pods_CTNetworkingSwift.framework in Frameworks */, 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | 3D6DEC79E84DD38F293F229C /* Pods */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | F0CD37C17C880E7F3657CEEA /* Pods-CTNetworkingSwift.debug.xcconfig */, 103 | D6E59D57E0CC0C8DF4D88D77 /* Pods-CTNetworkingSwift.release.xcconfig */, 104 | ); 105 | path = Pods; 106 | sourceTree = ""; 107 | }; 108 | 4A460E7B215DEBEA00C98571 /* Extensions */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 4A460E7C215DEC2A00C98571 /* Debug.Request.extension.swift */, 112 | 4A460E7E215DEC3700C98571 /* Debug.Response.Extension.swift */, 113 | 4A02B65F2408E40D00A761DF /* Service.CTMediator.Extension.swift */, 114 | 747ADE5E25669BC900361D6D /* Debug.Log.CTMediator.Extension.swift */, 115 | ); 116 | path = Extensions; 117 | sourceTree = ""; 118 | }; 119 | 4A937484215BDD4D00B88CB8 /* Demo */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 4A937489215BDD4D00B88CB8 /* Test */, 123 | 4A937490215BDD4D00B88CB8 /* CTNetworkingProtocol.swift */, 124 | 4A937491215BDD4D00B88CB8 /* ViewController */, 125 | ); 126 | path = Demo; 127 | sourceTree = ""; 128 | }; 129 | 4A937489215BDD4D00B88CB8 /* Test */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 4A02B6612408E4D700A761DF /* ServiceTarget.swift */, 133 | 747ADE612566A03200361D6D /* LogHandleTarget.swift */, 134 | 4A93748C215BDD4D00B88CB8 /* TestService */, 135 | 4A93748E215BDD4D00B88CB8 /* TestAPIManager */, 136 | ); 137 | path = Test; 138 | sourceTree = ""; 139 | }; 140 | 4A93748C215BDD4D00B88CB8 /* TestService */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 4A93748D215BDD4D00B88CB8 /* TestService.swift */, 144 | ); 145 | path = TestService; 146 | sourceTree = ""; 147 | }; 148 | 4A93748E215BDD4D00B88CB8 /* TestAPIManager */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 4A95111524B6F4D700361287 /* test.json */, 152 | 4A93748F215BDD4D00B88CB8 /* TestAPIManager.swift */, 153 | ); 154 | path = TestAPIManager; 155 | sourceTree = ""; 156 | }; 157 | 4A937491215BDD4D00B88CB8 /* ViewController */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 4A937492215BDD4D00B88CB8 /* ViewController.swift */, 161 | 4A937493215BDD4D00B88CB8 /* TableView.ViewController.extension.swift */, 162 | 4A937494215BDD4D00B88CB8 /* ParamSource.ViewController.extension.swift */, 163 | 4A937495215BDD4D00B88CB8 /* Callback.ViewController.extension.swift */, 164 | 4A937496215BDD4D00B88CB8 /* LifeCycle.ViewController.extension.swift */, 165 | ); 166 | path = ViewController; 167 | sourceTree = ""; 168 | }; 169 | 4A937497215BDD4D00B88CB8 /* CTNetworkingSwift */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 4A937498215BDD4D00B88CB8 /* CTNetworking.swift */, 173 | 4A460E7B215DEBEA00C98571 /* Extensions */, 174 | 4A937499215BDD4D00B88CB8 /* Components */, 175 | 4A9374A5215BDD4D00B88CB8 /* Services */, 176 | ); 177 | path = CTNetworkingSwift; 178 | sourceTree = ""; 179 | }; 180 | 4A937499215BDD4D00B88CB8 /* Components */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 4A93749A215BDD4D00B88CB8 /* BaseAPIManager */, 184 | ); 185 | path = Components; 186 | sourceTree = ""; 187 | }; 188 | 4A93749A215BDD4D00B88CB8 /* BaseAPIManager */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 4A93749D215BDD4D00B88CB8 /* CTNetworkingAPIManager.swift */, 192 | 4A8736622422589700E8B1CA /* private.CTNetworkingAPIManager.extension.swift */, 193 | 4A93749C215BDD4D00B88CB8 /* Reformer.CTNetworkingAPIManager.extension.swift */, 194 | 4A9374A4215BDD4D00B88CB8 /* Callback.CTNetworkingAPIManager.extension.swift */, 195 | 4A8A129F215FD4AD004A35BE /* InnerInterceptor.CTNetworkingAPIManager.extension.swift */, 196 | 4A93749E215BDD4D00B88CB8 /* Protocols */, 197 | ); 198 | path = BaseAPIManager; 199 | sourceTree = ""; 200 | }; 201 | 4A93749E215BDD4D00B88CB8 /* Protocols */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | 4A93749F215BDD4D00B88CB8 /* CTNetworkingAPIManagerParamSource.swift */, 205 | 4A9374A0215BDD4D00B88CB8 /* CTNetworkingAPIManagerInterceptor.swift */, 206 | 4A9374A1215BDD4D00B88CB8 /* CTNetworkingAPIManagerValidator.swift */, 207 | 4A9374A2215BDD4D00B88CB8 /* CTNetworkingAPIManagerCallbackDelegate.swift */, 208 | 4A9374A3215BDD4D00B88CB8 /* CTNetworkingAPIManagerChild.swift */, 209 | 4A22E83E215F6FAC00109F7A /* CTNetworkingAPIManagerPagable.swift */, 210 | ); 211 | path = Protocols; 212 | sourceTree = ""; 213 | }; 214 | 4A9374A5215BDD4D00B88CB8 /* Services */ = { 215 | isa = PBXGroup; 216 | children = ( 217 | 4A9374A6215BDD4D00B88CB8 /* ServiceProtocol.swift */, 218 | 4AFCFC512421CBF300334313 /* LoginServiceProtocol.swift */, 219 | ); 220 | path = Services; 221 | sourceTree = ""; 222 | }; 223 | 4AAF5815215BDB5C009E312E = { 224 | isa = PBXGroup; 225 | children = ( 226 | 4AAF5820215BDB5C009E312E /* CTNetworkingSwift */, 227 | 4AAF581F215BDB5C009E312E /* Products */, 228 | 3D6DEC79E84DD38F293F229C /* Pods */, 229 | DCD03A1A6A6764881FBC5779 /* Frameworks */, 230 | ); 231 | sourceTree = ""; 232 | }; 233 | 4AAF581F215BDB5C009E312E /* Products */ = { 234 | isa = PBXGroup; 235 | children = ( 236 | 4AAF581E215BDB5C009E312E /* CTNetworkingSwift.app */, 237 | ); 238 | name = Products; 239 | sourceTree = ""; 240 | }; 241 | 4AAF5820215BDB5C009E312E /* CTNetworkingSwift */ = { 242 | isa = PBXGroup; 243 | children = ( 244 | 4A937497215BDD4D00B88CB8 /* CTNetworkingSwift */, 245 | 4A937484215BDD4D00B88CB8 /* Demo */, 246 | 4AAF5821215BDB5C009E312E /* AppDelegate.swift */, 247 | 4AAF5825215BDB5C009E312E /* Main.storyboard */, 248 | 4AAF5828215BDB5D009E312E /* Assets.xcassets */, 249 | 4AAF582A215BDB5D009E312E /* LaunchScreen.storyboard */, 250 | 4AAF582D215BDB5D009E312E /* Info.plist */, 251 | ); 252 | path = CTNetworkingSwift; 253 | sourceTree = ""; 254 | }; 255 | DCD03A1A6A6764881FBC5779 /* Frameworks */ = { 256 | isa = PBXGroup; 257 | children = ( 258 | 0B21A842E0906B61311AD2E9 /* Pods_CTNetworkingSwift.framework */, 259 | ); 260 | name = Frameworks; 261 | sourceTree = ""; 262 | }; 263 | /* End PBXGroup section */ 264 | 265 | /* Begin PBXNativeTarget section */ 266 | 4AAF581D215BDB5C009E312E /* CTNetworkingSwift */ = { 267 | isa = PBXNativeTarget; 268 | buildConfigurationList = 4AAF5830215BDB5D009E312E /* Build configuration list for PBXNativeTarget "CTNetworkingSwift" */; 269 | buildPhases = ( 270 | 4FE515CD5ABF0CBABB67BCCD /* [CP] Check Pods Manifest.lock */, 271 | 4AAF581A215BDB5C009E312E /* Sources */, 272 | 4AAF581B215BDB5C009E312E /* Frameworks */, 273 | 4AAF581C215BDB5C009E312E /* Resources */, 274 | 3558CF28B05196C22E10855F /* [CP] Embed Pods Frameworks */, 275 | ); 276 | buildRules = ( 277 | ); 278 | dependencies = ( 279 | ); 280 | name = CTNetworkingSwift; 281 | productName = CTNetworkingSwift; 282 | productReference = 4AAF581E215BDB5C009E312E /* CTNetworkingSwift.app */; 283 | productType = "com.apple.product-type.application"; 284 | }; 285 | /* End PBXNativeTarget section */ 286 | 287 | /* Begin PBXProject section */ 288 | 4AAF5816215BDB5C009E312E /* Project object */ = { 289 | isa = PBXProject; 290 | attributes = { 291 | LastSwiftUpdateCheck = 1000; 292 | LastUpgradeCheck = 1000; 293 | ORGANIZATIONNAME = casa; 294 | TargetAttributes = { 295 | 4AAF581D215BDB5C009E312E = { 296 | CreatedOnToolsVersion = 10.0; 297 | LastSwiftMigration = 1130; 298 | }; 299 | }; 300 | }; 301 | buildConfigurationList = 4AAF5819215BDB5C009E312E /* Build configuration list for PBXProject "CTNetworkingSwift" */; 302 | compatibilityVersion = "Xcode 9.3"; 303 | developmentRegion = en; 304 | hasScannedForEncodings = 0; 305 | knownRegions = ( 306 | en, 307 | Base, 308 | ); 309 | mainGroup = 4AAF5815215BDB5C009E312E; 310 | productRefGroup = 4AAF581F215BDB5C009E312E /* Products */; 311 | projectDirPath = ""; 312 | projectRoot = ""; 313 | targets = ( 314 | 4AAF581D215BDB5C009E312E /* CTNetworkingSwift */, 315 | ); 316 | }; 317 | /* End PBXProject section */ 318 | 319 | /* Begin PBXResourcesBuildPhase section */ 320 | 4AAF581C215BDB5C009E312E /* Resources */ = { 321 | isa = PBXResourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | 4AAF582C215BDB5D009E312E /* LaunchScreen.storyboard in Resources */, 325 | 4A95111624B6F4D700361287 /* test.json in Resources */, 326 | 4AAF5829215BDB5D009E312E /* Assets.xcassets in Resources */, 327 | 4AAF5827215BDB5C009E312E /* Main.storyboard in Resources */, 328 | ); 329 | runOnlyForDeploymentPostprocessing = 0; 330 | }; 331 | /* End PBXResourcesBuildPhase section */ 332 | 333 | /* Begin PBXShellScriptBuildPhase section */ 334 | 3558CF28B05196C22E10855F /* [CP] Embed Pods Frameworks */ = { 335 | isa = PBXShellScriptBuildPhase; 336 | buildActionMask = 2147483647; 337 | files = ( 338 | ); 339 | inputFileListPaths = ( 340 | "${PODS_ROOT}/Target Support Files/Pods-CTNetworkingSwift/Pods-CTNetworkingSwift-frameworks-${CONFIGURATION}-input-files.xcfilelist", 341 | ); 342 | name = "[CP] Embed Pods Frameworks"; 343 | outputFileListPaths = ( 344 | "${PODS_ROOT}/Target Support Files/Pods-CTNetworkingSwift/Pods-CTNetworkingSwift-frameworks-${CONFIGURATION}-output-files.xcfilelist", 345 | ); 346 | runOnlyForDeploymentPostprocessing = 0; 347 | shellPath = /bin/sh; 348 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CTNetworkingSwift/Pods-CTNetworkingSwift-frameworks.sh\"\n"; 349 | showEnvVarsInLog = 0; 350 | }; 351 | 4FE515CD5ABF0CBABB67BCCD /* [CP] Check Pods Manifest.lock */ = { 352 | isa = PBXShellScriptBuildPhase; 353 | buildActionMask = 2147483647; 354 | files = ( 355 | ); 356 | inputFileListPaths = ( 357 | ); 358 | inputPaths = ( 359 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 360 | "${PODS_ROOT}/Manifest.lock", 361 | ); 362 | name = "[CP] Check Pods Manifest.lock"; 363 | outputFileListPaths = ( 364 | ); 365 | outputPaths = ( 366 | "$(DERIVED_FILE_DIR)/Pods-CTNetworkingSwift-checkManifestLockResult.txt", 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | shellPath = /bin/sh; 370 | 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"; 371 | showEnvVarsInLog = 0; 372 | }; 373 | /* End PBXShellScriptBuildPhase section */ 374 | 375 | /* Begin PBXSourcesBuildPhase section */ 376 | 4AAF581A215BDB5C009E312E /* Sources */ = { 377 | isa = PBXSourcesBuildPhase; 378 | buildActionMask = 2147483647; 379 | files = ( 380 | 4A9374B4215BDD4D00B88CB8 /* CTNetworking.swift in Sources */, 381 | 4A9374BE215BDD4D00B88CB8 /* ServiceProtocol.swift in Sources */, 382 | 4A02B6622408E4D700A761DF /* ServiceTarget.swift in Sources */, 383 | 747ADE5F25669BC900361D6D /* Debug.Log.CTMediator.Extension.swift in Sources */, 384 | 4A460E7F215DEC3700C98571 /* Debug.Response.Extension.swift in Sources */, 385 | 4A9374B3215BDD4D00B88CB8 /* LifeCycle.ViewController.extension.swift in Sources */, 386 | 4AAF5822215BDB5C009E312E /* AppDelegate.swift in Sources */, 387 | 4A9374AF215BDD4D00B88CB8 /* ViewController.swift in Sources */, 388 | 4A22E83F215F6FAC00109F7A /* CTNetworkingAPIManagerPagable.swift in Sources */, 389 | 4A9374B0215BDD4D00B88CB8 /* TableView.ViewController.extension.swift in Sources */, 390 | 4A9374AC215BDD4D00B88CB8 /* TestService.swift in Sources */, 391 | 4A9374AD215BDD4D00B88CB8 /* TestAPIManager.swift in Sources */, 392 | 4A9374BD215BDD4D00B88CB8 /* Callback.CTNetworkingAPIManager.extension.swift in Sources */, 393 | 4A8A12A0215FD4AD004A35BE /* InnerInterceptor.CTNetworkingAPIManager.extension.swift in Sources */, 394 | 4A02B6602408E40D00A761DF /* Service.CTMediator.Extension.swift in Sources */, 395 | 4A9374BB215BDD4D00B88CB8 /* CTNetworkingAPIManagerCallbackDelegate.swift in Sources */, 396 | 4A460E7D215DEC2A00C98571 /* Debug.Request.extension.swift in Sources */, 397 | 747ADE622566A03200361D6D /* LogHandleTarget.swift in Sources */, 398 | 4A9374B1215BDD4D00B88CB8 /* ParamSource.ViewController.extension.swift in Sources */, 399 | 4A9374B7215BDD4D00B88CB8 /* CTNetworkingAPIManager.swift in Sources */, 400 | 4AFCFC522421CBF300334313 /* LoginServiceProtocol.swift in Sources */, 401 | 4A9374BA215BDD4D00B88CB8 /* CTNetworkingAPIManagerValidator.swift in Sources */, 402 | 4A9374B9215BDD4D00B88CB8 /* CTNetworkingAPIManagerInterceptor.swift in Sources */, 403 | 4A9374AE215BDD4D00B88CB8 /* CTNetworkingProtocol.swift in Sources */, 404 | 4A9374B6215BDD4D00B88CB8 /* Reformer.CTNetworkingAPIManager.extension.swift in Sources */, 405 | 4A9374BC215BDD4D00B88CB8 /* CTNetworkingAPIManagerChild.swift in Sources */, 406 | 4A8736632422589700E8B1CA /* private.CTNetworkingAPIManager.extension.swift in Sources */, 407 | 4A9374B2215BDD4D00B88CB8 /* Callback.ViewController.extension.swift in Sources */, 408 | 4A9374B8215BDD4D00B88CB8 /* CTNetworkingAPIManagerParamSource.swift in Sources */, 409 | ); 410 | runOnlyForDeploymentPostprocessing = 0; 411 | }; 412 | /* End PBXSourcesBuildPhase section */ 413 | 414 | /* Begin PBXVariantGroup section */ 415 | 4AAF5825215BDB5C009E312E /* Main.storyboard */ = { 416 | isa = PBXVariantGroup; 417 | children = ( 418 | 4AAF5826215BDB5C009E312E /* Base */, 419 | ); 420 | name = Main.storyboard; 421 | sourceTree = ""; 422 | }; 423 | 4AAF582A215BDB5D009E312E /* LaunchScreen.storyboard */ = { 424 | isa = PBXVariantGroup; 425 | children = ( 426 | 4AAF582B215BDB5D009E312E /* Base */, 427 | ); 428 | name = LaunchScreen.storyboard; 429 | sourceTree = ""; 430 | }; 431 | /* End PBXVariantGroup section */ 432 | 433 | /* Begin XCBuildConfiguration section */ 434 | 4AAF582E215BDB5D009E312E /* Debug */ = { 435 | isa = XCBuildConfiguration; 436 | buildSettings = { 437 | ALWAYS_SEARCH_USER_PATHS = NO; 438 | CLANG_ANALYZER_NONNULL = YES; 439 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 440 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 441 | CLANG_CXX_LIBRARY = "libc++"; 442 | CLANG_ENABLE_MODULES = YES; 443 | CLANG_ENABLE_OBJC_ARC = YES; 444 | CLANG_ENABLE_OBJC_WEAK = YES; 445 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 446 | CLANG_WARN_BOOL_CONVERSION = YES; 447 | CLANG_WARN_COMMA = YES; 448 | CLANG_WARN_CONSTANT_CONVERSION = YES; 449 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 450 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 451 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 452 | CLANG_WARN_EMPTY_BODY = YES; 453 | CLANG_WARN_ENUM_CONVERSION = YES; 454 | CLANG_WARN_INFINITE_RECURSION = YES; 455 | CLANG_WARN_INT_CONVERSION = YES; 456 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 457 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 458 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 459 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 460 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 461 | CLANG_WARN_STRICT_PROTOTYPES = YES; 462 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 463 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 464 | CLANG_WARN_UNREACHABLE_CODE = YES; 465 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 466 | CODE_SIGN_IDENTITY = "iPhone Developer"; 467 | COPY_PHASE_STRIP = NO; 468 | DEBUG_INFORMATION_FORMAT = dwarf; 469 | ENABLE_STRICT_OBJC_MSGSEND = YES; 470 | ENABLE_TESTABILITY = YES; 471 | GCC_C_LANGUAGE_STANDARD = gnu11; 472 | GCC_DYNAMIC_NO_PIC = NO; 473 | GCC_NO_COMMON_BLOCKS = YES; 474 | GCC_OPTIMIZATION_LEVEL = 0; 475 | GCC_PREPROCESSOR_DEFINITIONS = ( 476 | "DEBUG=1", 477 | "$(inherited)", 478 | ); 479 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 480 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 481 | GCC_WARN_UNDECLARED_SELECTOR = YES; 482 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 483 | GCC_WARN_UNUSED_FUNCTION = YES; 484 | GCC_WARN_UNUSED_VARIABLE = YES; 485 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 486 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 487 | MTL_FAST_MATH = YES; 488 | ONLY_ACTIVE_ARCH = YES; 489 | SDKROOT = iphoneos; 490 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 491 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 492 | }; 493 | name = Debug; 494 | }; 495 | 4AAF582F215BDB5D009E312E /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | ALWAYS_SEARCH_USER_PATHS = NO; 499 | CLANG_ANALYZER_NONNULL = YES; 500 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 501 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 502 | CLANG_CXX_LIBRARY = "libc++"; 503 | CLANG_ENABLE_MODULES = YES; 504 | CLANG_ENABLE_OBJC_ARC = YES; 505 | CLANG_ENABLE_OBJC_WEAK = YES; 506 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 507 | CLANG_WARN_BOOL_CONVERSION = YES; 508 | CLANG_WARN_COMMA = YES; 509 | CLANG_WARN_CONSTANT_CONVERSION = YES; 510 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 511 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 512 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 513 | CLANG_WARN_EMPTY_BODY = YES; 514 | CLANG_WARN_ENUM_CONVERSION = YES; 515 | CLANG_WARN_INFINITE_RECURSION = YES; 516 | CLANG_WARN_INT_CONVERSION = YES; 517 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 518 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 519 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 520 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 521 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 522 | CLANG_WARN_STRICT_PROTOTYPES = YES; 523 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 524 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 525 | CLANG_WARN_UNREACHABLE_CODE = YES; 526 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 527 | CODE_SIGN_IDENTITY = "iPhone Developer"; 528 | COPY_PHASE_STRIP = NO; 529 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 530 | ENABLE_NS_ASSERTIONS = NO; 531 | ENABLE_STRICT_OBJC_MSGSEND = YES; 532 | GCC_C_LANGUAGE_STANDARD = gnu11; 533 | GCC_NO_COMMON_BLOCKS = YES; 534 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 535 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 536 | GCC_WARN_UNDECLARED_SELECTOR = YES; 537 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 538 | GCC_WARN_UNUSED_FUNCTION = YES; 539 | GCC_WARN_UNUSED_VARIABLE = YES; 540 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 541 | MTL_ENABLE_DEBUG_INFO = NO; 542 | MTL_FAST_MATH = YES; 543 | SDKROOT = iphoneos; 544 | SWIFT_COMPILATION_MODE = wholemodule; 545 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 546 | VALIDATE_PRODUCT = YES; 547 | }; 548 | name = Release; 549 | }; 550 | 4AAF5831215BDB5D009E312E /* Debug */ = { 551 | isa = XCBuildConfiguration; 552 | baseConfigurationReference = F0CD37C17C880E7F3657CEEA /* Pods-CTNetworkingSwift.debug.xcconfig */; 553 | buildSettings = { 554 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 555 | CODE_SIGN_STYLE = Automatic; 556 | DEVELOPMENT_TEAM = THS9SRQVES; 557 | INFOPLIST_FILE = CTNetworkingSwift/Info.plist; 558 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 559 | LD_RUNPATH_SEARCH_PATHS = ( 560 | "$(inherited)", 561 | "@executable_path/Frameworks", 562 | ); 563 | PRODUCT_BUNDLE_IDENTIFIER = casa.CTNetworkingSwift; 564 | PRODUCT_NAME = "$(TARGET_NAME)"; 565 | SWIFT_VERSION = 5.0; 566 | TARGETED_DEVICE_FAMILY = "1,2"; 567 | }; 568 | name = Debug; 569 | }; 570 | 4AAF5832215BDB5D009E312E /* Release */ = { 571 | isa = XCBuildConfiguration; 572 | baseConfigurationReference = D6E59D57E0CC0C8DF4D88D77 /* Pods-CTNetworkingSwift.release.xcconfig */; 573 | buildSettings = { 574 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 575 | CODE_SIGN_STYLE = Automatic; 576 | DEVELOPMENT_TEAM = THS9SRQVES; 577 | INFOPLIST_FILE = CTNetworkingSwift/Info.plist; 578 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 579 | LD_RUNPATH_SEARCH_PATHS = ( 580 | "$(inherited)", 581 | "@executable_path/Frameworks", 582 | ); 583 | PRODUCT_BUNDLE_IDENTIFIER = casa.CTNetworkingSwift; 584 | PRODUCT_NAME = "$(TARGET_NAME)"; 585 | SWIFT_VERSION = 5.0; 586 | TARGETED_DEVICE_FAMILY = "1,2"; 587 | }; 588 | name = Release; 589 | }; 590 | /* End XCBuildConfiguration section */ 591 | 592 | /* Begin XCConfigurationList section */ 593 | 4AAF5819215BDB5C009E312E /* Build configuration list for PBXProject "CTNetworkingSwift" */ = { 594 | isa = XCConfigurationList; 595 | buildConfigurations = ( 596 | 4AAF582E215BDB5D009E312E /* Debug */, 597 | 4AAF582F215BDB5D009E312E /* Release */, 598 | ); 599 | defaultConfigurationIsVisible = 0; 600 | defaultConfigurationName = Release; 601 | }; 602 | 4AAF5830215BDB5D009E312E /* Build configuration list for PBXNativeTarget "CTNetworkingSwift" */ = { 603 | isa = XCConfigurationList; 604 | buildConfigurations = ( 605 | 4AAF5831215BDB5D009E312E /* Debug */, 606 | 4AAF5832215BDB5D009E312E /* Release */, 607 | ); 608 | defaultConfigurationIsVisible = 0; 609 | defaultConfigurationName = Release; 610 | }; 611 | /* End XCConfigurationList section */ 612 | }; 613 | rootObject = 4AAF5816215BDB5C009E312E /* Project object */; 614 | } 615 | -------------------------------------------------------------------------------- /CTNetworkingSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CTNetworkingSwift.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CTNetworkingSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2018/9/26. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /CTNetworkingSwift/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CTNetworkingSwift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/CTNetworking.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Definitions.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | import Alamofire 10 | 11 | public enum CTNetworkingErrorType { 12 | 13 | case defaultStatus 14 | 15 | public enum Login { 16 | case needLogin 17 | case needRefreshAccessToken 18 | case loginCanceled 19 | } 20 | 21 | public enum Response { 22 | case noContent 23 | case missingInfomation 24 | case correct 25 | } 26 | 27 | public enum Params { 28 | case missingParams 29 | case correct 30 | } 31 | 32 | public enum Request { 33 | case noNetwork 34 | case timeout 35 | case cancel 36 | case success 37 | } 38 | 39 | } 40 | 41 | public protocol CTNetworkingResponseTransformer { 42 | func transformResponse(from apiManager:CTNetworkingAPIManager) -> Any? 43 | } 44 | 45 | public protocol CTNetworkingParamConvertible { 46 | func toParameters() -> Parameters 47 | } 48 | 49 | public extension CTNetworkingParamConvertible { 50 | func toParameters() -> Parameters { 51 | var result:Parameters = [:] 52 | let mirror = Mirror(reflecting: self) 53 | for property in mirror.children { 54 | guard let key = property.label else { continue } 55 | if case Optional.some(let value) = property.value { 56 | result[key] = value 57 | } 58 | } 59 | return result 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/CTNetworkingAPIManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingBaseAPIManager.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Alamofire 9 | import CTMediator 10 | 11 | @objc 12 | open class CTNetworkingAPIManager : NSObject { 13 | public weak var delegate : CTNetworkingAPIManagerCallbackDelegate? = nil 14 | public weak var paramSource : CTNetworkingAPIManagerParamSource? = nil 15 | public weak var validator : CTNetworkingAPIManagerValidator? = nil 16 | public weak var interceptor : CTNetworkingBaseAPIManagerInterceptor? = nil 17 | public weak var child : CTNetworkingAPIManagerChild? = nil 18 | 19 | public var request : URLRequest? = nil 20 | public var response : AFDataResponse? = nil 21 | public var mockDataFileURL : URL? = nil 22 | public var session : Session? = nil 23 | public var timeout : TimeInterval? = nil 24 | 25 | public var isLoading : Bool = false 26 | public let managerIdentifier = UUID().uuidString 27 | 28 | open func loadData() { 29 | guard let child = child else { return } 30 | 31 | if child.isAPINeedLoginInfo { 32 | guard let loginService = CTMediator.sharedInstance().fetchCTNetworkingLoginService(identifier: child.loginServiceIdentifier, moduleName: child.moduleName) else { return } 33 | if loginService.isCurrentLoggedIn() == false { 34 | loginService.doLoginProcess(success: { 35 | loginService.loginSuccessOperation(apiManager: self) 36 | }, fail: { 37 | loginService.loginFailOperation(apiManager: self) 38 | }, cancel: { 39 | loginService.loginCancelOperation(apiManager: self) 40 | }, apiManager: self) 41 | } else { 42 | apiCallingProcess(child) 43 | } 44 | } else { 45 | apiCallingProcess(child) 46 | } 47 | } 48 | 49 | public func setupCachedResponse(cachedData:Data) { 50 | let result = Result.success(cachedData) 51 | let httpResponse = HTTPURLResponse(url: request?.url ?? URL(fileURLWithPath: "cached response"), statusCode: 200, httpVersion: "1.1", headerFields: response?.response?.headers.dictionary) 52 | let response = AFDataResponse(request: request, response: httpResponse, data: cachedData, metrics: nil, serializationDuration: 10, result: result) 53 | self.response = response 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Callback.CTNetworkingAPIManager.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Callback.BaseAPIManager.extension.swift 3 | // Alamofire 4 | // 5 | // Created by casa on 2018/9/21. 6 | // 7 | 8 | import Alamofire 9 | 10 | public extension CTNetworkingAPIManager { 11 | func success() { 12 | guard beforePerformSuccess(self) else { return } 13 | delegate?.requestDidSuccess(self) 14 | afterPerformSuccess(self) 15 | } 16 | 17 | func fail() { 18 | guard beforePerformFail(self) else { return } 19 | delegate?.requestDidFailed(self) 20 | afterPerformFail(self) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/InnerInterceptor.CTNetworkingAPIManager.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InnerInterceptor.BaseAPIManager.extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2018/9/29. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Alamofire 11 | 12 | extension CTNetworkingAPIManager { 13 | func beforePerformSuccess(_ apiManager:CTNetworkingAPIManager) -> Bool { 14 | let result = interceptor?.beforePerformSuccess(self) ?? true 15 | return result 16 | } 17 | func afterPerformSuccess(_ apiManager:CTNetworkingAPIManager) { 18 | interceptor?.afterPerformSuccess(self) 19 | } 20 | 21 | func beforePerformFail(_ apiManager:CTNetworkingAPIManager) -> Bool { 22 | let result = interceptor?.beforePerformFail(self) ?? true 23 | return result 24 | } 25 | func afterPerformFail(_ apiManager:CTNetworkingAPIManager) { 26 | interceptor?.afterPerformFail(self) 27 | } 28 | 29 | func shouldCallAPI(_ apiManager:CTNetworkingAPIManager, params:Parameters?) -> Bool { 30 | let result = interceptor?.shouldCallAPI(self, params: params) ?? true 31 | return result 32 | } 33 | func afterAPICalling(_ apiManager:CTNetworkingAPIManager, params:Parameters?) { 34 | interceptor?.afterAPICalling(self, params: params) 35 | } 36 | func didReceiveResponse(_ apiManager:CTNetworkingAPIManager) { 37 | interceptor?.didReceiveResponse(self) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerCallbackDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingBaseAPIManagerCallbackDelegate.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | 10 | public protocol CTNetworkingAPIManagerCallbackDelegate : AnyObject { 11 | func requestDidSuccess(_ apiManager:CTNetworkingAPIManager) 12 | func requestDidFailed(_ apiManager:CTNetworkingAPIManager) 13 | func shouldContinueRequestAfterLogin(_ apiManager:CTNetworkingAPIManager) -> Bool 14 | } 15 | 16 | public extension CTNetworkingAPIManagerCallbackDelegate { 17 | func shouldContinueRequestAfterLogin(_ apiManager:CTNetworkingAPIManager) -> Bool { 18 | return true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerChild.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingBaseAPIManagerChild.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Alamofire 9 | 10 | public protocol CTNetworkingAPIManagerChild : CTNetworkingAPIManager { 11 | var serviceIdentifier : String { get } 12 | var loginServiceIdentifier : String { get } 13 | var logHandleIdentifier : String { get } 14 | var moduleName : String { get } 15 | var isPagable : Bool { get } 16 | var methodName : String { get } 17 | var requestType : HTTPMethod { get } 18 | var isAPINeedLoginInfo : Bool { get } 19 | var headers: HTTPHeaders? { get } 20 | func transformParams(_ params:Parameters?) -> Parameters? 21 | func extraURLParams(_ params:Parameters?) -> Parameters? 22 | } 23 | 24 | public extension CTNetworkingAPIManagerChild { 25 | var logHandleIdentifier: String { 26 | return "" 27 | } 28 | var headers: HTTPHeaders? { 29 | return nil 30 | } 31 | func transformParams(_ params:Parameters?) -> Parameters? { 32 | return params 33 | } 34 | 35 | func extraURLParams(_ params:Parameters?) -> Parameters? { 36 | return nil 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerInterceptor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingAPIManagerInterceptor.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | import Alamofire 10 | 11 | public protocol CTNetworkingBaseAPIManagerInterceptor : AnyObject { 12 | func beforePerformSuccess(_ apiManager:CTNetworkingAPIManager) -> Bool 13 | func afterPerformSuccess(_ apiManager:CTNetworkingAPIManager) 14 | 15 | func beforePerformFail(_ apiManager:CTNetworkingAPIManager) -> Bool 16 | func afterPerformFail(_ apiManager:CTNetworkingAPIManager) 17 | 18 | func shouldCallAPI(_ apiManager:CTNetworkingAPIManager, params:Parameters?) -> Bool 19 | func afterAPICalling(_ apiManager:CTNetworkingAPIManager, params:Parameters?) 20 | func didReceiveResponse(_ apiManager:CTNetworkingAPIManager) 21 | } 22 | 23 | public extension CTNetworkingBaseAPIManagerInterceptor { 24 | func beforePerformSuccess(_ apiManager:CTNetworkingAPIManager) -> Bool { 25 | return true 26 | } 27 | 28 | func afterPerformSuccess(_ apiManager:CTNetworkingAPIManager) { 29 | // do nothing 30 | } 31 | 32 | func beforePerformFail(_ apiManager:CTNetworkingAPIManager) -> Bool { 33 | return true 34 | } 35 | 36 | func afterPerformFail(_ apiManager:CTNetworkingAPIManager) { 37 | // do nothing 38 | } 39 | 40 | func shouldCallAPI(_ apiManager:CTNetworkingAPIManager, params:Parameters) -> Bool { 41 | return true 42 | } 43 | 44 | func afterAPICalling(_ apiManager:CTNetworkingAPIManager, params:Parameters) { 45 | // do nothing 46 | } 47 | 48 | func didReceiveResponse(_ apiManager:CTNetworkingAPIManager) { 49 | // do nothing 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerPagable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingAPIManagerPagable.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2018/9/29. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol CTNetworkingAPIManagerPagable : CTNetworkingAPIManager { 12 | var pageSize : Int { get } 13 | var isLastPage : Bool { get } 14 | var isFirstPage : Bool { get } 15 | var currentPageNumber : Int { get } 16 | var totalCount : Int? { get } 17 | var nextStep : Int { get } 18 | 19 | func loadNextPage() 20 | func loadPreviousPage() 21 | func loadPage(_ page:Int) 22 | func refreshCurrentPage() 23 | } 24 | 25 | public extension CTNetworkingAPIManagerPagable { 26 | var nextStep: Int { 27 | return 1 28 | } 29 | 30 | func loadNextPage() {} 31 | func loadPreviousPage() {} 32 | func loadPage(_ page:Int) {} 33 | func refreshCurrentPage() {} 34 | } 35 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerParamSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingBaseAPIManagerParamSource.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | import Alamofire 10 | 11 | public protocol CTNetworkingAPIManagerParamSource : AnyObject { 12 | func params(for apiManager:CTNetworkingAPIManager) -> Parameters? 13 | } 14 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Protocols/CTNetworkingAPIManagerValidator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingBaseAPIManagerValidator.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | import Alamofire 10 | 11 | public protocol CTNetworkingAPIManagerValidator : AnyObject { 12 | func isCorrect(manager:CTNetworkingAPIManager, params:Parameters?) -> CTNetworkingErrorType.Params 13 | func isCorrect(manager:CTNetworkingAPIManager) -> CTNetworkingErrorType.Response 14 | } 15 | 16 | extension CTNetworkingAPIManagerValidator { 17 | func isCorrect(manager:CTNetworkingAPIManager, params:Parameters?) -> CTNetworkingErrorType.Params { 18 | return .correct 19 | } 20 | 21 | func isCorrect(manager:CTNetworkingAPIManager) -> CTNetworkingErrorType.Response { 22 | return .correct 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/Reformer.CTNetworkingAPIManager.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Reformer.BaseAPIManager.extension.swift 3 | // Alamofire 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | 10 | public protocol CTNetworkingAPIManagerFetchable { 11 | func fetch(with responseTransformer:CTNetworkingResponseTransformer?) -> Any? 12 | func fetchAsData() -> Data? 13 | func fetchAsString() -> String? 14 | func fetchAsDictionary() -> [AnyHashable:Any]? 15 | } 16 | 17 | extension CTNetworkingAPIManager : CTNetworkingAPIManagerFetchable { 18 | public func fetch(with responseTransformer:CTNetworkingResponseTransformer?) -> Any? { 19 | guard let data = self.response?.data else { return nil } 20 | guard let transformer = responseTransformer else { 21 | if let result = try? JSONSerialization.jsonObject(with: data, options: []) as? [AnyHashable:Any] { 22 | return result 23 | } else if let result = String(data: data, encoding: .utf8) { 24 | return result 25 | } else { 26 | return data 27 | } 28 | } 29 | return transformer.transformResponse(from: self) 30 | } 31 | 32 | public func fetchAsData() -> Data? { 33 | return self.response?.data 34 | } 35 | 36 | public func fetchAsString() -> String? { 37 | guard let data = self.response?.data else { return nil } 38 | return String(data: data, encoding: .utf8) 39 | } 40 | 41 | public func fetchAsDictionary() -> [AnyHashable:Any]? { 42 | guard let data = self.response?.data else { return nil } 43 | let result = try? JSONSerialization.jsonObject(with: data, options: []) as? [AnyHashable:Any] 44 | return result 45 | } 46 | 47 | public func fetchAsArray() -> [Any]? { 48 | guard let data = self.response?.data else { return nil } 49 | let result = try? JSONSerialization.jsonObject(with: data, options: []) as? [Any] 50 | return result 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Components/BaseAPIManager/private.CTNetworkingAPIManager.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // private.CTNetworkingAPIManager.extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2020/3/18. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import CTMediator 10 | import Alamofire 11 | 12 | extension CTNetworkingAPIManager { 13 | func apiCallingProcess(_ child:CTNetworkingAPIManagerChild) { 14 | let params = child.transformParams(paramSource?.params(for: self)) 15 | 16 | guard validator?.isCorrect(manager: self, params: params) == CTNetworkingErrorType.Params.correct else { 17 | fail() 18 | return 19 | } 20 | 21 | guard shouldCallAPI(self, params: params) else { return } 22 | guard let service = CTMediator.sharedInstance().fetchCTNetworkingService(identifier: child.serviceIdentifier, moduleName: child.moduleName) else { return } 23 | guard var request = service.request(params: params, extraURLParams: child.extraURLParams(params), methodName: child.methodName, requestType: child.requestType, headers:child.headers) else { return } 24 | if let timeout = child.timeout { 25 | request.timeoutInterval = timeout 26 | } 27 | self.request = request 28 | 29 | #if DEBUG 30 | let requestLogMessage = request.logString(apiName: child.methodName, service: service) 31 | if !CTMediator.sharedInstance().customHandleLogMessage(identifier: child.logHandleIdentifier, moduleName: child.moduleName, message: requestLogMessage) { 32 | print(requestLogMessage) 33 | } 34 | #endif 35 | 36 | isLoading = true 37 | 38 | if let mockDataFilePathURL = self.mockDataFileURL, 39 | let mockData = try? Data(contentsOf: mockDataFilePathURL), 40 | let requestURL = request.url, 41 | let mockHttpResponse = HTTPURLResponse(url: requestURL, statusCode: 200, httpVersion: nil, headerFields: nil) 42 | { 43 | // 走mock数据 44 | DispatchQueue.main.async { 45 | let result = Result.success(mockData) 46 | let mockResponse = AFDataResponse(request: request, response: mockHttpResponse, data: mockData, metrics: nil, serializationDuration: 0, result: result) 47 | self.handleResponse(response: mockResponse, service: service) 48 | } 49 | } else { 50 | // 走正常调度 51 | let session = child.session ?? service.session 52 | session.request(request).response { (response) in 53 | #if DEBUG 54 | let responseLogMessage = response.logString() 55 | if !CTMediator.sharedInstance().customHandleLogMessage(identifier: child.logHandleIdentifier, moduleName: child.moduleName, message: responseLogMessage) { 56 | print(responseLogMessage) 57 | } 58 | #endif 59 | self.handleResponse(response: response, service: service) 60 | } 61 | } 62 | 63 | afterAPICalling(self, params: params) 64 | } 65 | 66 | func handleResponse(response:AFDataResponse, service:CTNetworkingService) { 67 | self.isLoading = false 68 | self.response = response 69 | self.interceptor?.didReceiveResponse(self) 70 | 71 | guard service.handleCommonError(self) else { return } 72 | 73 | if response.error == nil { 74 | if self.validator?.isCorrect(manager: self) != CTNetworkingErrorType.Response.correct { 75 | self.fail() 76 | } else { 77 | self.success() 78 | } 79 | } else { 80 | self.fail() 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Extensions/Debug.Log.CTMediator.Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Debug.Log.CTMediator.Extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by 景鹏博 on 2020/11/19. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import CTMediator 10 | 11 | extension CTMediator { 12 | func customHandleLogMessage(identifier: String, moduleName: String, message: String) -> Bool { 13 | let params = [ 14 | "message": message, 15 | kCTMediatorParamsKeySwiftTargetModuleName: moduleName 16 | ] 17 | guard let customHandle = performTarget(identifier, action: identifier, params: params, shouldCacheTarget: true) as? Bool else { return false } 18 | return customHandle 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Extensions/Debug.Request.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Debug.Request.extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2018/9/28. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Alamofire 11 | 12 | extension URLRequest { 13 | public func logString(apiName:String, service: CTNetworkingService) -> String { 14 | 15 | var logString = "\n\n***********************\nRequest Start\n***********************\n\n" 16 | 17 | logString += "API Name:\t\t\(apiName)\n" 18 | logString += "Method:\t\t\t\(httpMethod ?? "N/A")\n" 19 | logString += "Service:\t\t\(type(of: service))\n" 20 | logString += descriptionLogString() 21 | 22 | logString += "\n\n***********************\nRequest End\n***********************\n\n" 23 | 24 | return logString 25 | } 26 | 27 | func descriptionLogString() -> String { 28 | var result = "" 29 | 30 | result += "\n\nHTTP URL:\n\t\(url?.absoluteString ?? "N/A")" 31 | 32 | var headerString = "" 33 | if let httpHeaders = allHTTPHeaderFields { 34 | result += "\n\nHTTP Header:" 35 | 36 | httpHeaders.forEach { (key, value) in 37 | result += "\n\t\(key):\(value)" 38 | headerString += " -H \"\(key):\(value)\"" 39 | } 40 | } 41 | 42 | var bodyString = "" 43 | if let bodyData = httpBody { 44 | if let _bodyString = String(data: bodyData, encoding: .utf8) { 45 | bodyString += " -d \'\(_bodyString)\'" 46 | } 47 | result += "\n\nHTTP Body:\n\t\(bodyString)" 48 | } 49 | 50 | result += "\n\nCURL:\n\t curl -X \(httpMethod ?? "Get")\(headerString)\(bodyString) \(url?.absoluteString ?? "")" 51 | 52 | return result 53 | } 54 | 55 | func dictionaryToJsonString(dictionary:[AnyHashable:Any]) -> String { 56 | guard let data = try? JSONSerialization.data(withJSONObject: dictionary, options: .prettyPrinted) else { return "" } 57 | let result = String(data: data, encoding: .utf8) ?? "" 58 | return result 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Extensions/Debug.Response.Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Debug.Response.Extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2018/9/28. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Alamofire 11 | 12 | extension DataResponse { 13 | public func logString() -> String { 14 | 15 | guard let response = response else { return "No Response" } 16 | guard let request = request else { return "No Request" } 17 | 18 | var logString = "\n\n=========================================\nAPI Response\n=========================================\n\n" 19 | logString += "Headers:\(response.headers.dictionary)\n\n" 20 | logString += "Status:\t\(response.statusCode)\t\(HTTPURLResponse.localizedString(forStatusCode: response.statusCode))\n\n" 21 | 22 | if let data = data { 23 | logString += "Content:\n\t\(String(data: data, encoding: .utf8) ?? "Can not parse response data")\n\n" 24 | } else { 25 | logString += "Content:\n\tNo Data Available\n\n" 26 | } 27 | 28 | if let error = error { 29 | logString += error.localizedDescription 30 | } 31 | 32 | logString += "\n--------------- Related Request Content --------------\n" 33 | logString += request.descriptionLogString() 34 | logString += "\n\n=========================================\nResponse End\n=========================================\n\n" 35 | return logString 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Extensions/Service.CTMediator.Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Service.CTMediator.Extension.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2020/2/28. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import CTMediator 10 | 11 | extension CTMediator { 12 | func fetchCTNetworkingService(identifier:String, moduleName:String) -> CTNetworkingService? { 13 | let params = [kCTMediatorParamsKeySwiftTargetModuleName:moduleName] 14 | guard let service = performTarget(identifier, action: identifier, params: params, shouldCacheTarget: true) as? CTNetworkingService else { return nil } 15 | return service 16 | } 17 | 18 | func fetchCTNetworkingLoginService(identifier:String, moduleName:String) -> CTNetworkingLoginService? { 19 | let params = [kCTMediatorParamsKeySwiftTargetModuleName:moduleName] 20 | guard let service = performTarget(identifier, action: identifier, params: params, shouldCacheTarget: true) as? CTNetworkingLoginService else { return nil } 21 | return service 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Services/LoginServiceProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LoginServiceProtocol.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2020/3/18. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol CTNetworkingLoginService { 12 | func isCurrentLoggedIn() -> Bool 13 | func doLoginProcess(success:(()->Void)?, fail:(()->Void)?, cancel:(()->Void)?, apiManager:CTNetworkingAPIManager) 14 | func loginSuccessOperation(apiManager:CTNetworkingAPIManager) 15 | func loginFailOperation(apiManager:CTNetworkingAPIManager) 16 | func loginCancelOperation(apiManager:CTNetworkingAPIManager) 17 | } 18 | -------------------------------------------------------------------------------- /CTNetworkingSwift/CTNetworkingSwift/Services/ServiceProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceProtocol.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/20. 6 | // 7 | 8 | import Foundation 9 | import Alamofire 10 | 11 | public protocol CTNetworkingService { 12 | var session : Session { get } 13 | 14 | // 支持headers设置的request方法,建议实现该request方法 15 | func request(params:Parameters?, extraURLParams:Parameters?, methodName:String, requestType:HTTPMethod, headers:HTTPHeaders?) -> URLRequest? 16 | 17 | // 该request方法与上面request方法只有设置headers的区别,必须实现其中一个,若同时两个都实现,只有支持headers的方法生效 18 | func request(params:Parameters?, extraURLParams:Parameters?, methodName:String, requestType:HTTPMethod) -> URLRequest? 19 | 20 | func handleCommonError(_ apiManager:CTNetworkingAPIManager) -> Bool 21 | } 22 | 23 | public extension CTNetworkingService { 24 | func request(params:Parameters?, extraURLParams:Parameters?, methodName:String, requestType:HTTPMethod, headers:HTTPHeaders?) -> URLRequest? { 25 | return self.request(params: params, extraURLParams: extraURLParams, methodName: methodName, requestType: requestType) 26 | } 27 | func request(params:Parameters?, extraURLParams:Parameters?, methodName:String, requestType:HTTPMethod) -> URLRequest?{ 28 | return nil 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/CTNetworkingProtocol.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CTNetworkingProtocol.swift 3 | // CTNetworking.Swift_Example 4 | // 5 | // Created by casa on 2018/9/25. 6 | // Copyright © 2018年 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class CTNetworkingProtocol : URLProtocol { 12 | override class func canInit(with request: URLRequest) -> Bool { 13 | return false 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/Test/LogHandleTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LogHandleTarget.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by 景鹏博 on 2020/11/19. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | @objc class Target_LogHandle: NSObject { 12 | /** 13 | // custom log message 14 | @objc func Action_LogHandle(_ params:NSDictionary) -> Bool { 15 | guard let logMessage = params["message"] as? String else { return false } 16 | print("custom log message") 17 | print(logMessage) 18 | return true 19 | } 20 | */ 21 | } 22 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/Test/ServiceTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ServiceTarget.swift 3 | // CTNetworkingSwift 4 | // 5 | // Created by casa on 2020/2/28. 6 | // Copyright © 2020 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | @objc class Target_TestService: NSObject { 12 | @objc func Action_TestService(_ params:NSDictionary) -> Any { 13 | return TestService.shared 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/Test/TestAPIManager/TestAPIManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestAPIManager.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/26. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Alamofire 11 | 12 | class TestAPIManager: CTNetworkingAPIManager { 13 | override init() { 14 | super.init() 15 | child = self 16 | validator = self 17 | } 18 | } 19 | 20 | extension TestAPIManager: CTNetworkingAPIManagerValidator{} 21 | 22 | extension TestAPIManager : CTNetworkingAPIManagerChild { 23 | var isAPINeedLoginInfo: Bool { 24 | return false 25 | } 26 | 27 | var serviceIdentifier: String { 28 | return "TestService" 29 | } 30 | 31 | var loginServiceIdentifier: String { 32 | return "TestService" 33 | } 34 | 35 | var logHandleIdentifier: String { 36 | return "LogHandle" 37 | } 38 | 39 | var isPagable: Bool { 40 | return false 41 | } 42 | 43 | var methodName: String { 44 | return "" 45 | } 46 | 47 | var requestType: HTTPMethod { 48 | return .get 49 | } 50 | 51 | var moduleName: String { 52 | return "CTNetworkingSwift" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/Test/TestAPIManager/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "hello":"casa" 3 | } 4 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/Test/TestService/TestService.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestService.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/26. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Alamofire 11 | 12 | class TestService : CTNetworkingService { 13 | func request(params: Parameters?, extraURLParams: Parameters?, methodName: String, requestType: HTTPMethod) -> URLRequest? { 14 | guard let url = URL(string: "https://www.baidu.com") else { return nil } 15 | let request = URLRequest(url: url) 16 | return request 17 | } 18 | 19 | static let shared: CTNetworkingService = TestService() 20 | 21 | lazy var session: Session = Session.default 22 | 23 | func handleCommonError(_ apiManager: CTNetworkingAPIManager) -> Bool { 24 | return true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/ViewController/Callback.ViewController.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Callback.ViewController.extension.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/26. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension ViewController : CTNetworkingAPIManagerCallbackDelegate { 12 | func requestDidSuccess(_ apiManager: CTNetworkingAPIManager) { 13 | print("success") 14 | guard let result = apiManager.fetchAsDictionary() else { return } 15 | debugPrint(result) 16 | debugPrint(result["hello"]) 17 | } 18 | 19 | func requestDidFailed(_ apiManager: CTNetworkingAPIManager) { 20 | print("fail") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/ViewController/LifeCycle.ViewController.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LifeCycle.ViewController.extension.swift 3 | // CTNetworking.Swift_Example 4 | // 5 | // Created by casa on 2018/9/20. 6 | // Copyright © 2018年 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftHandyFrame 11 | 12 | extension ViewController { 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | view.addSubview(tableView) 16 | } 17 | 18 | override func viewWillLayoutSubviews() { 19 | super.viewWillLayoutSubviews() 20 | tableView.hf.fill() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/ViewController/ParamSource.ViewController.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParamSource.ViewController.extension.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by casa on 2018/9/26. 6 | // Copyright © 2018 casa. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Alamofire 11 | 12 | extension ViewController : CTNetworkingAPIManagerParamSource { 13 | func params(for apiManager: CTNetworkingAPIManager) -> Parameters? { 14 | return nil 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/ViewController/TableView.ViewController.extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableView.ViewController.extension.swift 3 | // CTNetworking.Swift_Example 4 | // 5 | // Created by casa on 2018/9/20. 6 | // Copyright © 2018年 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Alamofire 11 | 12 | extension ViewController : UITableViewDelegate, UITableViewDataSource { 13 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 14 | return dataSource.count 15 | } 16 | 17 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 18 | return tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) 19 | } 20 | 21 | func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 22 | cell.textLabel?.text = dataSource[indexPath.row] 23 | } 24 | 25 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 26 | tableView.deselectRow(at: indexPath, animated: true) 27 | if indexPath.row == 0 { 28 | testAPIManager.loadData() 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Demo/ViewController/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CTNetworking.Swift 4 | // 5 | // Created by Casa Taloyum on 09/20/2018. 6 | // Copyright (c) 2018 Casa Taloyum. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Alamofire 11 | 12 | class ViewController: UIViewController { 13 | 14 | lazy var tableView : UITableView = { 15 | let _tableView = UITableView(frame: .zero, style: .plain) 16 | _tableView.delegate = self 17 | _tableView.dataSource = self 18 | _tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") 19 | _tableView.tableFooterView = UIView() 20 | return _tableView 21 | }() 22 | 23 | lazy var dataSource = [ 24 | "API Manager", 25 | ] 26 | 27 | lazy var sessionManager : Session = { 28 | 29 | var certificates:[SecCertificate] = Bundle.main.af.certificates 30 | let manager = ServerTrustManager(evaluators: ["*":PinnedCertificatesTrustEvaluator(acceptSelfSignedCertificates:true)]) 31 | 32 | let configuration = URLSessionConfiguration.default 33 | var protocolClasses = configuration.protocolClasses 34 | protocolClasses?.insert(CTNetworkingProtocol.self, at: 0) 35 | configuration.protocolClasses = protocolClasses 36 | let sessionManager = Session(configuration: configuration, serverTrustManager: manager) 37 | return sessionManager 38 | }() 39 | 40 | lazy var testAPIManager : TestAPIManager = { 41 | let _testAPIManager = TestAPIManager() 42 | _testAPIManager.delegate = self 43 | _testAPIManager.mockDataFileURL = Bundle.main.url(forResource: "test", withExtension: "json") 44 | return _testAPIManager 45 | }() 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /CTNetworkingSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | platform :ios, '10.0' 3 | 4 | target 'CTNetworkingSwift' do 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for CTNetworkingSwift 9 | pod "Alamofire" 10 | 11 | # Private Pods 12 | pod "SwiftHandyFrame" 13 | pod "CTMediator" 14 | 15 | end 16 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Alamofire (5.4.1) 3 | - CTMediator (44) 4 | - SwiftHandyFrame (15) 5 | 6 | DEPENDENCIES: 7 | - Alamofire 8 | - CTMediator 9 | - SwiftHandyFrame 10 | 11 | SPEC REPOS: 12 | trunk: 13 | - Alamofire 14 | - CTMediator 15 | - SwiftHandyFrame 16 | 17 | SPEC CHECKSUMS: 18 | Alamofire: 2291f7d21ca607c491dd17642e5d40fdcda0e65c 19 | CTMediator: 933dba523da87bf875e4a7e8728945fbc512f1d2 20 | SwiftHandyFrame: 76340da8630c255a0b48f70a323f2d2b408babcc 21 | 22 | PODFILE CHECKSUM: 6ea071597123cf9c99463ee4ce240cb8dbff00b4 23 | 24 | COCOAPODS: 1.10.1 25 | -------------------------------------------------------------------------------- /upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git stash 3 | git pull origin master --tags 4 | git stash pop 5 | 6 | VersionString=`grep -E 's.version.*=' CTNetworkingSwift.podspec` 7 | VersionNumber=`tr -cd 0-9 <<<"$VersionString"` 8 | NewVersionNumber=$(($VersionNumber + 1)) 9 | LineNumber=`grep -nE 's.version.*=' CTNetworkingSwift.podspec | cut -d : -f1` 10 | sed -i "" "${LineNumber}s/${VersionNumber}/${NewVersionNumber}/g" CTNetworkingSwift.podspec 11 | 12 | echo "current version is ${VersionNumber}, new version is ${NewVersionNumber}" 13 | 14 | 15 | git commit -am ${NewVersionNumber} 16 | git tag ${NewVersionNumber} 17 | git push origin master --tags 18 | pod trunk push ./CTNetworkingSwift.podspec --verbose --use-libraries --allow-warnings --use-modular-headers 19 | --------------------------------------------------------------------------------