diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000000..951b97b9d6 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,2 @@ +ignore: + - "Tests" diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000000..7d2ed51c3c --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,33 @@ +> ℹ Please fill out this template when filing an issue. +> All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info. +> +> Per our [*CONTRIBUTING guidelines](https://github.com/AFNetworking/AFNetworking/blob/master/CONTRIBUTING.md), we use GitHub for +> bugs and feature requests, not general support. Other issues should be opened on Stack Overflow with the tag `afnetworking`. +> +> Please remove this line and everything above it before submitting. + +* [ ] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/AFNetworking/AFNetworking/blob/master/CONTRIBUTING.md). + +## What did you do? + +ℹ Please replace this with what you did. + +## What did you expect to happen? + +ℹ Please replace this with what you expected to happen. + +## What happened instead? + +ℹ Please replace this with of what happened instead. + +## AFNetworking Environment + +**AFNetworking version:** +**Xcode version:** +**Swift version:** +**Platform(s) running AFNetworking:** +**macOS version running Xcode:** + +## Demo Project + +ℹ Please link to or upload a project we can download that reproduces the issue. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..6e04c37480 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +### Issue Link :link: + + +### Goals :soccer: + + + +### Implementation Details :construction: + + + +### Testing Details :mag: + diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000000..65f633c793 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,33 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 14 + +# Number of days of inactivity before a stale Issue or Pull Request is closed +daysUntilClose: 7 + +# Issues or Pull Requests with these labels will never be considered stale +exemptLabels: + - "support" + - "bug" + - "security" + +# Label to use when marking as stale +staleLabel: stale + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. + +# Comment to post when removing the stale label. Set to `false` to disable +unmarkComment: false + +# Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable +closeComment: > + This issue has been auto-closed because there hasn't been any activity for at least 21 days. + However, we really appreciate your contribution, so thank you for that! 🙏 + Also, feel free to [open a new issue](https://github.com/AFNetworking/AFNetworking/issues/new) if you still experience this problem 👍. + +# Limit to only `issues` +only: issues diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..ec939bbbbd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: "AFNetworking CI" + +on: + push: + branches: + - master + pull_request: + branches: + - '*' + +jobs: + macOS: + name: Test macOS + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - name: macOS + run: fastlane ci_commit configuration:Debug --env macos + iOS: + name: Test iOS + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - name: iOS + run: fastlane ci_commit configuration:Debug --env ios13_xcode11 + Catalyst: + name: Test Catalyst + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - name: Catalyst + run: fastlane ci_commit configuration:Debug --env catalyst + tvOS: + name: Test tvOS + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - name: tvOS + run: fastlane ci_commit configuration:Debug --env tvos13_xcode11 + watchOS: + name: Build watchOS + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + strategy: + matrix: + destination: ["OS=6.1.1,name=Apple Watch Series 5 - 44mm"] #, "OS=4.2,name=Apple Watch Series 3 - 42mm", "OS=3.2,name=Apple Watch Series 2 - 42mm"] + steps: + - uses: actions/checkout@v2 + - name: watchOS - ${{ matrix.destination }} + run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "AFNetworking.xcodeproj" -scheme "AFNetworking watchOS" -destination "${{ matrix.destination }}" clean build | xcpretty + SPM: + name: Build with SPM + runs-on: macOS-latest + env: + DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer + steps: + - uses: actions/checkout@v2 + - name: SPM Build + run: swift build diff --git a/.gitignore b/.gitignore index f33bce3b46..cddadc3052 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ fastlane/test-output/* Carthage/Build fastlane/README.md +.build diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 index 0000000000..0edabf3396 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1 @@ +afnetworking diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..24ba9a38de --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.0 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c35335ad62..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -language: objective-c -osx_image: xcode7.1 -sudo: false -env: - global: - - LC_CTYPE=en_US.UTF-8 - - LANG=en_US.UTF-8 - - LANGUAGE=en_US.UTF-8 - - FASTLANE_LANE=ci_commit -matrix: - include: - - osx_image: xcode9.3 - env: FASTLANE_LANE=code_coverage FASTLANE_ENV=default - - osx_image: xcode9.3 - env: FASTLANE_ENV=ios11_xcode93 - - osx_image: xcode9.3 - env: FASTLANE_ENV=tvos11_xcode9 - - osx_image: xcode9.3 - env: FASTLANE_ENV=osx - - osx_image: xcode9.2 - env: FASTLANE_ENV=ios11_xcode92 - - osx_image: xcode9.1 - env: FASTLANE_ENV=ios11_xcode91 - - osx_image: xcode9 - env: FASTLANE_ENV=ios11_xcode9 - - osx_image: xcode8.3 - env: FASTLANE_ENV=ios10_xcode8 - - osx_image: xcode7.3 - env: FASTLANE_ENV=ios9_xcode7 - - osx_image: xcode7.3 - env: FASTLANE_ENV=ios8_xcode7 -before_install: - # Force bundler 1.12.5 because version 1.13 has issues, see https://github.com/fastlane/fastlane/issues/6065#issuecomment-246044617 - - gem uninstall bundler -v '>1.12.5' --force --executables || echo "bundler >1.12.5 is not installed" - - gem install bundler -v 1.12.5 --no-rdoc --no-ri --no-document --quiet - - gem install fastlane --no-rdoc --no-ri --no-document --quiet - - gem install cocoapods --no-rdoc --no-ri --no-document --quiet -script: - - set -o pipefail - - fastlane $FASTLANE_LANE configuration:Debug --env $FASTLANE_ENV - - fastlane $FASTLANE_LANE configuration:Release --env $FASTLANE_ENV -after_success: - - if [ "$FASTLANE_LANE" == "code_coverage" ]; then - bash <(curl -s https://codecov.io/bash); - fi -after_failure: - - cat -n ~/Library/Logs/scan/* - - cat -n $TMPDIR/com.apple.dt.XCTest-status/Session*.log - - cat -n ~/Library/Logs/DiagnosticReports/xctest*.crash -# deploy: -# provider: script -# script: fastlane complete_framework_release --env deploy -# on: -# tags: true diff --git a/AFNetworking.podspec b/AFNetworking.podspec index 1e243c5660..d16a42a616 100644 --- a/AFNetworking.podspec +++ b/AFNetworking.podspec @@ -1,60 +1,39 @@ Pod::Spec.new do |s| s.name = 'AFNetworking' - s.version = '3.2.1' + s.version = '4.0.0' s.license = 'MIT' - s.summary = 'A delightful iOS and OS X networking framework.' + s.summary = 'A delightful networking framework for Apple platforms.' s.homepage = 'https://github.com/AFNetworking/AFNetworking' s.social_media_url = 'https://twitter.com/AFNetworking' s.authors = { 'Mattt Thompson' => 'm@mattt.me' } - s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => s.version, :submodules => true } - s.requires_arc = true - - s.public_header_files = 'AFNetworking/AFNetworking.h' - s.source_files = 'AFNetworking/AFNetworking.h' - - pch_AF = <<-EOS -#ifndef TARGET_OS_IOS - #define TARGET_OS_IOS TARGET_OS_IPHONE -#endif - -#ifndef TARGET_OS_WATCH - #define TARGET_OS_WATCH 0 -#endif + s.source = { :git => 'https://github.com/AFNetworking/AFNetworking.git', :tag => s.version } -#ifndef TARGET_OS_TV - #define TARGET_OS_TV 0 -#endif -EOS - s.prefix_header_contents = pch_AF - - s.ios.deployment_target = '7.0' - s.osx.deployment_target = '10.9' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.10' s.watchos.deployment_target = '2.0' s.tvos.deployment_target = '9.0' - + + s.ios.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER' => 'com.alamofire.AFNetworking' } + s.osx.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER' => 'com.alamofire.AFNetworking' } + s.watchos.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER' => 'com.alamofire.AFNetworking-watchOS' } + s.tvos.pod_target_xcconfig = { 'PRODUCT_BUNDLE_IDENTIFIER' => 'com.alamofire.AFNetworking' } + + s.source_files = 'AFNetworking/AFNetworking.h' + s.subspec 'Serialization' do |ss| ss.source_files = 'AFNetworking/AFURL{Request,Response}Serialization.{h,m}' - ss.public_header_files = 'AFNetworking/AFURL{Request,Response}Serialization.h' - ss.watchos.frameworks = 'MobileCoreServices', 'CoreGraphics' - ss.ios.frameworks = 'MobileCoreServices', 'CoreGraphics' - ss.osx.frameworks = 'CoreServices' end s.subspec 'Security' do |ss| ss.source_files = 'AFNetworking/AFSecurityPolicy.{h,m}' - ss.public_header_files = 'AFNetworking/AFSecurityPolicy.h' - ss.frameworks = 'Security' end s.subspec 'Reachability' do |ss| - ss.ios.deployment_target = '7.0' - ss.osx.deployment_target = '10.9' + ss.ios.deployment_target = '9.0' + ss.osx.deployment_target = '10.10' ss.tvos.deployment_target = '9.0' ss.source_files = 'AFNetworking/AFNetworkReachabilityManager.{h,m}' - ss.public_header_files = 'AFNetworking/AFNetworkReachabilityManager.h' - - ss.frameworks = 'SystemConfiguration' end s.subspec 'NSURLSession' do |ss| @@ -65,15 +44,13 @@ EOS ss.dependency 'AFNetworking/Security' ss.source_files = 'AFNetworking/AF{URL,HTTP}SessionManager.{h,m}', 'AFNetworking/AFCompatibilityMacros.h' - ss.public_header_files = 'AFNetworking/AF{URL,HTTP}SessionManager.h', 'AFNetworking/AFCompatibilityMacros.h' end s.subspec 'UIKit' do |ss| - ss.ios.deployment_target = '7.0' + ss.ios.deployment_target = '9.0' ss.tvos.deployment_target = '9.0' ss.dependency 'AFNetworking/NSURLSession' - ss.public_header_files = 'UIKit+AFNetworking/*.h' ss.source_files = 'UIKit+AFNetworking' end end diff --git a/AFNetworking.xcodeproj/project.pbxproj b/AFNetworking.xcodeproj/project.pbxproj index 96e9060053..4525a4ba36 100644 --- a/AFNetworking.xcodeproj/project.pbxproj +++ b/AFNetworking.xcodeproj/project.pbxproj @@ -10,19 +10,10 @@ 1BF9F9601C87832B00F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; }; 1BF9F9611C87843200F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; }; 1BF9F9621C87843300F1F35A /* AFImageResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */; }; - 1F6F7DF71F17051000C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; }; - 1F6F7DF81F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; }; - 1F6F7DFA1F17051000C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; }; - 1F6F7DFB1F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; }; - 1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */; }; - 1F6F7DFE1F17051100C979D0 /* Let's Encrypt Authority X3.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */; }; 1F96D2A4203649560085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F96D2A5203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F96D2A6203649570085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F96D2A7203649580085FC3F /* AFCompatibilityMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1FBBC1C9207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; }; - 1FBBC1CA207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; }; - 1FBBC1CB207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */ = {isa = PBXBuildFile; fileRef = 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */; }; 2960BAC31C1B2F1A00BA02F0 /* AFUIButtonTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */; }; 297824A31BC2D69A0041C395 /* adn_0.cer in Resources */ = {isa = PBXBuildFile; fileRef = 297824A01BC2D69A0041C395 /* adn_0.cer */; }; 297824A41BC2D69A0041C395 /* adn_0.cer in Resources */ = {isa = PBXBuildFile; fileRef = 297824A01BC2D69A0041C395 /* adn_0.cer */; }; @@ -137,15 +128,12 @@ 299522A31BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995228D1BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.m */; }; 299522A61BBF13C700859F49 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522901BBF13C700859F49 /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 299522A71BBF13C700859F49 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 299522911BBF13C700859F49 /* UIButton+AFNetworking.m */; }; - 299522A81BBF13C700859F49 /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522921BBF13C700859F49 /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 299522A91BBF13C700859F49 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522931BBF13C700859F49 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 299522AA1BBF13C700859F49 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 299522941BBF13C700859F49 /* UIImageView+AFNetworking.m */; }; 299522AC1BBF13C700859F49 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522961BBF13C700859F49 /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 299522AD1BBF13C700859F49 /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 299522971BBF13C700859F49 /* UIProgressView+AFNetworking.m */; }; 299522AE1BBF13C700859F49 /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522981BBF13C700859F49 /* UIRefreshControl+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 299522AF1BBF13C700859F49 /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 299522991BBF13C700859F49 /* UIRefreshControl+AFNetworking.m */; }; - 299522B01BBF13C700859F49 /* UIWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2995229A1BBF13C700859F49 /* UIWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 299522B11BBF13C700859F49 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995229B1BBF13C700859F49 /* UIWebView+AFNetworking.m */; }; 29D3413F1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */; }; 29D341401C20D46400A7D266 /* AFCompoundResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */; }; 29D341411C20D46400A7D266 /* AFCompoundResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */; }; @@ -173,14 +161,18 @@ 29D96E951BCC406B00F571A5 /* AFImageDownloader.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522881BBF13C700859F49 /* AFImageDownloader.h */; settings = {ATTRIBUTES = (Public, ); }; }; 29D96E961BCC406B00F571A5 /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 2995228C1BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 29D96E971BCC406B00F571A5 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522901BBF13C700859F49 /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 29D96E981BCC406B00F571A5 /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522921BBF13C700859F49 /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 29D96E991BCC406B00F571A5 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522931BBF13C700859F49 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; 29D96E9A1BCC406B00F571A5 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 299522961BBF13C700859F49 /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 29F5EF031C47E64F008B976A /* AFUIWebViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F5EF021C47E64F008B976A /* AFUIWebViewTests.m */; }; 2D4563901DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */; }; 2D4563911DB117A200AE4812 /* AFXMLParserResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */; }; 2D4563921DB117A200AE4812 /* AFXMLParserResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */; }; 2D4563941DB11DDB00AE4812 /* AFXMLDocumentResponseSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2D4563931DB11DDB00AE4812 /* AFXMLDocumentResponseSerializerTests.m */; }; + 31CBC007242D8DF200934333 /* httpbinorg_02182021.cer in Resources */ = {isa = PBXBuildFile; fileRef = 31CBC006242D8DF200934333 /* httpbinorg_02182021.cer */; }; + 31CBC008242D8DF200934333 /* httpbinorg_02182021.cer in Resources */ = {isa = PBXBuildFile; fileRef = 31CBC006242D8DF200934333 /* httpbinorg_02182021.cer */; }; + 31CBC009242D8DF200934333 /* httpbinorg_02182021.cer in Resources */ = {isa = PBXBuildFile; fileRef = 31CBC006242D8DF200934333 /* httpbinorg_02182021.cer */; }; + 323D83E2231D185400C5BFC6 /* WKWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 323D83E0231D185400C5BFC6 /* WKWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 323D83E3231D185400C5BFC6 /* WKWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 323D83E1231D185400C5BFC6 /* WKWebView+AFNetworking.m */; }; + 323D83E5231D188400C5BFC6 /* AFWKWebViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 323D83E4231D188400C5BFC6 /* AFWKWebViewTests.m */; }; 5F4323BB1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323B31BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer */; }; 5F4323BC1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323B31BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer */; }; 5F4323BD1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323B31BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer */; }; @@ -202,6 +194,15 @@ 5F4323DD1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; }; 5F4323DE1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; }; 5F4323DF1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */ = {isa = PBXBuildFile; fileRef = 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */; }; + E2B10D8E233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; }; + E2B10D8F233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; }; + E2B10D90233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */; }; + E2B10D91233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; }; + E2B10D92233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; }; + E2B10D93233035100004E005 /* Amazon Root CA 1.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */; }; + E2B10D94233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; }; + E2B10D95233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; }; + E2B10D96233035100004E005 /* Amazon.cer in Resources */ = {isa = PBXBuildFile; fileRef = E2B10D8D233035100004E005 /* Amazon.cer */; }; E91164651DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; }; E91164661DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; }; E91164671DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */; }; @@ -234,9 +235,6 @@ /* Begin PBXFileReference section */ 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageResponseSerializerTests.m; sourceTree = ""; }; 1F083A4920364648004D80C7 /* AFCompatibilityMacros.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AFCompatibilityMacros.h; sourceTree = ""; }; - 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Let's Encrypt Authority X3.cer"; sourceTree = ""; }; - 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "DST Root CA X3.cer"; sourceTree = ""; }; - 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = httpbinorg_06102018.cer; sourceTree = ""; }; 2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFUIButtonTests.m; sourceTree = ""; }; 297824A01BC2D69A0041C395 /* adn_0.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_0.cer; path = ADNNetServerTrustChain/adn_0.cer; sourceTree = ""; }; 297824A11BC2D69A0041C395 /* adn_1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; name = adn_1.cer; path = ADNNetServerTrustChain/adn_1.cer; sourceTree = ""; }; @@ -294,7 +292,6 @@ 2995228D1BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; 299522901BBF13C700859F49 /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+AFNetworking.h"; sourceTree = ""; }; 299522911BBF13C700859F49 /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+AFNetworking.m"; sourceTree = ""; }; - 299522921BBF13C700859F49 /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+AFNetworking.h"; sourceTree = ""; }; 299522931BBF13C700859F49 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; 299522941BBF13C700859F49 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; 299522951BBF13C700859F49 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIKit+AFNetworking.h"; sourceTree = ""; }; @@ -302,12 +299,13 @@ 299522971BBF13C700859F49 /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIProgressView+AFNetworking.m"; sourceTree = ""; }; 299522981BBF13C700859F49 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; 299522991BBF13C700859F49 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; - 2995229A1BBF13C700859F49 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+AFNetworking.h"; sourceTree = ""; }; - 2995229B1BBF13C700859F49 /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+AFNetworking.m"; sourceTree = ""; }; 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFCompoundResponseSerializerTests.m; sourceTree = ""; }; - 29F5EF021C47E64F008B976A /* AFUIWebViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFUIWebViewTests.m; sourceTree = ""; }; 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLParserResponseSerializerTests.m; sourceTree = ""; }; 2D4563931DB11DDB00AE4812 /* AFXMLDocumentResponseSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLDocumentResponseSerializerTests.m; sourceTree = ""; }; + 31CBC006242D8DF200934333 /* httpbinorg_02182021.cer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = httpbinorg_02182021.cer; sourceTree = ""; }; + 323D83E0231D185400C5BFC6 /* WKWebView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "WKWebView+AFNetworking.h"; sourceTree = ""; }; + 323D83E1231D185400C5BFC6 /* WKWebView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "WKWebView+AFNetworking.m"; sourceTree = ""; }; + 323D83E4231D188400C5BFC6 /* AFWKWebViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFWKWebViewTests.m; sourceTree = ""; }; 5F4323B31BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = Equifax_Secure_Certificate_Authority_Root.cer; sourceTree = ""; }; 5F4323B41BF63741003B8749 /* GeoTrust_Global_CA-cross.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "GeoTrust_Global_CA-cross.cer"; sourceTree = ""; }; 5F4323B51BF63741003B8749 /* google.com.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = google.com.cer; sourceTree = ""; }; @@ -315,6 +313,9 @@ 5F4323D41BF63CB0003B8749 /* GoogleComServerTrustChainPath1 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = GoogleComServerTrustChainPath1; sourceTree = ""; }; 5F4323D81BF63CBA003B8749 /* GoogleComServerTrustChainPath2 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = GoogleComServerTrustChainPath2; sourceTree = ""; }; 5F4323DC1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = GeoTrust_Global_CA_Root.cer; sourceTree = ""; }; + E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Starfield Services Root Certificate Authority - G2.cer"; sourceTree = ""; }; + E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Amazon Root CA 1.cer"; sourceTree = ""; }; + E2B10D8D233035100004E005 /* Amazon.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = Amazon.cer; sourceTree = ""; }; E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestSerializerTests.m; sourceTree = ""; }; /* End PBXFileReference section */ @@ -409,10 +410,11 @@ 298D7C6D1BC2C88F00FD3B3E /* HTTPBin.org */ = { isa = PBXGroup; children = ( + E2B10D8C233035100004E005 /* Amazon Root CA 1.cer */, + E2B10D8D233035100004E005 /* Amazon.cer */, + E2B10D8B233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer */, 298D7CE21BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain */, - 1F6F7DF61F1703A100C979D0 /* DST Root CA X3.cer */, - 1F6F7DF51F1703A100C979D0 /* Let's Encrypt Authority X3.cer */, - 1FBBC1C8207D5F8F00631B47 /* httpbinorg_06102018.cer */, + 31CBC006242D8DF200934333 /* httpbinorg_02182021.cer */, ); path = HTTPBin.org; sourceTree = ""; @@ -441,19 +443,19 @@ 298D7CD11BC2CABE00FD3B3E /* AFNetworking Tests */ = { isa = PBXGroup; children = ( + 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */, 298D7C811BC2C88F00FD3B3E /* AFHTTPRequestSerializationTests.m */, 298D7C821BC2C88F00FD3B3E /* AFHTTPResponseSerializationTests.m */, 298D7C831BC2C88F00FD3B3E /* AFHTTPSessionManagerTests.m */, - 298D7C851BC2C88F00FD3B3E /* AFJSONSerializationTests.m */, - 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */, - 2D4563931DB11DDB00AE4812 /* AFXMLDocumentResponseSerializerTests.m */, - 298D7C881BC2C88F00FD3B3E /* AFPropertyListResponseSerializerTests.m */, - E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */, - 29D3413E1C20D46400A7D266 /* AFCompoundResponseSerializerTests.m */, 1BF9F95F1C87832B00F1F35A /* AFImageResponseSerializerTests.m */, + 298D7C851BC2C88F00FD3B3E /* AFJSONSerializationTests.m */, 298D7C871BC2C88F00FD3B3E /* AFNetworkReachabilityManagerTests.m */, + E91164641DA6A7AE00DFFF56 /* AFPropertyListRequestSerializerTests.m */, + 298D7C881BC2C88F00FD3B3E /* AFPropertyListResponseSerializerTests.m */, 298D7C891BC2C88F00FD3B3E /* AFSecurityPolicyTests.m */, 298D7C8F1BC2C88F00FD3B3E /* AFURLSessionManagerTests.m */, + 2D4563931DB11DDB00AE4812 /* AFXMLDocumentResponseSerializerTests.m */, + 2D45638F1DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m */, ); name = "AFNetworking Tests"; sourceTree = ""; @@ -465,10 +467,10 @@ 298D7C841BC2C88F00FD3B3E /* AFImageDownloaderTests.m */, 298D7C861BC2C88F00FD3B3E /* AFNetworkActivityManagerTests.m */, 298D7C8C1BC2C88F00FD3B3E /* AFUIActivityIndicatorViewTests.m */, + 2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */, 298D7C8D1BC2C88F00FD3B3E /* AFUIImageViewTests.m */, 298D7C8E1BC2C88F00FD3B3E /* AFUIRefreshControlTests.m */, - 2960BAC21C1B2F1A00BA02F0 /* AFUIButtonTests.m */, - 29F5EF021C47E64F008B976A /* AFUIWebViewTests.m */, + 323D83E4231D188400C5BFC6 /* AFWKWebViewTests.m */, ); name = "AFNetworking UIKit Tests"; sourceTree = ""; @@ -544,7 +546,6 @@ 2995228D1BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.m */, 299522901BBF13C700859F49 /* UIButton+AFNetworking.h */, 299522911BBF13C700859F49 /* UIButton+AFNetworking.m */, - 299522921BBF13C700859F49 /* UIImage+AFNetworking.h */, 299522931BBF13C700859F49 /* UIImageView+AFNetworking.h */, 299522941BBF13C700859F49 /* UIImageView+AFNetworking.m */, 299522951BBF13C700859F49 /* UIKit+AFNetworking.h */, @@ -552,8 +553,8 @@ 299522971BBF13C700859F49 /* UIProgressView+AFNetworking.m */, 299522981BBF13C700859F49 /* UIRefreshControl+AFNetworking.h */, 299522991BBF13C700859F49 /* UIRefreshControl+AFNetworking.m */, - 2995229A1BBF13C700859F49 /* UIWebView+AFNetworking.h */, - 2995229B1BBF13C700859F49 /* UIWebView+AFNetworking.m */, + 323D83E0231D185400C5BFC6 /* WKWebView+AFNetworking.h */, + 323D83E1231D185400C5BFC6 /* WKWebView+AFNetworking.m */, ); path = "UIKit+AFNetworking"; sourceTree = ""; @@ -590,7 +591,6 @@ 1F96D2A7203649580085FC3F /* AFCompatibilityMacros.h in Headers */, 29D96E961BCC406B00F571A5 /* UIActivityIndicatorView+AFNetworking.h in Headers */, 29D96E971BCC406B00F571A5 /* UIButton+AFNetworking.h in Headers */, - 29D96E981BCC406B00F571A5 /* UIImage+AFNetworking.h in Headers */, 29D96E991BCC406B00F571A5 /* UIImageView+AFNetworking.h in Headers */, 29D96E9A1BCC406B00F571A5 /* UIProgressView+AFNetworking.h in Headers */, 29D96E8E1BCC3D7D00F571A5 /* AFNetworking.h in Headers */, @@ -602,7 +602,6 @@ buildActionMask = 2147483647; files = ( 2995225A1BBF125A00859F49 /* AFURLRequestSerialization.h in Headers */, - 299522A81BBF13C700859F49 /* UIImage+AFNetworking.h in Headers */, 299522531BBF125A00859F49 /* AFHTTPSessionManager.h in Headers */, 2995229C1BBF13C700859F49 /* AFAutoPurgingImageCache.h in Headers */, 299522581BBF125A00859F49 /* AFSecurityPolicy.h in Headers */, @@ -610,11 +609,11 @@ 299522A91BBF13C700859F49 /* UIImageView+AFNetworking.h in Headers */, 2995229E1BBF13C700859F49 /* AFImageDownloader.h in Headers */, 2995225E1BBF125A00859F49 /* AFURLSessionManager.h in Headers */, + 323D83E2231D185400C5BFC6 /* WKWebView+AFNetworking.h in Headers */, 2995225C1BBF125A00859F49 /* AFURLResponseSerialization.h in Headers */, 299522A21BBF13C700859F49 /* UIActivityIndicatorView+AFNetworking.h in Headers */, 1F96D2A4203649560085FC3F /* AFCompatibilityMacros.h in Headers */, 2995223D1BBF104D00859F49 /* AFNetworking.h in Headers */, - 299522B01BBF13C700859F49 /* UIWebView+AFNetworking.h in Headers */, 299522AC1BBF13C700859F49 /* UIProgressView+AFNetworking.h in Headers */, 299522A61BBF13C700859F49 /* UIButton+AFNetworking.h in Headers */, 299522A01BBF13C700859F49 /* AFNetworkActivityIndicatorManager.h in Headers */, @@ -786,40 +785,46 @@ 299522301BBF104D00859F49 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1140; ORGANIZATIONNAME = AFNetworking; TargetAttributes = { 2987B0A41BC408A200179A4C = { CreatedOnToolsVersion = 7.1; + ProvisioningStyle = Automatic; }; 2987B0AD1BC408A200179A4C = { CreatedOnToolsVersion = 7.1; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; 298D7C3A1BC2C79500FD3B3E = { CreatedOnToolsVersion = 7.0.1; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; 298D7C491BC2C7B200FD3B3E = { CreatedOnToolsVersion = 7.0.1; + ProvisioningStyle = Automatic; }; 299522381BBF104D00859F49 = { CreatedOnToolsVersion = 7.0.1; + ProvisioningStyle = Automatic; }; 299522641BBF129200859F49 = { CreatedOnToolsVersion = 7.0.1; + ProvisioningStyle = Automatic; }; 299522761BBF136400859F49 = { CreatedOnToolsVersion = 7.0.1; + ProvisioningStyle = Automatic; }; }; }; buildConfigurationList = 299522331BBF104D00859F49 /* Build configuration list for PBXProject "AFNetworking" */; compatibilityVersion = "Xcode 6.3"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 2995222F1BBF104D00859F49; productRefGroup = 2995223A1BBF104D00859F49 /* Products */; @@ -851,7 +856,7 @@ files = ( 2987B0DE1BC40AFB00179A4C /* foobar.com.cer in Resources */, 2987B0D61BC40AEC00179A4C /* ADNNetServerTrustChain in Resources */, - 1FBBC1CB207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */, + E2B10D90233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */, 2987B0DF1BC40AFB00179A4C /* NoDomains.cer in Resources */, 2987B0D41BC40AE900179A4C /* adn_1.cer in Resources */, 2987B0DD1BC40AFB00179A4C /* AltName.cer in Resources */, @@ -860,12 +865,13 @@ 2987B0DC1BC40AF600179A4C /* logo.png in Resources */, 2987B0D51BC40AE900179A4C /* adn_2.cer in Resources */, 5F4323D71BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */, - 1F6F7DFE1F17051100C979D0 /* Let's Encrypt Authority X3.cer in Resources */, + E2B10D96233035100004E005 /* Amazon.cer in Resources */, 5F4323DB1BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */, 5F4323BD1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */, 5F4323DF1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */, + E2B10D93233035100004E005 /* Amazon Root CA 1.cer in Resources */, + 31CBC009242D8DF200934333 /* httpbinorg_02182021.cer in Resources */, 5F4323C01BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */, - 1F6F7DFD1F17051100C979D0 /* DST Root CA X3.cer in Resources */, 5F4323CF1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */, 5F4323C31BF63741003B8749 /* google.com.cer in Resources */, ); @@ -877,7 +883,7 @@ files = ( 298D7CBF1BC2CA9D00FD3B3E /* foobar.com.cer in Resources */, 298D7CBA1BC2CA9800FD3B3E /* logo.png in Resources */, - 1FBBC1C9207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */, + E2B10D8E233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */, 297824A31BC2D69A0041C395 /* adn_0.cer in Resources */, 298D7CE31BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */, 297824A71BC2D69A0041C395 /* adn_2.cer in Resources */, @@ -886,12 +892,13 @@ 298D7CE01BC2CB5A00FD3B3E /* ADNNetServerTrustChain in Resources */, 298D7CBE1BC2CA9D00FD3B3E /* AltName.cer in Resources */, 5F4323D51BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */, - 1F6F7DF81F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */, + E2B10D94233035100004E005 /* Amazon.cer in Resources */, 5F4323D91BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */, 5F4323BB1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */, 5F4323DD1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */, + E2B10D91233035100004E005 /* Amazon Root CA 1.cer in Resources */, + 31CBC007242D8DF200934333 /* httpbinorg_02182021.cer in Resources */, 5F4323BE1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */, - 1F6F7DF71F17051000C979D0 /* DST Root CA X3.cer in Resources */, 5F4323CD1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */, 5F4323C11BF63741003B8749 /* google.com.cer in Resources */, ); @@ -903,7 +910,7 @@ files = ( 298D7CBC1BC2CA9C00FD3B3E /* foobar.com.cer in Resources */, 298D7CB91BC2CA9800FD3B3E /* logo.png in Resources */, - 1FBBC1CA207D5F8F00631B47 /* httpbinorg_06102018.cer in Resources */, + E2B10D8F233035100004E005 /* Starfield Services Root Certificate Authority - G2.cer in Resources */, 297824A41BC2D69A0041C395 /* adn_0.cer in Resources */, 298D7CE41BC2CB7C00FD3B3E /* HTTPBinOrgServerTrustChain in Resources */, 297824A81BC2D69A0041C395 /* adn_2.cer in Resources */, @@ -912,12 +919,13 @@ 298D7CE11BC2CB5A00FD3B3E /* ADNNetServerTrustChain in Resources */, 298D7CBB1BC2CA9C00FD3B3E /* AltName.cer in Resources */, 5F4323D61BF63CB0003B8749 /* GoogleComServerTrustChainPath1 in Resources */, - 1F6F7DFB1F17051000C979D0 /* Let's Encrypt Authority X3.cer in Resources */, + E2B10D95233035100004E005 /* Amazon.cer in Resources */, 5F4323DA1BF63CBA003B8749 /* GoogleComServerTrustChainPath2 in Resources */, 5F4323BC1BF63741003B8749 /* Equifax_Secure_Certificate_Authority_Root.cer in Resources */, 5F4323CE1BF63741003B8749 /* GoogleInternetAuthorityG2.cer in Resources */, + E2B10D92233035100004E005 /* Amazon Root CA 1.cer in Resources */, + 31CBC008242D8DF200934333 /* httpbinorg_02182021.cer in Resources */, 5F4323DE1BF63CCC003B8749 /* GeoTrust_Global_CA_Root.cer in Resources */, - 1F6F7DFA1F17051000C979D0 /* DST Root CA X3.cer in Resources */, 5F4323BF1BF63741003B8749 /* GeoTrust_Global_CA-cross.cer in Resources */, 5F4323C21BF63741003B8749 /* google.com.cer in Resources */, ); @@ -1009,8 +1017,8 @@ 298D7CD91BC2CAF200FD3B3E /* AFNetworkReachabilityManagerTests.m in Sources */, 297824AA1BC2DAD80041C395 /* AFAutoPurgingImageCacheTests.m in Sources */, 298D7C981BC2CA2500FD3B3E /* AFURLSessionManagerTests.m in Sources */, + 323D83E5231D188400C5BFC6 /* AFWKWebViewTests.m in Sources */, 297824AC1BC2DB450041C395 /* AFImageDownloaderTests.m in Sources */, - 29F5EF031C47E64F008B976A /* AFUIWebViewTests.m in Sources */, 2D4563901DB1179D00AE4812 /* AFXMLParserResponseSerializerTests.m in Sources */, 298D7CD51BC2CAEC00FD3B3E /* AFHTTPSessionManagerTests.m in Sources */, 298D7CD71BC2CAEF00FD3B3E /* AFJSONSerializationTests.m in Sources */, @@ -1047,10 +1055,10 @@ 299522571BBF125A00859F49 /* AFNetworkReachabilityManager.m in Sources */, 299522AF1BBF13C700859F49 /* UIRefreshControl+AFNetworking.m in Sources */, 299522AA1BBF13C700859F49 /* UIImageView+AFNetworking.m in Sources */, - 299522B11BBF13C700859F49 /* UIWebView+AFNetworking.m in Sources */, 299522591BBF125A00859F49 /* AFSecurityPolicy.m in Sources */, 299522A71BBF13C700859F49 /* UIButton+AFNetworking.m in Sources */, 299522541BBF125A00859F49 /* AFHTTPSessionManager.m in Sources */, + 323D83E3231D185400C5BFC6 /* WKWebView+AFNetworking.m in Sources */, 2995225F1BBF125A00859F49 /* AFURLSessionManager.m in Sources */, 2995225B1BBF125A00859F49 /* AFURLRequestSerialization.m in Sources */, 2995229D1BBF13C700859F49 /* AFAutoPurgingImageCache.m in Sources */, @@ -1113,22 +1121,23 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = marker; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; @@ -1138,22 +1147,23 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = bitcode; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; + CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; @@ -1161,14 +1171,16 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-tvOSTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; - TVOS_DEPLOYMENT_TARGET = 9.0; + TARGETED_DEVICE_FAMILY = 3; }; name = Debug; }; @@ -1176,14 +1188,16 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-tvOSTests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; - TVOS_DEPLOYMENT_TARGET = 9.0; + TARGETED_DEVICE_FAMILY = 3; }; name = Release; }; @@ -1191,14 +1205,17 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Tests/Tests-Prefix.pch"; INFOPLIST_FILE = ./Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-iOS-Tests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; }; name = Debug; }; @@ -1206,14 +1223,17 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; + CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = ""; GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Tests/Tests-Prefix.pch"; INFOPLIST_FILE = ./Tests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-iOS-Tests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; }; name = Release; }; @@ -1221,14 +1241,17 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Tests/Tests-Prefix.pch"; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-Mac-OS-X-Tests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; }; name = Debug; @@ -1237,14 +1260,17 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = "-"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + DEVELOPMENT_TEAM = ""; GCC_PREFIX_HEADER = "$(PROJECT_DIR)/Tests/Tests-Prefix.pch"; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-Mac-OS-X-Tests"; + PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; }; name = Release; @@ -1253,8 +1279,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; + CLANG_ENABLE_CODE_COVERAGE = YES; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_ASSIGN_ENUM = YES; @@ -1288,7 +1316,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -1296,7 +1324,7 @@ "DEBUG=1", "$(inherited)", ); - GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; @@ -1315,8 +1343,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MARKETING_VERSION = 4.0.0; MODULEMAP_FILE = "$(PROJECT_DIR)/Framework/module.modulemap"; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -1325,6 +1354,11 @@ TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; + WARNING_CFLAGS = ( + "-Wall", + "-Wextra", + "-Wno-unused-parameter", + ); WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; @@ -1333,8 +1367,10 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_CXX_LANGUAGE_STANDARD = "compiler-default"; + CLANG_CXX_LIBRARY = "compiler-default"; + CLANG_ENABLE_CODE_COVERAGE = NO; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_ASSIGN_ENUM = YES; @@ -1368,9 +1404,9 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_C_LANGUAGE_STANDARD = "compiler-default"; GCC_NO_COMMON_BLOCKS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; @@ -1389,8 +1425,9 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MARKETING_VERSION = 4.0.0; MODULEMAP_FILE = "$(PROJECT_DIR)/Framework/module.modulemap"; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; @@ -1399,6 +1436,11 @@ VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; + WARNING_CFLAGS = ( + "-Wall", + "-Wextra", + "-Wno-unused-parameter", + ); WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; @@ -1409,20 +1451,25 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = marker; CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 4.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; @@ -1432,20 +1479,25 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = bitcode; CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MARKETING_VERSION = 4.0.0; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = ""; SKIP_INSTALL = YES; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; @@ -1455,8 +1507,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = marker; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1465,11 +1520,10 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-watchOS"; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; @@ -1479,8 +1533,11 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = bitcode; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; + CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1489,11 +1546,10 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.AFNetworking-watchOS"; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = watchos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 4; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; @@ -1503,24 +1559,24 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = marker; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SKIP_INSTALL = YES; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; @@ -1530,24 +1586,24 @@ APPLICATION_EXTENSION_API_ONLY = YES; BITCODE_GENERATION_MODE = bitcode; CLANG_ENABLE_OBJC_WEAK = YES; + CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_VERSION = A; INFOPLIST_FILE = ./Framework/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = com.alamofire.AFNetworking; PRODUCT_NAME = AFNetworking; + PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = macosx; SKIP_INSTALL = YES; - TVOS_DEPLOYMENT_TARGET = 9.0; - WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS.xcscheme b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS.xcscheme index 617a92dbbc..264cb201a1 100644 --- a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS.xcscheme +++ b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS.xcscheme @@ -1,6 +1,6 @@ - - - - - - - - - - + shouldUseLaunchSchemeArgsEnv = "NO" + enableThreadSanitizer = "YES" + enableUBSanitizer = "YES" + codeCoverageEnabled = "YES"> + + + + + + + + + + + + + allowLocationSimulation = "YES" + consoleMode = "1"> - - - - - - - - - - - - + shouldUseLaunchSchemeArgsEnv = "NO" + enableThreadSanitizer = "YES" + enableUBSanitizer = "YES" + codeCoverageEnabled = "YES"> + + + + + + + + + + + + - - - - - - - - - - - - + shouldUseLaunchSchemeArgsEnv = "NO" + enableThreadSanitizer = "YES" + enableUBSanitizer = "YES"> + + + + + + + + + + diff --git a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking watchOS.xcscheme b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking watchOS.xcscheme index 9319f684dd..2585216082 100644 --- a/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking watchOS.xcscheme +++ b/AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking watchOS.xcscheme @@ -1,6 +1,6 @@ - - - - *pinnedCertificates; @@ -90,10 +90,14 @@ NS_ASSUME_NONNULL_BEGIN /** Creates and returns a security policy with the specified pinning mode. + + Certificates with the `.cer` extension found in the main bundle will be pinned. If you want more control over which certificates are pinned, please use `policyWithPinningMode:withPinnedCertificates:` instead. @param pinningMode The SSL pinning mode. @return A new security policy. + + @see -policyWithPinningMode:withPinnedCertificates: */ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; @@ -104,7 +108,10 @@ NS_ASSUME_NONNULL_BEGIN @param pinnedCertificates The certificates to pin against. @return A new security policy. - */ + + @see +certificatesInBundle: + @see -pinnedCertificates +*/ + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; ///------------------------------ diff --git a/AFNetworking/AFSecurityPolicy.m b/AFNetworking/AFSecurityPolicy.m index 043441a03b..da199aa3b7 100644 --- a/AFNetworking/AFSecurityPolicy.m +++ b/AFNetworking/AFSecurityPolicy.m @@ -60,7 +60,10 @@ static id AFPublicKeyForCertificate(NSData *certificate) { policy = SecPolicyCreateBasicX509(); __Require_noErr_Quiet(SecTrustCreateWithCertificates(allowedCertificate, policy, &allowedTrust), _out); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); +#pragma clang diagnostic pop allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); @@ -83,7 +86,10 @@ static id AFPublicKeyForCertificate(NSData *certificate) { static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { BOOL isValid = NO; SecTrustResultType result; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); +#pragma clang diagnostic pop isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); @@ -115,10 +121,11 @@ static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { SecTrustRef trust; __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); - SecTrustResultType result; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); - +#pragma clang diagnostic pop [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; _out: @@ -158,17 +165,6 @@ + (NSSet *)certificatesInBundle:(NSBundle *)bundle { return [NSSet setWithSet:certificates]; } -+ (NSSet *)defaultPinnedCertificates { - static NSSet *_defaultPinnedCertificates = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - _defaultPinnedCertificates = [self certificatesInBundle:bundle]; - }); - - return _defaultPinnedCertificates; -} - + (instancetype)defaultPolicy { AFSecurityPolicy *securityPolicy = [[self alloc] init]; securityPolicy.SSLPinningMode = AFSSLPinningModeNone; @@ -177,7 +173,8 @@ + (instancetype)defaultPolicy { } + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { - return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]]; + NSSet *defaultPinnedCertificates = [self certificatesInBundle:[NSBundle mainBundle]]; + return [self policyWithPinningMode:pinningMode withPinnedCertificates:defaultPinnedCertificates]; } + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates { @@ -247,14 +244,11 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust if (self.SSLPinningMode == AFSSLPinningModeNone) { return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); - } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + } else if (!self.allowInvalidCertificates && !AFServerTrustIsValid(serverTrust)) { return NO; } switch (self.SSLPinningMode) { - case AFSSLPinningModeNone: - default: - return NO; case AFSSLPinningModeCertificate: { NSMutableArray *pinnedCertificates = [NSMutableArray array]; for (NSData *certificateData in self.pinnedCertificates) { @@ -290,6 +284,9 @@ - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust } return trustedPublicKeyCount > 0; } + + default: + return NO; } return NO; @@ -317,7 +314,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue]; self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))]; - self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; return self; } diff --git a/AFNetworking/AFURLRequestSerialization.m b/AFNetworking/AFURLRequestSerialization.m index a4d5d9dfee..f60b6f9d8a 100644 --- a/AFNetworking/AFURLRequestSerialization.m +++ b/AFNetworking/AFURLRequestSerialization.m @@ -217,12 +217,13 @@ - (instancetype)init { }]; [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 NSString *userAgent = nil; #if TARGET_OS_IOS - // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_TV + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; tvOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; #elif TARGET_OS_WATCH - // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; @@ -312,7 +313,7 @@ - (NSDictionary *)HTTPRequestHeaders { - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { - dispatch_barrier_async(self.requestHeaderModificationQueue, ^{ + dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{ [self.mutableHTTPRequestHeaders setValue:value forKey:field]; }); } @@ -334,7 +335,7 @@ - (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username } - (void)clearAuthorizationHeader { - dispatch_barrier_async(self.requestHeaderModificationQueue, ^{ + dispatch_barrier_sync(self.requestHeaderModificationQueue, ^{ [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; }); } @@ -571,7 +572,7 @@ - (void)encodeWithCoder:(NSCoder *)coder { dispatch_sync(self.requestHeaderModificationQueue, ^{ [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; }); - [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; + [coder encodeObject:@(self.queryStringSerializationStyle) forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; } #pragma mark - NSCopying @@ -1295,7 +1296,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; + [coder encodeObject:@(self.writingOptions) forKey:NSStringFromSelector(@selector(writingOptions))]; } #pragma mark - NSCopying @@ -1381,7 +1382,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { - (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder:coder]; - [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; } diff --git a/AFNetworking/AFURLResponseSerialization.h b/AFNetworking/AFURLResponseSerialization.h index 24800a3866..56a4d28ae1 100644 --- a/AFNetworking/AFURLResponseSerialization.h +++ b/AFNetworking/AFURLResponseSerialization.h @@ -24,6 +24,11 @@ NS_ASSUME_NONNULL_BEGIN +/** + Recursively removes `NSNull` values from a JSON object. +*/ +FOUNDATION_EXPORT id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions); + /** The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. @@ -57,8 +62,6 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init; -@property (nonatomic, assign) NSStringEncoding stringEncoding DEPRECATED_MSG_ATTRIBUTE("The string encoding is never used. AFHTTPResponseSerializer only validates status codes and content types but does not try to decode the received data in any way."); - /** Creates and returns a serializer with default configuration. */ diff --git a/AFNetworking/AFURLResponseSerialization.m b/AFNetworking/AFURLResponseSerialization.m index b7be3d403c..2715a1b319 100755 --- a/AFNetworking/AFURLResponseSerialization.m +++ b/AFNetworking/AFURLResponseSerialization.m @@ -60,11 +60,13 @@ static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger co return NO; } -static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { +id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { if ([JSONObject isKindOfClass:[NSArray class]]) { NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; for (id value in (NSArray *)JSONObject) { - [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + if (![value isEqual:[NSNull null]]) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } } return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; @@ -112,7 +114,7 @@ - (BOOL)validateResponse:(NSHTTPURLResponse *)response BOOL responseIsValid = YES; NSError *validationError = nil; - if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]] && !([response MIMEType] == nil && [data length] == 0)) { @@ -180,7 +182,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { } self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; - self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; return self; } @@ -269,6 +271,10 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding ++ (BOOL)supportsSecureCoding { + return YES; +} + - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { @@ -486,6 +492,10 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding ++ (BOOL)supportsSecureCoding { + return YES; +} + - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { @@ -702,6 +712,10 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding ++ (BOOL)supportsSecureCoding { + return YES; +} + - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { @@ -788,13 +802,18 @@ - (id)responseObjectForResponse:(NSURLResponse *)response #pragma mark - NSSecureCoding ++ (BOOL)supportsSecureCoding { + return YES; +} + - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (!self) { return nil; } - self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + NSSet *classes = [NSSet setWithArray:@[[NSArray class], [AFHTTPResponseSerializer class]]]; + self.responseSerializers = [decoder decodeObjectOfClasses:classes forKey:NSStringFromSelector(@selector(responseSerializers))]; return self; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0548256f..ab25a7b612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,29 +1,108 @@ -#Change Log +# Change Log All notable changes to this project will be documented in this file. -`AFNetworking` adheres to [Semantic Versioning](http://semver.org/). +`AFNetworking` adheres to [Semantic Versioning](https://semver.org/). --- +## [4.0.0](https://github.com/AFNetworking/AFNetworking/releases/tag/4.0.0) (03/29/2020) +Released on Sunday, March 29, 2020. All issues associated with this milestone can be found using this [filter](https://github.com/AFNetworking/AFNetworking/milestone/16?closed=1). + +#### Added +* Notificate when a downloaded file has been moved successfully. + * Implemented by xingheng in [#4393](https://github.com/AFNetworking/AFNetworking/pull/4393). +* Specific error for certificate pinning failure. + * Implemented by 0xced in [#3425](https://github.com/AFNetworking/AFNetworking/pull/3425). +* `WKWebView` extensions. + * Implemented by tjanela in [#4439](https://github.com/AFNetworking/AFNetworking/pull/4439). +* Automatic location of certificates in the main bundle for certificate pinning. + * Implemented by 0xced in [#3752](https://github.com/AFNetworking/AFNetworking/pull/3752). +* User-Agent support for tvOS. + * Implemented by ghking in [#4014](https://github.com/AFNetworking/AFNetworking/pull/4014). +* Ability for `AFHTTPSessionManager` to recreate its underlying `NSURLSession`. + * Implemented by Kaspik in [#4256](https://github.com/AFNetworking/AFNetworking/pull/4256). +* Ability to set HTTP headers per request. + * Implemented by stnslw in [#4113](https://github.com/AFNetworking/AFNetworking/pull/4113). +* Ability to capture `NSURLSessionTaskMetrics`. + * Implemented by Caelink in [#4237](https://github.com/AFNetworking/AFNetworking/pull/4237). + +#### Updated +* `dataTaskWithHTTPMethod` to be public. + * Implemented by smartinspereira in [#4007](https://github.com/AFNetworking/AFNetworking/pull/4007). +* Reachability notification to include the instance which issued the notification. + * Implemented by LMsgSendNilSelf in [#4051](https://github.com/AFNetworking/AFNetworking/pull/4051). +* `AFJSONObjectByRemovingKeysWithNullValues` to be public. + * Implemented by ashfurrow in [#4051](https://github.com/AFNetworking/AFNetworking/pull/4051). +* `AFJSONObjectByRemovingKeysWithNullValues` to remove `NSNull` values from `NSArray`s. + * Implemented by ashfurrow in [#4052](https://github.com/AFNetworking/AFNetworking/pull/4052). + +#### Changed +* Automated CI to GitHub Actions. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). + +#### Fixed +* Explicit `NSSecureCoding` support. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). +* Deprecated API usage on Catalyst. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). +* Nullability annotations. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). +* `AFImageDownloader` to more accurately cancel downloads. + * Implemented by kinarobin in [#4407](https://github.com/AFNetworking/AFNetworking/pull/4407). +* Double KVO notifications in `AFNetworkActivityManager`. + * Implemented by kinarobin in [#4406](https://github.com/AFNetworking/AFNetworking/pull/4406). +* Availability annotations around `NSURLSessionTaskMetrics`. + * Implemented by ElfSundae in [#4516](https://github.com/AFNetworking/AFNetworking/pull/4516). +* Issues with `associated_object` and subclasses. + * Implemented by welcommand in [#3872](https://github.com/AFNetworking/AFNetworking/pull/3872). +* Memory leak in example application. + * Implemented by svoit in [#4196](https://github.com/AFNetworking/AFNetworking/pull/4196). +* Crashes in mulithreaded scenarios and `dispatch_barrier`. + * Implemetned by streeter in [#4474](https://github.com/AFNetworking/AFNetworking/pull/4474). +* Issues with `NSSecureCoding`. + * Implemented by ElfSudae in [#4409](https://github.com/AFNetworking/AFNetworking/pull/4409). +* Code style issues. + * Implemented by svoit in [#4200](https://github.com/AFNetworking/AFNetworking/pull/4200). +* Race condition in `AFImageDownloader`. + * Implemented by bbeversdorf in [#4246](https://github.com/AFNetworking/AFNetworking/pull/4246). +* Coding style issues. + * Implemented by LeeHongHwa in [#4002](https://github.com/AFNetworking/AFNetworking/pull/4002). + +#### Removed +* Support for iOS < 9, macOS < 10.10. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). +* All previously deprecated APIs. + * Implemented by jshier in [#4523](https://github.com/AFNetworking/AFNetworking/pull/4523). +* Unnecessary `__block` capture. + * Implemented by kinarobin in [#4526](https://github.com/AFNetworking/AFNetworking/pull/4526). +* Workaround for `NSURLSessionUploadTask` creation on iOS 7. + * Implemented by kinarobin in [#4525](https://github.com/AFNetworking/AFNetworking/pull/4525). +* Workaround for safe `NSURLSessionTask` creation on iOS < 8. + * Implemented by kinarobin in [#4401](https://github.com/AFNetworking/AFNetworking/pull/4401). +* `UIWebView` extensions. + * Implemented by tjanela in [#4439](https://github.com/AFNetworking/AFNetworking/pull/4439). + +--- + ## [3.2.1](https://github.com/AFNetworking/AFNetworking/releases/tag/3.2.1) (05/04/2018) Released on Friday, May 04, 2018. All issues associated with this milestone can be found using this [filter](https://github.com/AFNetworking/AFNetworking/issues?q=milestone%3A3.2.1+is%3Aclosed). #### Updated * Xcode 9.3 Support - * Implemented by Jeff Kelley in [#4199](https://github.com/AFNetworking/AFNetworking/pull/4199). + * Implemented by Jeff Kelley in [#4199](https://github.com/AFNetworking/AFNetworking/pull/4199). * Update HTTPBin certificates for April 2018. - * Implemented by Jeff Kelley in [#4198](https://github.com/AFNetworking/AFNetworking/pull/4198). + * Implemented by Jeff Kelley in [#4198](https://github.com/AFNetworking/AFNetworking/pull/4198). #### Additional Changes * Remove conflicting nullable specifier on init - * Implemented by Nick Brook and Jeff Kelley in [#4182](https://github.com/AFNetworking/AFNetworking/pull/4182). + * Implemented by Nick Brook and Jeff Kelley in [#4182](https://github.com/AFNetworking/AFNetworking/pull/4182). * Use @available if available to silence a warning. - * Implemented by Jeff Kelley in [#4138](https://github.com/AFNetworking/AFNetworking/pull/4138). + * Implemented by Jeff Kelley in [#4138](https://github.com/AFNetworking/AFNetworking/pull/4138). * UIImageView+AFNetworking: Prevent stuck state for malformed urlRequest - * Implemented by Adam Duflo and aduflo in [#4131](https://github.com/AFNetworking/AFNetworking/pull/4131). + * Implemented by Adam Duflo and aduflo in [#4131](https://github.com/AFNetworking/AFNetworking/pull/4131). * add the link for LICENSE - * Implemented by Liao Malin in [#4125](https://github.com/AFNetworking/AFNetworking/pull/4125). + * Implemented by Liao Malin in [#4125](https://github.com/AFNetworking/AFNetworking/pull/4125). * Fix analyzer warning for upload task creation - * Implemented by Jeff Kelley in [#4122](https://github.com/AFNetworking/AFNetworking/pull/4122). + * Implemented by Jeff Kelley in [#4122](https://github.com/AFNetworking/AFNetworking/pull/4122). ## [3.2.0](https://github.com/AFNetworking/AFNetworking/releases/tag/3.2.0) (12/15/2017) diff --git a/CONTRIBUTING_CH.md b/CONTRIBUTING_CH.md new file mode 100644 index 0000000000..165da75a47 --- /dev/null +++ b/CONTRIBUTING_CH.md @@ -0,0 +1,97 @@ +# 贡献指南 +本文档包含有关为此项目做出贡献的信息和指南。 +请在开始参加之前阅读。 + +**主题** + +* [提问](#提问) +* [报告安全问题](#报告安全问题) +* [报告其他问题](#报告其他问题) +* [提交拉取请求](#提交拉取请求) +* [开发人员原产地证书](#开发人员原产地证书-1.1) +* [行为守则](#行为守则) + +## 提问 + +我们不使用GitHub的论坛发表问题 +对于任何非特定于项目本身的使用问题, +请直接在[Stack Overflow](https://stackoverflow.com)上询问。 +通过此方法,你可以快速解决您的问题, +并且任何有相同问题的人可以找到答案。 +这也使维护人员能够专注于为其他人改进项目。 + +## 报告安全问题 + +Alamofire Software Foundation 认真对待安全问题。 +如果您发现任何关于安全的问题,请立即通知我们! + +请**不要**公然公开发布问题, +而是将您的问题私下发送到。 +这将有于帮助确保发现的任何漏洞 +可以[披露制度](http://en.wikipedia.org/wiki/Responsible_disclosure) +对任何受影响的各方 + +## 报告其他问题 + +为此项目贡献的方法 +是当遇到问题时,请发送一篇详细的错误报告。 +我们会感谢您写出的一份精心编写的详尽错误报告。 + +在提交问题之前,请检查项目里的问题数据库是否已存在此问题。 +如果您找到匹配项,请添加“+1”或“我也遇到此问题”。 +这样做有助于确定最常见问题和请求的优先级。 + +报告问题时,请包含以下内容: + +* 您正在使用的Xcode版本 +* 您的iOS或OS X版本 +* 任何堆栈轨迹或编译器错误的完整输出 +* 如果代码段可再现所描述的行为 +* 任何其他有助于理解问题的细节 + +此信息有助于我们更快地查看和修复您的问题。 + +## 提交拉取请求 + +大力鼓励和欢迎拉取请求。在提交拉取请求时,请创建适当的测试用例,说明修复的问题或新功能。 + +## 开发人员原产地证书 1.1 + +为了项目做出贡献,我保证: + +- (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +- (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +- (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +- (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. + +## 行为守则 + +该项目采取贡献者公约为准则。 + +这项目的成果将会被我们的行为或行动影响。 + +我们期望每个为此项目做出贡献的人都会对此表示敬意。 + +详情请阅读 [CONDUCT.md](https://github.com/Alamofire/Foundation/blob/master/CONDUCT.md)。 + +---- + +*上述陈述的一些想法和措辞是基于 [Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) 和 [Linux](http://elinux.org/Developer_Certificate_Of_Origin) 社区. +我们表彰和感激他们为促进项目合作所做的付出。* diff --git a/Example/AFNetworking Example.xcodeproj/project.pbxproj b/Example/AFNetworking Example.xcodeproj/project.pbxproj index cc24acfc15..5ccf69afb5 100644 --- a/Example/AFNetworking Example.xcodeproj/project.pbxproj +++ b/Example/AFNetworking Example.xcodeproj/project.pbxproj @@ -525,7 +525,7 @@ }; buildConfigurationList = 29E6F16E1BB9DA2E00A4466C /* Build configuration list for PBXProject "AFNetworking Example" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -928,7 +928,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "macOS Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.macOS-Example"; @@ -972,7 +972,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; INFOPLIST_FILE = "macOS Example/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.10; + MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.alamofire.macOS-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1027,7 +1027,7 @@ SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -1072,7 +1072,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OBJC_BRIDGING_HEADER = "$(PROJECT_DIR)/tvOS Example/AFNetworking tvOS Example-Bridging-Header.h"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; diff --git a/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme b/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme index 60733acde5..af3dda85cd 100644 --- a/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme +++ b/Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES" + enableThreadSanitizer = "YES" + enableUBSanitizer = "YES"> + + + + + + + + @@ -53,17 +71,6 @@ - - - - - - - - + + + + @@ -68,23 +77,13 @@ - - - - - - - - + + + + @@ -53,22 +62,13 @@ - - - - - - + + + + + + @@ -53,22 +62,13 @@ - - - - - - + + - - - - + + - - - - + + - + - + @@ -160,33 +160,32 @@ - + - - + + - + - + - + - - + + - + - @@ -194,11 +193,11 @@ - + - + @@ -223,14 +222,12 @@ - + - - - + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad mi. @@ -241,15 +238,14 @@ - - + - - - + + + @@ -264,23 +260,24 @@ - - - - - + + + + + diff --git a/Example/tvOS Example/AppDelegate.swift b/Example/tvOS Example/AppDelegate.swift index 5284177596..10587662eb 100644 --- a/Example/tvOS Example/AppDelegate.swift +++ b/Example/tvOS Example/AppDelegate.swift @@ -27,7 +27,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/Example/tvOS Example/Gravatar.swift b/Example/tvOS Example/Gravatar.swift index 635c77f1ce..4b5304b14a 100644 --- a/Example/tvOS Example/Gravatar.swift +++ b/Example/tvOS Example/Gravatar.swift @@ -39,7 +39,7 @@ private extension String { hash += String(format: "%02x", result[i]) } - result.deallocate(capacity: digestLength) + result.deallocate() return String(format: hash) } diff --git a/Framework/AFNetworking.h b/Framework/AFNetworking.h index b8edcfdecd..65f3fcf823 100644 --- a/Framework/AFNetworking.h +++ b/Framework/AFNetworking.h @@ -52,7 +52,6 @@ FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; #import #import #import -#import #import #import #endif @@ -60,7 +59,7 @@ FOUNDATION_EXPORT const unsigned char AFNetworkingVersionString[]; #if TARGET_OS_IOS #import #import -#import +#import #endif diff --git a/Framework/Info.plist b/Framework/Info.plist index 3a389bb15d..36e428553d 100644 --- a/Framework/Info.plist +++ b/Framework/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.1.0 + $(MARKETING_VERSION) CFBundleSignature ???? CFBundleVersion - 3.2.1 + $(MARKETING_VERSION) NSPrincipalClass diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..a43c93aa2f --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "fastlane" +gem "cocoapods" +gem "xcode-install" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..70dc844f2a --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,248 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.2) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.1) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + aws-eventstream (1.0.3) + aws-partitions (1.290.0) + aws-sdk-core (3.92.0) + aws-eventstream (~> 1.0, >= 1.0.2) + aws-partitions (~> 1, >= 1.239.0) + aws-sigv4 (~> 1.1) + jmespath (~> 1.0) + aws-sdk-kms (1.30.0) + aws-sdk-core (~> 3, >= 3.71.0) + aws-sigv4 (~> 1.1) + aws-sdk-s3 (1.61.1) + aws-sdk-core (~> 3, >= 3.83.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.1) + aws-sigv4 (1.1.1) + aws-eventstream (~> 1.0, >= 1.0.2) + babosa (1.0.3) + claide (1.0.3) + cocoapods (1.9.1) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.9.1) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.6.6) + nap (~> 1.0) + ruby-macho (~> 1.4) + xcodeproj (>= 1.14.0, < 2.0) + cocoapods-core (1.9.1) + activesupport (>= 4.0.2, < 6) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.3.0) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.4.1) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.1.0) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + concurrent-ruby (1.1.6) + declarative (0.0.10) + declarative-option (0.1.0) + digest-crc (0.5.1) + domain_name (0.5.20190701) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.5) + emoji_regex (1.0.1) + escape (0.0.4) + ethon (0.12.0) + ffi (>= 1.3.0) + excon (0.73.0) + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.7) + fastlane (2.144.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + aws-sdk-s3 (~> 1.0) + babosa (>= 1.0.2, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 2.0) + excon (>= 0.71.0, < 1.0.0) + faraday (~> 0.17) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.13.1) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.29.2, < 0.37.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + jwt (~> 2.1.0) + mini_magick (>= 4.9.4, < 5.0.0) + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) + rubyzip (>= 1.3.0, < 2.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.13.0, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + ffi (1.12.2) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + google-api-client (0.36.4) + addressable (~> 2.5, >= 2.5.1) + googleauth (~> 0.9) + httpclient (>= 2.8.1, < 3.0) + mini_mime (~> 1.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.12) + google-cloud-core (1.5.0) + google-cloud-env (~> 1.0) + google-cloud-errors (~> 1.0) + google-cloud-env (1.3.1) + faraday (>= 0.17.3, < 2.0) + google-cloud-errors (1.0.0) + google-cloud-storage (1.25.1) + addressable (~> 2.5) + digest-crc (~> 0.4) + google-api-client (~> 0.33) + google-cloud-core (~> 1.2) + googleauth (~> 0.9) + mini_mime (~> 1.0) + googleauth (0.11.0) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.12) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + jmespath (1.4.0) + json (2.3.0) + jwt (2.1.0) + memoist (0.16.2) + mini_magick (4.10.1) + mini_mime (1.0.2) + minitest (5.14.0) + molinillo (0.6.6) + multi_json (1.14.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nanaimo (0.2.6) + nap (1.1.0) + naturally (2.2.0) + netrc (0.11.0) + os (1.0.1) + plist (3.5.0) + public_suffix (2.0.5) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + ruby-macho (1.4.0) + rubyzip (1.3.0) + security (0.1.3) + signet (0.13.2) + addressable (~> 2.3) + faraday (>= 0.17.3, < 2.0) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.8) + CFPropertyList + naturally + slack-notifier (2.3.2) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thread_safe (0.3.6) + tty-cursor (0.7.1) + tty-screen (0.7.1) + tty-spinner (0.9.3) + tty-cursor (~> 0.7) + typhoeus (1.3.1) + ethon (>= 0.9.0) + tzinfo (1.2.6) + thread_safe (~> 0.1) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.6) + unicode-display_width (1.7.0) + word_wrap (1.0.0) + xcode-install (2.6.3) + claide (>= 0.9.1, < 1.1.0) + fastlane (>= 2.1.0, < 3.0.0) + xcodeproj (1.15.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods + fastlane + xcode-install + +BUNDLED WITH + 2.1.2 diff --git a/LICENSE b/LICENSE index d7076267c4..f611f42f35 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2016 Alamofire Software Foundation (http://alamofire.org/) +Copyright (c) 2011-2020 Alamofire Software Foundation (http://alamofire.org/) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000000..fe6e38db65 --- /dev/null +++ b/Package.swift @@ -0,0 +1,37 @@ +// swift-tools-version:5.0 +// +// Package.swift +// +// Copyright (c) 2020 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import PackageDescription + +let package = Package(name: "AFNetworking", + platforms: [.macOS(.v10_10), + .iOS(.v9), + .tvOS(.v9), + .watchOS(.v2)], + products: [.library(name: "AFNetworking", + targets: ["AFNetworking"])], + targets: [.target(name: "AFNetworking", + path: "AFNetworking", + publicHeadersPath: "AFNetworking")]) diff --git a/README.md b/README.md index 6a7d2cd119..d193dfe8d1 100644 --- a/README.md +++ b/README.md @@ -2,25 +2,20 @@ AFNetworking

-[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) -[![codecov.io](https://codecov.io/github/AFNetworking/AFNetworking/coverage.svg?branch=master)](https://codecov.io/github/AFNetworking/AFNetworking?branch=master) +[![Build Status](https://github.com/AFNetworking/AFNetworking/workflows/AFNetworking%20CI/badge.svg?branch=master)](https://github.com/AFNetworking/AFNetworking/actions) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/AFNetworking.svg)](https://img.shields.io/cocoapods/v/AFNetworking.svg) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Platform](https://img.shields.io/cocoapods/p/AFNetworking.svg?style=flat)](http://cocoadocs.org/docsets/AFNetworking) [![Twitter](https://img.shields.io/badge/twitter-@AFNetworking-blue.svg?style=flat)](http://twitter.com/AFNetworking) -AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. +AFNetworking is a delightful networking library for iOS, macOS, watchOS, and tvOS. It's built on top of the [Foundation URL Loading System](https://developer.apple.com/documentation/foundation/url_loading_system), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. -Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! - ## How To Get Started - [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps - Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) -- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking -- Read the [AFNetworking 3.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-3.0-Migration-Guide) for an overview of the architectural changes from 2.0. ## Communication @@ -35,56 +30,37 @@ AFNetworking supports multiple methods for installing the library in a project. ## Installation with CocoaPods -[CocoaPods](http://cocoapods.org) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). You can install it with the following command: - -```bash -$ gem install cocoapods -``` - -> CocoaPods 0.39.0+ is required to build AFNetworking 3.0.0+. - -#### Podfile - To integrate AFNetworking into your Xcode project using CocoaPods, specify it in your `Podfile`: ```ruby -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '8.0' - -target 'TargetName' do -pod 'AFNetworking', '~> 3.0' -end +pod 'AFNetworking', '~> 4.0' ``` -Then, run the following command: +### Installation with Swift Package Manager -```bash -$ pod install -``` - -### Installation with Carthage +Once you have your Swift package set up, adding AFNetworking as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. -[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. +```swift +dependencies: [ + .package(url: "https://github.com/AFNetworking/AFNetworking.git", .upToNextMajor(from: "4.0.0")) +] +``` -You can install Carthage with [Homebrew](http://brew.sh/) using the following command: +> Note: AFNetworking's Swift package does not include it's UIKit extensions. -```bash -$ brew update -$ brew install carthage -``` +### Installation with Carthage -To integrate AFNetworking into your Xcode project using Carthage, specify it in your `Cartfile`: +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AFNetworking, add the following to your `Cartfile`. ```ogdl -github "AFNetworking/AFNetworking" ~> 3.0 +github "AFNetworking/AFNetworking" ~> 4.0 ``` -Run `carthage` to build the framework and drag the built `AFNetworking.framework` into your Xcode project. - ## Requirements | AFNetworking Version | Minimum iOS Target | Minimum macOS Target | Minimum watchOS Target | Minimum tvOS Target | Notes | |:--------------------:|:---------------------------:|:----------------------------:|:----------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 4.x | iOS 9 | macOS 10.10 | watchOS 2.0 | tvOS 9.0 | Xcode 11+ is required. | | 3.x | iOS 7 | OS X 10.9 | watchOS 2.0 | tvOS 9.0 | Xcode 7+ is required. `NSURLConnectionOperation` support has been removed. | | 2.6 -> 2.6.3 | iOS 7 | OS X 10.9 | watchOS 2.0 | n/a | Xcode 7+ is required. | | 2.0 -> 2.5.4 | iOS 6 | OS X 10.8 | n/a | n/a | Xcode 5+ is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | diff --git a/Tests/Info.plist b/Tests/Info.plist index 32379bec19..169b6f710e 100644 --- a/Tests/Info.plist +++ b/Tests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier - com.alamofire.afnetworking.${PRODUCT_NAME:rfc1034identifier} + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType diff --git a/Tests/Resources/HTTPBin.org/Amazon Root CA 1.cer b/Tests/Resources/HTTPBin.org/Amazon Root CA 1.cer new file mode 100644 index 0000000000..1dfb0e70fa Binary files /dev/null and b/Tests/Resources/HTTPBin.org/Amazon Root CA 1.cer differ diff --git a/Tests/Resources/HTTPBin.org/Amazon.cer b/Tests/Resources/HTTPBin.org/Amazon.cer new file mode 100644 index 0000000000..93f1fb0c6b Binary files /dev/null and b/Tests/Resources/HTTPBin.org/Amazon.cer differ diff --git a/Tests/Resources/HTTPBin.org/DST Root CA X3.cer b/Tests/Resources/HTTPBin.org/DST Root CA X3.cer deleted file mode 100644 index 95500f6bd1..0000000000 Binary files a/Tests/Resources/HTTPBin.org/DST Root CA X3.cer and /dev/null differ diff --git a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer index 5bf6e8058a..8ba123fbcf 100644 Binary files a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer and b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_0.cer differ diff --git a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer index e08466c5a7..93f1fb0c6b 100644 Binary files a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer and b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_1.cer differ diff --git a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer index 95500f6bd1..1dfb0e70fa 100644 Binary files a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer and b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_2.cer differ diff --git a/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_3.cer b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_3.cer new file mode 100644 index 0000000000..75df0cc7c0 Binary files /dev/null and b/Tests/Resources/HTTPBin.org/HTTPBinOrgServerTrustChain/httpbin_3.cer differ diff --git a/Tests/Resources/HTTPBin.org/Let's Encrypt Authority X3.cer b/Tests/Resources/HTTPBin.org/Let's Encrypt Authority X3.cer deleted file mode 100644 index e08466c5a7..0000000000 Binary files a/Tests/Resources/HTTPBin.org/Let's Encrypt Authority X3.cer and /dev/null differ diff --git a/Tests/Resources/HTTPBin.org/Starfield Services Root Certificate Authority - G2.cer b/Tests/Resources/HTTPBin.org/Starfield Services Root Certificate Authority - G2.cer new file mode 100644 index 0000000000..75df0cc7c0 Binary files /dev/null and b/Tests/Resources/HTTPBin.org/Starfield Services Root Certificate Authority - G2.cer differ diff --git a/Tests/Resources/HTTPBin.org/httpbinorg_02182021.cer b/Tests/Resources/HTTPBin.org/httpbinorg_02182021.cer new file mode 100644 index 0000000000..8ba123fbcf Binary files /dev/null and b/Tests/Resources/HTTPBin.org/httpbinorg_02182021.cer differ diff --git a/Tests/Resources/HTTPBin.org/httpbinorg_06102018.cer b/Tests/Resources/HTTPBin.org/httpbinorg_06102018.cer deleted file mode 100644 index 5bf6e8058a..0000000000 Binary files a/Tests/Resources/HTTPBin.org/httpbinorg_06102018.cer and /dev/null differ diff --git a/Tests/Tests/AFAutoPurgingImageCacheTests.m b/Tests/Tests/AFAutoPurgingImageCacheTests.m index d5e3224763..2e2b83f954 100644 --- a/Tests/Tests/AFAutoPurgingImageCacheTests.m +++ b/Tests/Tests/AFAutoPurgingImageCacheTests.m @@ -211,7 +211,7 @@ - (void)testThatPrioritizedImagesWithOldestLastAccessDatesAreRemovedDuringPurge [self.cache addImage:self.testImage withIdentifier:identifier]; } - NSString * firstIdentifier = [NSString stringWithFormat:@"image-%ld",(long)0]; + NSString *firstIdentifier = [NSString stringWithFormat:@"image-%ld",(long)0]; UIImage *firstImage = [self.cache imageWithIdentifier:firstIdentifier]; XCTAssertNotNil(firstImage, @"first image should not be nil"); UInt64 prePurgeMemoryUsage = self.cache.memoryUsage; @@ -219,7 +219,7 @@ - (void)testThatPrioritizedImagesWithOldestLastAccessDatesAreRemovedDuringPurge UInt64 postPurgeMemoryUsage = self.cache.memoryUsage; XCTAssertTrue(postPurgeMemoryUsage < prePurgeMemoryUsage); - for (NSUInteger index = 0; index <= numberOfImages ; index++) { + for (NSUInteger index = 0; index <= numberOfImages; index++) { NSString * identifier = [NSString stringWithFormat:@"image-%ld",(long)index]; UIImage *cachedImage = [self.cache imageWithIdentifier:identifier]; if (index == 0 || index >= 6) { diff --git a/Tests/Tests/AFCompoundResponseSerializerTests.m b/Tests/Tests/AFCompoundResponseSerializerTests.m index 2ec32887b2..894158f3ea 100644 --- a/Tests/Tests/AFCompoundResponseSerializerTests.m +++ b/Tests/Tests/AFCompoundResponseSerializerTests.m @@ -71,8 +71,8 @@ - (void)testCompoundSerializerCanBeCopied { XCTAssertNotNil(copiedSerializer); XCTAssertNotEqual(compoundSerializer, copiedSerializer); XCTAssertTrue(compoundSerializer.responseSerializers.count == copiedSerializer.responseSerializers.count); - XCTAssertTrue([NSStringFromClass([[copiedSerializer.responseSerializers objectAtIndex:0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]); - XCTAssertTrue([NSStringFromClass([[copiedSerializer.responseSerializers objectAtIndex:1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]); + XCTAssertTrue([NSStringFromClass([copiedSerializer.responseSerializers[0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]); + XCTAssertTrue([NSStringFromClass([copiedSerializer.responseSerializers[1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]); XCTAssertEqual(compoundSerializer.acceptableStatusCodes, copiedSerializer.acceptableStatusCodes); XCTAssertEqual(compoundSerializer.acceptableContentTypes, copiedSerializer.acceptableContentTypes); } @@ -81,14 +81,14 @@ - (void)testCompoundSerializerCanBeArchivedAndUnarchived { AFImageResponseSerializer *imageSerializer = [AFImageResponseSerializer serializer]; AFJSONResponseSerializer *jsonSerializer = [AFJSONResponseSerializer serializer]; AFCompoundResponseSerializer *compoundSerializer = [AFCompoundResponseSerializer compoundSerializerWithResponseSerializers:@[imageSerializer, jsonSerializer]]; - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:compoundSerializer]; + NSData *data = [self archivedDataWithRootObject:compoundSerializer]; XCTAssertNotNil(data); - AFCompoundResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + AFCompoundResponseSerializer *unarchivedSerializer = [self unarchivedObjectOfClass:[AFCompoundResponseSerializer class] fromData:data]; XCTAssertNotNil(unarchivedSerializer); XCTAssertNotEqual(unarchivedSerializer, compoundSerializer); XCTAssertTrue(compoundSerializer.responseSerializers.count == compoundSerializer.responseSerializers.count); - XCTAssertTrue([NSStringFromClass([[unarchivedSerializer.responseSerializers objectAtIndex:0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]); - XCTAssertTrue([NSStringFromClass([[unarchivedSerializer.responseSerializers objectAtIndex:1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]); + XCTAssertTrue([NSStringFromClass([unarchivedSerializer.responseSerializers[0] class]) isEqualToString:NSStringFromClass([AFImageResponseSerializer class])]); + XCTAssertTrue([NSStringFromClass([unarchivedSerializer.responseSerializers[1] class]) isEqualToString:NSStringFromClass([AFJSONResponseSerializer class])]); } @end diff --git a/Tests/Tests/AFHTTPSessionManagerTests.m b/Tests/Tests/AFHTTPSessionManagerTests.m index 6fbbdf2b5d..a6c7b1b2f2 100644 --- a/Tests/Tests/AFHTTPSessionManagerTests.m +++ b/Tests/Tests/AFHTTPSessionManagerTests.m @@ -25,24 +25,25 @@ #import "AFSecurityPolicy.h" @interface AFHTTPSessionManagerTests : AFTestCase -@property (readwrite, nonatomic, strong) AFHTTPSessionManager *manager; +@property (readwrite, nonatomic, strong) AFHTTPSessionManager *sessionManager; @end @implementation AFHTTPSessionManagerTests - (void)setUp { [super setUp]; - self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:self.baseURL]; + self.sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:self.baseURL]; } - (void)tearDown { - [self.manager invalidateSessionCancelingTasks:YES]; + [self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO]; + self.sessionManager = nil; [super tearDown]; } #pragma mark - init -- (void)testSharedManagerIsNotEqualToInitdManager { - XCTAssertFalse([[AFHTTPSessionManager manager] isEqual:self.manager]); +- (void)testSharedManagerIsNotEqualToInitedManager { + XCTAssertFalse([[AFHTTPSessionManager manager] isEqual:self.sessionManager]); } #pragma mark - misc @@ -54,7 +55,7 @@ - (void)testThatOperationInvokesCompletionHandlerWithResponseObjectOnSuccess { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/get" relativeToURL:self.baseURL]]; - NSURLSessionDataTask *task = [self.manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil + NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { blockResponseObject = responseObject; blockError = error; @@ -76,7 +77,7 @@ - (void)testThatOperationInvokesFailureCompletionBlockWithErrorOnFailure { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/status/404" relativeToURL:self.baseURL]]; - NSURLSessionDataTask *task = [self.manager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil + NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { blockError = error; [expectation fulfill]; @@ -97,13 +98,13 @@ - (void)testThatRedirectBlockIsCalledWhen302IsEncountered { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; NSURLRequest *redirectRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"/redirect/1" relativeToURL:self.baseURL]]; - NSURLSessionDataTask *redirectTask = [self.manager dataTaskWithRequest:redirectRequest uploadProgress:nil downloadProgress:nil + NSURLSessionDataTask *redirectTask = [self.sessionManager dataTaskWithRequest:redirectRequest uploadProgress:nil downloadProgress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { blockError = error; [expectation fulfill]; }]; - [self.manager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest *(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request) { + [self.sessionManager setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest *(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request) { if (response) { success = YES; } @@ -126,14 +127,14 @@ - (void)testDownloadFileCompletionSpecifiesURLInCompletionWithManagerDidFinishBl __block NSURL *downloadFilePath = nil; XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager setDownloadTaskDidFinishDownloadingBlock:^NSURL *(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location) { + [self.sessionManager setDownloadTaskDidFinishDownloadingBlock:^NSURL *(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location) { managerDownloadFinishedBlockExecuted = YES; NSURL *dirURL = [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; return [dirURL URLByAppendingPathComponent:@"t1.file"]; }]; NSURLSessionDownloadTask *downloadTask; - downloadTask = [self.manager + downloadTask = [self.sessionManager downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL] progress:nil destination:nil @@ -155,7 +156,7 @@ - (void)testDownloadFileCompletionSpecifiesURLInCompletionBlock { __block NSURL *downloadFilePath = nil; XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - NSURLSessionDownloadTask *downloadTask = [self.manager downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL] + NSURLSessionDownloadTask *downloadTask = [self.sessionManager downloadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL] progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { destinationBlockExecuted = YES; @@ -177,7 +178,7 @@ - (void)testDownloadFileCompletionSpecifiesURLInCompletionBlock { - (void)testThatSerializationErrorGeneratesErrorAndNullTaskForGET { XCTestExpectation *expectation = [self expectationWithDescription:@"Serialization should fail"]; - [self.manager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) { + [self.sessionManager.requestSerializer setQueryStringSerializationWithBlock:^NSString * _Nonnull(NSURLRequest * _Nonnull request, id _Nonnull parameters, NSError * _Nullable __autoreleasing * _Nullable error) { if (error != NULL) { *error = [NSError errorWithDomain:@"Custom" code:-1 userInfo:nil]; } @@ -185,9 +186,10 @@ - (void)testThatSerializationErrorGeneratesErrorAndNullTaskForGET { }]; NSURLSessionTask *nilTask; - nilTask = [self.manager + nilTask = [self.sessionManager GET:@"test" parameters:@{@"key":@"value"} + headers:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { @@ -205,13 +207,13 @@ - (void)testSupportsSecureCoding { } - (void)testCanBeEncoded { - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.manager]; + NSData *data = [self archivedDataWithRootObject:self.sessionManager]; XCTAssertNotNil(data); } - (void)testCanBeDecoded { - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.manager]; - AFHTTPSessionManager *newManager = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + NSData *data = [self archivedDataWithRootObject:self.sessionManager]; + AFHTTPSessionManager *newManager = [self unarchivedObjectOfClass:[AFHTTPSessionManager class] fromData:data];; XCTAssertNotNil(newManager.securityPolicy); XCTAssertNotNil(newManager.requestSerializer); XCTAssertNotNil(newManager.responseSerializer); @@ -223,7 +225,7 @@ - (void)testCanBeDecoded { #pragma mark - NSCopying - (void)testCanBeCopied { - AFHTTPSessionManager *copyManager = [self.manager copy]; + AFHTTPSessionManager *copyManager = [self.sessionManager copy]; XCTAssertNotNil(copyManager); } @@ -231,9 +233,10 @@ - (void)testCanBeCopied { - (void)testDownloadProgressIsReportedForGET { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"]; - [self.manager + [self.sessionManager GET:@"image" parameters:nil + headers:nil progress:^(NSProgress * _Nonnull downloadProgress) { if (downloadProgress.fractionCompleted == 1.0) { [expectation fulfill]; @@ -252,9 +255,10 @@ - (void)testUploadProgressIsReportedForPOST { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"]; - [self.manager + [self.sessionManager POST:@"post" parameters:payload + headers:nil progress:^(NSProgress * _Nonnull uploadProgress) { if (uploadProgress.fractionCompleted == 1.0) { [expectation fulfill]; @@ -273,9 +277,10 @@ - (void)testUploadProgressIsReportedForStreamingPost { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Progress Should equal 1.0"]; - [self.manager + [self.sessionManager POST:@"post" parameters:nil + headers:nil constructingBodyWithBlock:^(id _Nonnull formData) { [formData appendPartWithFileData:[payload dataUsingEncoding:NSUTF8StringEncoding] name:@"AFNetworking" fileName:@"AFNetworking" mimeType:@"text/html"]; } @@ -293,9 +298,10 @@ - (void)testUploadProgressIsReportedForStreamingPost { - (void)testThatSuccessBlockIsCalledFor200 { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager GET:@"status/200" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { [expectation fulfill]; @@ -306,9 +312,10 @@ - (void)testThatSuccessBlockIsCalledFor200 { - (void)testThatFailureBlockIsCalledFor404 { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager GET:@"status/404" parameters:nil + headers:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) { @@ -320,9 +327,10 @@ - (void)testThatFailureBlockIsCalledFor404 { - (void)testThatResponseObjectIsEmptyFor204 { __block id urlResponseObject = nil; XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager GET:@"status/204" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { urlResponseObject = responseObject; @@ -337,9 +345,10 @@ - (void)testThatResponseObjectIsEmptyFor204 { - (void)testGET { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager GET:@"get" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { XCTAssertNotNil(responseObject); @@ -351,9 +360,10 @@ - (void)testGET { - (void)testHEAD { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager HEAD:@"get" parameters:nil + headers:nil success:^(NSURLSessionDataTask * _Nonnull task) { XCTAssertNotNil(task); [expectation fulfill]; @@ -364,11 +374,13 @@ - (void)testHEAD { - (void)testPOST { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager POST:@"post" parameters:@{@"key":@"value"} + headers:@{@"field":@"value"} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]); XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); [expectation fulfill]; } @@ -378,9 +390,10 @@ - (void)testPOST { - (void)testPOSTWithConstructingBody { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager POST:@"post" parameters:@{@"key":@"value"} + headers:@{@"field":@"value"} constructingBodyWithBlock:^(id _Nonnull formData) { [formData appendPartWithFileData:[@"Data" dataUsingEncoding:NSUTF8StringEncoding] name:@"DataName" @@ -389,6 +402,7 @@ - (void)testPOSTWithConstructingBody { } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]); XCTAssertTrue([responseObject[@"files"][@"DataName"] isEqualToString:@"Data"]); XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); [expectation fulfill]; @@ -399,10 +413,12 @@ - (void)testPOSTWithConstructingBody { - (void)testPUT { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager PUT:@"put" parameters:@{@"key":@"value"} + headers:@{@"field":@"value"} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]); XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); [expectation fulfill]; } @@ -412,10 +428,12 @@ - (void)testPUT { - (void)testDELETE { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager DELETE:@"delete" parameters:@{@"key":@"value"} + headers:@{@"field":@"value"} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]); XCTAssertTrue([responseObject[@"args"][@"key"] isEqualToString:@"value"]); [expectation fulfill]; } @@ -425,10 +443,12 @@ - (void)testDELETE { - (void)testPATCH { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; - [self.manager + [self.sessionManager PATCH:@"patch" parameters:@{@"key":@"value"} + headers:@{@"field":@"value"} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + XCTAssertTrue([task.originalRequest.allHTTPHeaderFields[@"field"] isEqualToString:@"value"]); XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); [expectation fulfill]; } @@ -437,71 +457,15 @@ - (void)testPATCH { [self waitForExpectationsWithCommonTimeout]; } -#pragma mark - Deprecated Rest Interface - -- (void)testDeprecatedGET { - XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.manager - GET:@"get" - parameters:nil - success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - XCTAssertNotNil(responseObject); - [expectation fulfill]; - } - failure:nil]; -#pragma clang diagnostic pop - [self waitForExpectationsWithCommonTimeout]; -} - -- (void)testDeprecatedPOST { - XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.manager - POST:@"post" - parameters:@{@"key":@"value"} - success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); - [expectation fulfill]; - } - failure:nil]; -#pragma clang diagnostic pop - [self waitForExpectationsWithCommonTimeout]; -} - -- (void)testDeprecatedPOSTWithConstructingBody { - XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - [self.manager - POST:@"post" - parameters:@{@"key":@"value"} - constructingBodyWithBlock:^(id _Nonnull formData) { - [formData appendPartWithFileData:[@"Data" dataUsingEncoding:NSUTF8StringEncoding] - name:@"DataName" - fileName:@"DataFileName" - mimeType:@"data"]; - } - success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { - XCTAssertTrue([responseObject[@"files"][@"DataName"] isEqualToString:@"Data"]); - XCTAssertTrue([responseObject[@"form"][@"key"] isEqualToString:@"value"]); - [expectation fulfill]; - } - failure:nil]; -#pragma clang diagnostic pop - [self waitForExpectationsWithCommonTimeout]; -} - #pragma mark - Auth - (void)testHiddenBasicAuthentication { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should finish"]; - [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"password"]; - [self.manager + [self.sessionManager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"password"]; + [self.sessionManager GET:@"hidden-basic-auth/user/password" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { [expectation fulfill]; @@ -565,7 +529,7 @@ - (void)testInvalidPublicKeyPinningSecurityPolicyWithoutBaseURL { # pragma mark - Server Trust - (void)testInvalidServerTrustProducesCorrectErrorForCertificatePinning { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should fail"]; + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should fail with untrusted certificate error"]; NSURL *googleCertificateURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"google.com" withExtension:@"cer"]; NSData *googleCertificateData = [NSData dataWithContentsOfURL:googleCertificateURL]; AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:@"https://apple.com/"]]; @@ -574,6 +538,7 @@ - (void)testInvalidServerTrustProducesCorrectErrorForCertificatePinning { [manager GET:@"" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { XCTFail(@"Request should fail"); @@ -581,15 +546,16 @@ - (void)testInvalidServerTrustProducesCorrectErrorForCertificatePinning { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { XCTAssertEqualObjects(error.domain, NSURLErrorDomain); - XCTAssertEqual(error.code, NSURLErrorCancelled); + XCTAssertEqual(error.code, NSURLErrorServerCertificateUntrusted); + XCTAssertEqualObjects(error.localizedDescription, @"The certificate for this server is invalid. You might be connecting to a server that is pretending to be “apple.com” which could put your confidential information at risk."); [expectation fulfill]; }]; [self waitForExpectationsWithCommonTimeout]; - [manager invalidateSessionCancelingTasks:YES]; + [manager invalidateSessionCancelingTasks:YES resetSession:NO]; } - (void)testInvalidServerTrustProducesCorrectErrorForPublicKeyPinning { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should fail"]; + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request should fail with untrusted certificate error"]; NSURL *googleCertificateURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"google.com" withExtension:@"cer"]; NSData *googleCertificateData = [NSData dataWithContentsOfURL:googleCertificateURL]; AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:@"https://apple.com/"]]; @@ -598,6 +564,7 @@ - (void)testInvalidServerTrustProducesCorrectErrorForPublicKeyPinning { [manager GET:@"" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { XCTFail(@"Request should fail"); @@ -605,11 +572,38 @@ - (void)testInvalidServerTrustProducesCorrectErrorForPublicKeyPinning { } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { XCTAssertEqualObjects(error.domain, NSURLErrorDomain); - XCTAssertEqual(error.code, NSURLErrorCancelled); + XCTAssertEqual(error.code, NSURLErrorServerCertificateUntrusted); + XCTAssertEqualObjects(error.localizedDescription, @"The certificate for this server is invalid. You might be connecting to a server that is pretending to be “apple.com” which could put your confidential information at risk."); [expectation fulfill]; }]; [self waitForExpectationsWithCommonTimeout]; - [manager invalidateSessionCancelingTasks:YES]; + [manager invalidateSessionCancelingTasks:YES resetSession:NO]; +} + +# pragma mark - Custom Authentication Challenge Handler + +- (void)testAuthenticationChallengeHandlerCredentialResult { + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"Request succeed with provided credentials"]; + self.sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; + [self.sessionManager setAuthenticationChallengeHandler:^id _Nonnull(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLAuthenticationChallenge * _Nonnull challenge, void (^ _Nonnull completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable)) { + if ([challenge.protectionSpace.realm isEqualToString:@"Fake Realm"]) { + return [NSURLCredential credentialWithUser:@"user" password:@"passwd" persistence:NSURLCredentialPersistenceNone]; + } + return @(NSURLSessionAuthChallengePerformDefaultHandling); + }]; + [self.sessionManager + GET:@"basic-auth/user/passwd" + parameters:nil + headers:nil + progress:nil + success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + [expectation fulfill]; + } + failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + XCTFail(@"Request should succeed"); + [expectation fulfill]; + }]; + [self waitForExpectationsWithCommonTimeoutUsingHandler:nil]; } @end diff --git a/Tests/Tests/AFImageDownloaderTests.m b/Tests/Tests/AFImageDownloaderTests.m index 9a94b86683..7eee82e31c 100644 --- a/Tests/Tests/AFImageDownloaderTests.m +++ b/Tests/Tests/AFImageDownloaderTests.m @@ -45,7 +45,7 @@ - (void)setUp { } - (void)tearDown { - [self.downloader.sessionManager invalidateSessionCancelingTasks:YES]; + [self.downloader.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO]; self.downloader = nil; // Put teardown code here. This method is called after the invocation of each test method in the class. [super tearDown]; @@ -512,6 +512,27 @@ - (void)testThatItCanDownloadAndCancelAndDownloadAgain { [self waitForExpectationsWithCommonTimeout]; } +- (void)testThatCancelImageDownloadItShouldCancelImmediately { + [self.downloader.imageCache removeAllImages]; + + NSString *imageURLString = @"https://secure.gravatar.com/avatar/5a105e8b9d40e1329780d62ea2265d8a?d=identicon"; + AFImageDownloadReceipt *receipt = [self.downloader + downloadImageForURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:imageURLString]] + success:nil + failure:nil]; + [self.downloader cancelTaskForImageDownloadReceipt:receipt]; + + XCTestExpectation *expectation = [self expectationWithDescription:@"Image download should be cancelled immediately"]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + UIImage *cacheImage = [self.downloader.imageCache imageWithIdentifier:imageURLString]; + XCTAssertNil(cacheImage); + [expectation fulfill]; + }); + + [self waitForExpectationsWithCommonTimeout]; +} + + #pragma mark - Threading - (void)testThatItAlwaysCallsTheSuccessHandlerOnTheMainQueue { XCTestExpectation *expectation = [self expectationWithDescription:@"image download should succeed"]; @@ -561,7 +582,7 @@ - (void)testThatReceiptIDMatchesReturnedID { @implementation MockAFAutoPurgingImageCache --(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { +- (BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request withAdditionalIdentifier:(NSString *)identifier { if (self.shouldCache) { return self.shouldCache(image, request, identifier); } @@ -570,7 +591,7 @@ -(BOOL)shouldCacheImage:(UIImage *)image forRequest:(NSURLRequest *)request with } } --(void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{ +- (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier{ [super addImage:image withIdentifier:identifier]; if (self.addCache) { self.addCache(image, identifier); diff --git a/Tests/Tests/AFImageResponseSerializerTests.m b/Tests/Tests/AFImageResponseSerializerTests.m index b075041736..c65587c60f 100644 --- a/Tests/Tests/AFImageResponseSerializerTests.m +++ b/Tests/Tests/AFImageResponseSerializerTests.m @@ -56,11 +56,11 @@ - (void)testImageSerializerSupportsSecureCoding { - (void)testImageSerializerCanBeArchivedAndUnarchived { AFImageResponseSerializer *responseSerializer = [AFImageResponseSerializer serializer]; - NSData *archive = nil; + NSData *archive = nil; - archive = [NSKeyedArchiver archivedDataWithRootObject:responseSerializer]; + archive = [self archivedDataWithRootObject:responseSerializer]; XCTAssertNotNil(archive); - AFImageResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive]; + AFImageResponseSerializer *unarchivedSerializer = [self unarchivedObjectOfClass:[AFImageResponseSerializer class] fromData:archive]; XCTAssertNotNil(unarchivedSerializer); XCTAssertNotEqual(unarchivedSerializer, responseSerializer); XCTAssertTrue([unarchivedSerializer.acceptableContentTypes isEqualToSet:responseSerializer.acceptableContentTypes]); @@ -83,9 +83,9 @@ - (void)testImageSerializerCanBeArchivedAndUnarchivedWithNonDefaultPropertyValue responseSerializer.imageScale = responseSerializer.imageScale * 2.0f; #endif - archive = [NSKeyedArchiver archivedDataWithRootObject:responseSerializer]; + archive = [self archivedDataWithRootObject:responseSerializer]; XCTAssertNotNil(archive); - AFImageResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive]; + AFImageResponseSerializer *unarchivedSerializer = [self unarchivedObjectOfClass:[AFImageResponseSerializer class] fromData:archive]; XCTAssertNotNil(unarchivedSerializer); XCTAssertNotEqual(unarchivedSerializer, responseSerializer); diff --git a/Tests/Tests/AFJSONSerializationTests.m b/Tests/Tests/AFJSONSerializationTests.m index d1b15e97a5..e17b1932a3 100644 --- a/Tests/Tests/AFJSONSerializationTests.m +++ b/Tests/Tests/AFJSONSerializationTests.m @@ -177,7 +177,7 @@ - (void)testThatJSONResponseSerializerReturnsNilObjectAndNilErrorForSingleSpace - (void)testThatJSONRemovesKeysWithNullValues { self.responseSerializer.removesKeysWithNullValues = YES; NSHTTPURLResponse *response = [[NSHTTPURLResponse alloc] initWithURL:self.baseURL statusCode:200 HTTPVersion:@"1.1" headerFields:@{@"Content-Type":@"text/json"}]; - NSData *data = [NSJSONSerialization dataWithJSONObject:@{@"key":@"value",@"nullkey":[NSNull null],@"array":@[@{@"subnullkey":[NSNull null]}]} + NSData *data = [NSJSONSerialization dataWithJSONObject:@{@"key":@"value",@"nullkey":[NSNull null],@"array":@[@{@"subnullkey":[NSNull null]}], @"arrayWithNulls": @[[NSNull null]]} options:(NSJSONWritingOptions)0 error:nil]; @@ -189,6 +189,7 @@ - (void)testThatJSONRemovesKeysWithNullValues { XCTAssertNotNil(responseObject[@"key"]); XCTAssertNil(responseObject[@"nullkey"]); XCTAssertNil(responseObject[@"array"][0][@"subnullkey"]); + XCTAssertEqualObjects(responseObject[@"arrayWithNulls"], @[]); } - (void)testThatJSONResponseSerializerCanBeCopied { @@ -205,4 +206,23 @@ - (void)testThatJSONResponseSerializerCanBeCopied { XCTAssertEqual(copiedSerializer.removesKeysWithNullValues, self.responseSerializer.removesKeysWithNullValues); } +#pragma mark NSSecureCoding + +- (void)testJSONSerializerSupportsSecureCoding { + XCTAssertTrue([AFJSONResponseSerializer supportsSecureCoding]); +} + +- (void)testJSONSerializerCanBeArchivedAndUnarchived { + AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializer]; + NSData *archive = nil; + + archive = [self archivedDataWithRootObject:responseSerializer]; + XCTAssertNotNil(archive); + AFJSONResponseSerializer *unarchivedSerializer = [self unarchivedObjectOfClass:[AFJSONResponseSerializer class] fromData:archive]; + XCTAssertNotNil(unarchivedSerializer); + XCTAssertNotEqual(unarchivedSerializer, responseSerializer); + XCTAssertTrue([unarchivedSerializer.acceptableContentTypes isEqualToSet:responseSerializer.acceptableContentTypes]); + XCTAssertTrue([unarchivedSerializer.acceptableStatusCodes isEqualToIndexSet:responseSerializer.acceptableStatusCodes]); +} + @end diff --git a/Tests/Tests/AFNetworkActivityManagerTests.m b/Tests/Tests/AFNetworkActivityManagerTests.m index b454c76d30..152eae6509 100644 --- a/Tests/Tests/AFNetworkActivityManagerTests.m +++ b/Tests/Tests/AFNetworkActivityManagerTests.m @@ -46,7 +46,8 @@ - (void)tearDown { [super tearDown]; self.networkActivityIndicatorManager = nil; - [self.sessionManager invalidateSessionCancelingTasks:YES]; + [self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO]; + self.sessionManager = nil; } #pragma mark - @@ -69,6 +70,7 @@ - (void)testThatNetworkActivityIndicatorTurnsOnAndOffIndicatorWhenRequestSucceed [self.sessionManager GET:@"/delay/1" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { [requestExpectation fulfill]; @@ -95,6 +97,7 @@ - (void)testThatNetworkActivityIndicatorTurnsOnAndOffIndicatorWhenRequestFails { [self.sessionManager GET:@"/status/404" parameters:nil + headers:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { @@ -128,6 +131,7 @@ - (void)testThatVisibilityDelaysAreApplied { [self.sessionManager GET:@"/delay/2" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { requestEndTime = CACurrentMediaTime(); @@ -157,6 +161,7 @@ - (void)testThatIndicatorBlockIsOnlyCalledOnceEachForStartAndEndForMultipleReque [self.sessionManager GET:@"/delay/4" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { [requestExpectation fulfill]; @@ -167,6 +172,7 @@ - (void)testThatIndicatorBlockIsOnlyCalledOnceEachForStartAndEndForMultipleReque [self.sessionManager GET:@"/delay/2" parameters:nil + headers:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { @@ -178,4 +184,18 @@ - (void)testThatIndicatorBlockIsOnlyCalledOnceEachForStartAndEndForMultipleReque } +- (void)testThatIndicatorKVOOnlyTriggerOnce { + // create new one indicator manager + AFNetworkActivityIndicatorManager *manager = [AFNetworkActivityIndicatorManager new]; + __block NSInteger kvoTriggerCount = 0; + + XCTKVOExpectation *activityCountExpectation = [[XCTKVOExpectation alloc] initWithKeyPath:@"activityCount" object:manager]; + activityCountExpectation.handler = ^BOOL(id _Nonnull observedObject, NSDictionary * _Nonnull change) { + kvoTriggerCount += 1; + return [change[NSKeyValueChangeNewKey] isEqualToNumber:@(1)]; + }; + [manager incrementActivityCount]; + XCTAssertTrue(kvoTriggerCount == 1); +} + @end diff --git a/Tests/Tests/AFNetworkReachabilityManagerTests.m b/Tests/Tests/AFNetworkReachabilityManagerTests.m index b3a553abb2..49fca9bb52 100644 --- a/Tests/Tests/AFNetworkReachabilityManagerTests.m +++ b/Tests/Tests/AFNetworkReachabilityManagerTests.m @@ -125,4 +125,17 @@ - (void)testDomainReachabilityBlock { [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability]; } +- (void)testObjectPostingReachabilityManagerNotification { + [self expectationForNotification:AFNetworkingReachabilityDidChangeNotification + object:self.domainReachability + handler:^BOOL(NSNotification *notification) { + BOOL isObjectPostingNotification = [notification.object isEqual:self.domainReachability]; + return isObjectPostingNotification; + }]; + + [self.domainReachability startMonitoring]; + + [self waitForExpectationsWithCommonTimeout]; +} + @end diff --git a/Tests/Tests/AFPropertyListResponseSerializerTests.m b/Tests/Tests/AFPropertyListResponseSerializerTests.m index ec5953e1c0..7bbeb57f9d 100644 --- a/Tests/Tests/AFPropertyListResponseSerializerTests.m +++ b/Tests/Tests/AFPropertyListResponseSerializerTests.m @@ -82,9 +82,9 @@ - (void)testResponseSerializerCanBeCopied { } - (void)testResponseSerializerCanBeArchivedAndUnarchived { - NSData *archive = [NSKeyedArchiver archivedDataWithRootObject:self.responseSerializer]; + NSData *archive = [self archivedDataWithRootObject:self.responseSerializer]; XCTAssertNotNil(archive); - AFPropertyListResponseSerializer *unarchivedSerializer = [NSKeyedUnarchiver unarchiveObjectWithData:archive]; + AFPropertyListResponseSerializer *unarchivedSerializer = [self unarchivedObjectOfClass:[AFPropertyListResponseSerializer class] fromData:archive]; XCTAssertNotNil(unarchivedSerializer); XCTAssertNotEqual(unarchivedSerializer, self.responseSerializer); XCTAssertTrue(unarchivedSerializer.format == self.responseSerializer.format); diff --git a/Tests/Tests/AFSecurityPolicyTests.m b/Tests/Tests/AFSecurityPolicyTests.m index 3d63378652..ff81dcd5d6 100644 --- a/Tests/Tests/AFSecurityPolicyTests.m +++ b/Tests/Tests/AFSecurityPolicyTests.m @@ -58,23 +58,31 @@ static SecTrustRef AFUTADNNetServerTrust() { } static SecCertificateRef AFUTHTTPBinOrgCertificate() { - NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_06102018" ofType:@"cer"]; + NSString *certPath = [[NSBundle bundleForClass:[AFSecurityPolicyTests class]] pathForResource:@"httpbinorg_02182021" ofType:@"cer"]; NSCAssert(certPath != nil, @"Path for certificate should not be nil"); NSData *certData = [NSData dataWithContentsOfFile:certPath]; return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData)); } -static SecCertificateRef AFUTLetsEncryptAuthorityCertificate() { - NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Let's Encrypt Authority X3" ofType:@"cer"]; +static SecCertificateRef AFUTAmazonAuthorityCertificate() { + NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Amazon" ofType:@"cer"]; NSCAssert(certPath != nil, @"Path for certificate should not be nil"); NSData *certData = [NSData dataWithContentsOfFile:certPath]; return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData)); } -static SecCertificateRef AFUTDSTRootCertificate() { - NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"DST Root CA X3" ofType:@"cer"]; +static SecCertificateRef AFUTAmazonRootAuthorityCertificate() { + NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Amazon Root CA 1" ofType:@"cer"]; + NSCAssert(certPath != nil, @"Path for certificate should not be nil"); + NSData *certData = [NSData dataWithContentsOfFile:certPath]; + + return SecCertificateCreateWithData(NULL, (__bridge CFDataRef)(certData)); +} + +static SecCertificateRef AFUTStarfieldServicesRootCertificate() { + NSString *certPath = [[NSBundle bundleForClass:NSClassFromString(@"AFSecurityPolicyTests")] pathForResource:@"Starfield Services Root Certificate Authority - G2" ofType:@"cer"]; NSCAssert(certPath != nil, @"Path for certificate should not be nil"); NSData *certData = [NSData dataWithContentsOfFile:certPath]; @@ -204,7 +212,7 @@ - (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgL - (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgIntermediateCertificatePinned { AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey]; - SecCertificateRef certificate = AFUTLetsEncryptAuthorityCertificate(); + SecCertificateRef certificate = AFUTAmazonAuthorityCertificate(); policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust"); } @@ -212,7 +220,7 @@ - (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgI - (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgRootCertificatePinned { AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey]; - SecCertificateRef certificate = AFUTDSTRootCertificate(); + SecCertificateRef certificate = AFUTAmazonRootAuthorityCertificate(); policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust"); } @@ -221,10 +229,12 @@ - (void)testPolicyWithPublicKeyPinningAllowsHTTPBinOrgServerTrustWithEntireCerti AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey]; SecCertificateRef httpBinCertificate = AFUTHTTPBinOrgCertificate(); - SecCertificateRef intermediateCertificate = AFUTLetsEncryptAuthorityCertificate(); - SecCertificateRef rootCertificate = AFUTDSTRootCertificate(); + SecCertificateRef intermediateCertificate = AFUTAmazonAuthorityCertificate(); + SecCertificateRef intermediateCertificate2 = AFUTAmazonRootAuthorityCertificate(); + SecCertificateRef rootCertificate = AFUTStarfieldServicesRootCertificate(); [policy setPinnedCertificates:[NSSet setWithObjects:(__bridge_transfer NSData *)SecCertificateCopyData(httpBinCertificate), (__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate), + (__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate2), (__bridge_transfer NSData *)SecCertificateCopyData(rootCertificate), nil]]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow HTTPBinOrg server trust because at least one of the pinned certificates is valid"); @@ -316,7 +326,7 @@ - (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOr - (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgIntermediateCertificatePinned { AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]; - SecCertificateRef certificate = AFUTLetsEncryptAuthorityCertificate(); + SecCertificateRef certificate = AFUTAmazonAuthorityCertificate(); policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust"); } @@ -324,7 +334,7 @@ - (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOr - (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithHTTPBinOrgRootCertificatePinned { AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]; - SecCertificateRef certificate = AFUTDSTRootCertificate(); + SecCertificateRef certificate = AFUTAmazonRootAuthorityCertificate(); policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(certificate)]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow server trust"); } @@ -333,10 +343,12 @@ - (void)testPolicyWithCertificatePinningAllowsHTTPBinOrgServerTrustWithEntireCer AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate]; SecCertificateRef httpBinCertificate = AFUTHTTPBinOrgCertificate(); - SecCertificateRef intermediateCertificate = AFUTLetsEncryptAuthorityCertificate(); - SecCertificateRef rootCertificate = AFUTDSTRootCertificate(); + SecCertificateRef intermediateCertificate = AFUTAmazonAuthorityCertificate(); + SecCertificateRef intermediateCertificate2 = AFUTAmazonRootAuthorityCertificate(); + SecCertificateRef rootCertificate = AFUTStarfieldServicesRootCertificate(); [policy setPinnedCertificates:[NSSet setWithObjects:(__bridge_transfer NSData *)SecCertificateCopyData(httpBinCertificate), (__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate), + (__bridge_transfer NSData *)SecCertificateCopyData(intermediateCertificate2), (__bridge_transfer NSData *)SecCertificateCopyData(rootCertificate), nil]]; XCTAssertTrue([policy evaluateServerTrust:AFUTHTTPBinOrgServerTrust() forDomain:nil], @"Policy should allow HTTPBinOrg server trust because at least one of the pinned certificates is valid"); @@ -540,13 +552,8 @@ - (void)testThatPolicyCanBeEncodedAndDecoded { policy.validatesDomainName = NO; policy.pinnedCertificates = [NSSet setWithObject:(__bridge_transfer id)SecCertificateCopyData(AFUTHTTPBinOrgCertificate())]; - NSMutableData *archiveData = [NSMutableData new]; - NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:archiveData]; - [archiver encodeObject:policy forKey:@"policy"]; - [archiver finishEncoding]; - - NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:archiveData]; - AFSecurityPolicy *unarchivedPolicy = [unarchiver decodeObjectOfClass:[AFSecurityPolicy class] forKey:@"policy"]; + NSData *archive = [self archivedDataWithRootObject:policy]; + AFSecurityPolicy *unarchivedPolicy = [self unarchivedObjectOfClass:[AFSecurityPolicy class] fromData:archive]; XCTAssertNotEqual(unarchivedPolicy, policy); XCTAssertEqual(unarchivedPolicy.allowInvalidCertificates, policy.allowInvalidCertificates); diff --git a/Tests/Tests/AFTestCase.h b/Tests/Tests/AFTestCase.h index b57e088531..2d508a7c24 100644 --- a/Tests/Tests/AFTestCase.h +++ b/Tests/Tests/AFTestCase.h @@ -33,5 +33,7 @@ - (void)waitForExpectationsWithCommonTimeout; - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandler)handler; +- (NSData *)archivedDataWithRootObject:(id)object; +- (id)unarchivedObjectOfClass:(Class)class fromData:(NSData *)data; @end diff --git a/Tests/Tests/AFTestCase.m b/Tests/Tests/AFTestCase.m index 4726807b8f..00bac17f29 100644 --- a/Tests/Tests/AFTestCase.m +++ b/Tests/Tests/AFTestCase.m @@ -63,4 +63,18 @@ - (void)waitForExpectationsWithCommonTimeoutUsingHandler:(XCWaitCompletionHandle [self waitForExpectationsWithTimeout:self.networkTimeout handler:handler]; } +- (NSData *)archivedDataWithRootObject:(id)object { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + return [NSKeyedArchiver archivedDataWithRootObject:object]; +#pragma clang diagnostic pop +} + +- (id)unarchivedObjectOfClass:(Class)class fromData:(NSData *)data { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + return [NSKeyedUnarchiver unarchiveObjectWithData:data]; +#pragma clang diagnostic pop +} + @end diff --git a/Tests/Tests/AFUIActivityIndicatorViewTests.m b/Tests/Tests/AFUIActivityIndicatorViewTests.m index eb01f27581..ed591c9ec6 100644 --- a/Tests/Tests/AFUIActivityIndicatorViewTests.m +++ b/Tests/Tests/AFUIActivityIndicatorViewTests.m @@ -33,14 +33,18 @@ @implementation AFUIActivityIndicatorViewTests - (void)setUp { [super setUp]; +#if TARGET_OS_MACCATALYST + self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium]; +#else self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; +#endif self.request = [NSURLRequest requestWithURL:self.delayURL]; self.sessionManager = [[AFURLSessionManager alloc] initWithSessionConfiguration:nil]; } - (void)tearDown { [super tearDown]; - [self.sessionManager invalidateSessionCancelingTasks:YES]; + [self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO]; self.sessionManager = nil; } diff --git a/Tests/Tests/AFUIRefreshControlTests.m b/Tests/Tests/AFUIRefreshControlTests.m index 3daec94831..c5ab5af709 100644 --- a/Tests/Tests/AFUIRefreshControlTests.m +++ b/Tests/Tests/AFUIRefreshControlTests.m @@ -40,7 +40,7 @@ - (void)setUp { - (void)tearDown { [super tearDown]; - [self.sessionManager invalidateSessionCancelingTasks:YES]; + [self.sessionManager invalidateSessionCancelingTasks:YES resetSession:NO]; self.sessionManager = nil; } diff --git a/Tests/Tests/AFURLSessionManagerTests.m b/Tests/Tests/AFURLSessionManagerTests.m index 1a3d7cf6b3..fc4d3bfc7c 100644 --- a/Tests/Tests/AFURLSessionManagerTests.m +++ b/Tests/Tests/AFURLSessionManagerTests.m @@ -70,10 +70,10 @@ - (void)setUp { - (void)tearDown { [super tearDown]; [self.localManager.session.configuration.URLCache removeAllCachedResponses]; - [self.localManager invalidateSessionCancelingTasks:YES]; + [self.localManager invalidateSessionCancelingTasks:YES resetSession:NO]; self.localManager = nil; - [self.backgroundManager invalidateSessionCancelingTasks:YES]; + [self.backgroundManager invalidateSessionCancelingTasks:YES resetSession:NO]; self.backgroundManager = nil; } @@ -133,19 +133,44 @@ - (void)testDownloadTaskDoesReportProgress { [self waitForExpectationsWithCommonTimeout]; } -// iOS 7 has a bug that may return nil for a session. To simulate that, nil out the -// session and it will return nil itself. -- (void)testFileUploadTaskReturnsNilWithBug { - [self.localManager setValue:nil forKey:@"session"]; +- (void)testSessionTaskDoesReportMetrics { + [self expectationForNotification:AFNetworkingTaskDidCompleteNotification object:nil handler:^BOOL(NSNotification * _Nonnull notification) { +#if AF_CAN_USE_AT_AVAILABLE && AF_CAN_INCLUDE_SESSION_TASK_METRICS + if (@available(iOS 10, macOS 10.12, watchOS 3, tvOS 10, *)) { + return [notification userInfo][AFNetworkingTaskDidCompleteSessionTaskMetrics] != nil; + } +#endif + return YES; + }]; + +#if AF_CAN_INCLUDE_SESSION_TASK_METRICS + __weak XCTestExpectation *metricsBlock = [self expectationWithDescription:@"Metrics completion block is called"]; + [self.localManager setTaskDidFinishCollectingMetricsBlock:^(NSURLSession * _Nonnull session, NSURLSessionTask * _Nonnull task, NSURLSessionTaskMetrics * _Nullable metrics) { + [metricsBlock fulfill]; + }]; +#endif + + NSURLSessionTask *task = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest] + progress:nil + destination:nil + completionHandler:nil]; + [task resume]; + [self waitForExpectationsWithCommonTimeout]; +} + +- (void)testSessionIsStillValid { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wnonnull" - XCTAssertNil([self.localManager uploadTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL] - fromFile:nil - progress:NULL - completionHandler:NULL], - @"Upload task should be nil."); -#pragma GCC diagnostic pop + NSURLSession *session = self.localManager.session; + [self.localManager invalidateSessionCancelingTasks:YES resetSession:NO]; + + XCTAssertEqual(session, self.localManager.session); +} + +- (void)testSessionRecreatesAgain { + + [self.localManager invalidateSessionCancelingTasks:YES resetSession:YES]; + + XCTAssertNotNil(self.localManager.session); } - (void)testUploadTaskDoesReportProgress { @@ -199,34 +224,6 @@ - (void)testUploadProgressCanBeKVOd { [self waitForExpectationsWithCommonTimeout]; } -#pragma mark - rdar://17029580 - -- (void)testRDAR17029580IsFixed { - //https://github.com/AFNetworking/AFNetworking/issues/2093 - //https://github.com/AFNetworking/AFNetworking/pull/3205 - //http://openradar.appspot.com/radar?id=5871104061079552 - dispatch_queue_t serial_queue = dispatch_queue_create("com.alamofire.networking.test.RDAR17029580", DISPATCH_QUEUE_SERIAL); - NSMutableArray *taskIDs = [[NSMutableArray alloc] init]; - for (NSInteger i = 0; i < 100; i++) { - XCTestExpectation *expectation = [self expectationWithDescription:@"Wait for task creation"]; - __block NSURLSessionTask *task; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - task = [self.localManager - dataTaskWithRequest:[NSURLRequest requestWithURL:self.baseURL] - uploadProgress:nil - downloadProgress:nil - completionHandler:nil]; - dispatch_sync(serial_queue, ^{ - XCTAssertFalse([taskIDs containsObject:@(task.taskIdentifier)]); - [taskIDs addObject:@(task.taskIdentifier)]; - }); - [task cancel]; - [expectation fulfill]; - }); - } - [self waitForExpectationsWithCommonTimeout]; -} - #pragma mark - Issue #2702 Tests // The following tests are all releated to issue #2702 @@ -445,6 +442,43 @@ - (void)testBackgroundManagerReturnsExpectedClassForDownloadTask { } } +#pragma mark - Notifications + +- (void)testTaskMoveSuccessfullyAfterDownloading { + NSURL *dirURL = [[[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; + NSURL *destinationURL = [dirURL URLByAppendingPathComponent:NSUUID.UUID.UUIDString]; + + NSURLSessionDownloadTask *task = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest] + progress:nil + destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + return destinationURL; + } + completionHandler:nil]; + + [self expectationForNotification:AFURLSessionDownloadTaskDidMoveFileSuccessfullyNotification + object:nil + handler:nil]; + [task resume]; + [self waitForExpectationsWithCommonTimeout]; + [[NSFileManager defaultManager] removeItemAtURL:destinationURL error:nil]; +} + +- (void)testTaskMoveFailedAfterDownloading { + NSURLSessionDownloadTask *downloadTask = [self.localManager downloadTaskWithRequest:[self bigImageURLRequest] + progress:nil + destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + // Try to move the destination file to a nonexist path on purpose for simulating a move failure. + return [NSURL fileURLWithPath:@"/a/b/c"]; + } + completionHandler:nil]; + + [self expectationForNotification:AFURLSessionDownloadTaskDidFailToMoveFileNotification + object:nil + handler:nil]; + [downloadTask resume]; + [self waitForExpectationsWithCommonTimeout]; +} + #pragma mark - private - (void)_testResumeNotificationForTask:(NSURLSessionTask *)task { @@ -473,7 +507,7 @@ - (NSURLRequest *)_delayURLRequest { return [NSURLRequest requestWithURL:self.delayURL]; } -- (IMP)_implementationForTask:(NSURLSessionTask *)task selector:(SEL)selector { +- (IMP)_implementationForTask:(NSURLSessionTask *)task selector:(SEL)selector { return [self _implementationForClass:[task class] selector:selector]; } diff --git a/Tests/Tests/AFUIWebViewTests.m b/Tests/Tests/AFWKWebViewTests.m similarity index 61% rename from Tests/Tests/AFUIWebViewTests.m rename to Tests/Tests/AFWKWebViewTests.m index 375993169d..80c10b56d4 100644 --- a/Tests/Tests/AFUIWebViewTests.m +++ b/Tests/Tests/AFWKWebViewTests.m @@ -1,4 +1,4 @@ -// AFUIWebViewTests.h +// AFWKWebViewTests.m // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -20,61 +20,87 @@ // THE SOFTWARE. #import +#import #import "AFTestCase.h" -#import "UIWebView+AFNetworking.h" +#import "WKWebView+AFNetworking.h" -@interface AFUIWebViewTests : AFTestCase +@interface AFWKWebViewTests : AFTestCase -@property (nonatomic, strong) UIWebView *webView; +@property (nonatomic, strong) WKWebView *webView; +@property (nonatomic, strong) WKNavigation *navigation; @property (nonatomic, strong) NSURLRequest *HTMLRequest; +@property (nonatomic, strong) NSURLRequest *largeHTMLRequest; +@property (nonatomic, strong) NSURLRequest *headerRequest; +@property (nonatomic, strong) NSProgress *progressCapture; @end -@implementation AFUIWebViewTests +@implementation AFWKWebViewTests -- (void)setUp { +-(void)setUp { [super setUp]; - self.webView = [UIWebView new]; - self.HTMLRequest = [NSURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"html"]]; + self.webView = [WKWebView new]; + self.webView.navigationDelegate = self; + self.navigation = [WKNavigation new]; + self.HTMLRequest = [NSURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"html"] + cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData + timeoutInterval:self.networkTimeout]; + NSURL * largeURL = [[self.baseURL URLByAppendingPathComponent:@"bytes"] URLByAppendingPathComponent:@(1024 * 1024).stringValue]; + self.largeHTMLRequest = [NSURLRequest requestWithURL:largeURL + cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData + timeoutInterval:self.networkTimeout]; + NSMutableURLRequest *customHeaderRequest = [NSMutableURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"headers"]]; + [customHeaderRequest setValue:@"Custom-Header-Value" forHTTPHeaderField:@"Custom-Header-Field"]; + self.headerRequest = customHeaderRequest; } - (void)testNilProgressDoesNotCauseCrash { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; [self.webView loadRequest:self.HTMLRequest + navigation:self.navigation progress:nil success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) { [expectation fulfill]; return HTML; - } - failure:nil]; + } failure:^(NSError * _Nonnull error) { + XCTFail(@"Request %@ failed with error %@", self.HTMLRequest, error); + [expectation fulfill]; + }]; [self waitForExpectationsWithCommonTimeout]; } -- (void)testNULLProgressDoesNotCauseCrash { +- (void)testNUllProgressDoesNotCauseCrash { XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; [self.webView loadRequest:self.HTMLRequest + navigation:self.navigation progress:NULL success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) { [expectation fulfill]; return HTML; - } - failure:nil]; + } failure:^(NSError * _Nonnull error) { + XCTFail(@"Request %@ failed with error %@", self.HTMLRequest, error); + [expectation fulfill]; + }]; [self waitForExpectationsWithCommonTimeout]; } - (void)testProgressIsSet { NSProgress* progress = nil; XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; + [self.webView - loadRequest:self.HTMLRequest + loadRequest:self.largeHTMLRequest + navigation:self.navigation progress:&progress success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull HTML) { [expectation fulfill]; return HTML; - } - failure:nil]; + } failure:^(NSError * _Nonnull error) { + XCTFail(@"Request %@ failed with error %@", self.largeHTMLRequest, error); + [expectation fulfill]; + }]; [self keyValueObservingExpectationForObject:progress keyPath:@"fractionCompleted" expectedValue:@(1.0)]; @@ -82,23 +108,29 @@ - (void)testProgressIsSet { } - (void)testRequestWithCustomHeaders { - NSMutableURLRequest *customHeaderRequest = [NSMutableURLRequest requestWithURL:[self.baseURL URLByAppendingPathComponent:@"headers"]]; - [customHeaderRequest setValue:@"Custom-Header-Value" forHTTPHeaderField:@"Custom-Header-Field"]; + XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"]; [self.webView - loadRequest:customHeaderRequest + loadRequest:self.headerRequest + navigation:self.navigation progress:NULL success:^NSString * _Nonnull(NSHTTPURLResponse * _Nonnull response, NSString * _Nonnull string) { - // Here string is actually JSON. + // Here string is actually JSON NSDictionary *responseObject = [NSJSONSerialization JSONObjectWithData:[string dataUsingEncoding:NSUTF8StringEncoding] options:(NSJSONReadingOptions)0 error:nil]; NSDictionary *headers = responseObject[@"headers"]; XCTAssertTrue([headers[@"Custom-Header-Field"] isEqualToString:@"Custom-Header-Value"]); [expectation fulfill]; return string; - } - failure:nil]; + } failure:^(NSError * _Nonnull error) { + XCTFail(@"Request %@ failed with error %@", self.headerRequest, error); + [expectation fulfill]; + }]; [self waitForExpectationsWithCommonTimeout]; } +- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { + XCTFail(@"Navigation failed with error %@", error); +} + @end diff --git a/UIKit+AFNetworking/AFAutoPurgingImageCache.m b/UIKit+AFNetworking/AFAutoPurgingImageCache.m index 374eeac653..a09e87c837 100644 --- a/UIKit+AFNetworking/AFAutoPurgingImageCache.m +++ b/UIKit+AFNetworking/AFAutoPurgingImageCache.m @@ -28,7 +28,7 @@ @interface AFCachedImage : NSObject @property (nonatomic, strong) UIImage *image; -@property (nonatomic, strong) NSString *identifier; +@property (nonatomic, copy) NSString *identifier; @property (nonatomic, assign) UInt64 totalBytes; @property (nonatomic, strong) NSDate *lastAccessDate; @property (nonatomic, assign) UInt64 currentMemoryUsage; @@ -37,7 +37,7 @@ @interface AFCachedImage : NSObject @implementation AFCachedImage --(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { +- (instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier { if (self = [self init]) { self.image = image; self.identifier = identifier; @@ -51,7 +51,7 @@ -(instancetype)initWithImage:(UIImage *)image identifier:(NSString *)identifier return self; } -- (UIImage*)accessImage { +- (UIImage *)accessImage { self.lastAccessDate = [NSDate date]; return self.image; } @@ -134,7 +134,7 @@ - (void)addImage:(UIImage *)image withIdentifier:(NSString *)identifier { [self.cachedImages removeObjectForKey:cachedImage.identifier]; bytesPurged += cachedImage.totalBytes; if (bytesPurged >= bytesToPurge) { - break ; + break; } } self.currentMemoryUsage -= bytesPurged; diff --git a/UIKit+AFNetworking/AFImageDownloader.h b/UIKit+AFNetworking/AFImageDownloader.h index 7e25e3734d..3bf5a32025 100644 --- a/UIKit+AFNetworking/AFImageDownloader.h +++ b/UIKit+AFNetworking/AFImageDownloader.h @@ -67,7 +67,7 @@ typedef NS_ENUM(NSInteger, AFImageDownloadPrioritization) { /** Defines the order prioritization of incoming download requests being inserted into the queue. `AFImageDownloadPrioritizationFIFO` by default. */ -@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritizaton; +@property (nonatomic, assign) AFImageDownloadPrioritization downloadPrioritization; /** The shared default instance of `AFImageDownloader` initialized with default values. diff --git a/UIKit+AFNetworking/AFImageDownloader.m b/UIKit+AFNetworking/AFImageDownloader.m index 36745b57a1..008a78286d 100644 --- a/UIKit+AFNetworking/AFImageDownloader.m +++ b/UIKit+AFNetworking/AFImageDownloader.m @@ -28,8 +28,8 @@ @interface AFImageDownloaderResponseHandler : NSObject @property (nonatomic, strong) NSUUID *uuid; -@property (nonatomic, copy) void (^successBlock)(NSURLRequest*, NSHTTPURLResponse*, UIImage*); -@property (nonatomic, copy) void (^failureBlock)(NSURLRequest*, NSHTTPURLResponse*, NSError*); +@property (nonatomic, copy) void (^successBlock)(NSURLRequest *, NSHTTPURLResponse *, UIImage *); +@property (nonatomic, copy) void (^failureBlock)(NSURLRequest *, NSHTTPURLResponse *, NSError *); @end @implementation AFImageDownloaderResponseHandler @@ -71,11 +71,11 @@ - (instancetype)initWithURLIdentifier:(NSString *)URLIdentifier identifier:(NSUU return self; } -- (void)addResponseHandler:(AFImageDownloaderResponseHandler*)handler { +- (void)addResponseHandler:(AFImageDownloaderResponseHandler *)handler { [self.responseHandlers addObject:handler]; } -- (void)removeResponseHandler:(AFImageDownloaderResponseHandler*)handler { +- (void)removeResponseHandler:(AFImageDownloaderResponseHandler *)handler { [self.responseHandlers removeObject:handler]; } @@ -109,20 +109,24 @@ @interface AFImageDownloader () @implementation AFImageDownloader + (NSURLCache *)defaultURLCache { + NSUInteger memoryCapacity = 20 * 1024 * 1024; // 20MB + NSUInteger diskCapacity = 150 * 1024 * 1024; // 150MB + NSURL *cacheURL = [[[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory + inDomain:NSUserDomainMask + appropriateForURL:nil + create:YES + error:nil] + URLByAppendingPathComponent:@"com.alamofire.imagedownloader"]; - // It's been discovered that a crash will occur on certain versions - // of iOS if you customize the cache. - // - // More info can be found here: https://devforums.apple.com/message/1102182#1102182 - // - // When iOS 7 support is dropped, this should be modified to use - // NSProcessInfo methods instead. - if ([[[UIDevice currentDevice] systemVersion] compare:@"8.2" options:NSNumericSearch] == NSOrderedAscending) { - return [NSURLCache sharedURLCache]; - } - return [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 - diskCapacity:150 * 1024 * 1024 - diskPath:@"com.alamofire.imagedownloader"]; +#if TARGET_OS_MACCATALYST + return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity + diskCapacity:diskCapacity + directoryURL:cacheURL]; +#else + return [[NSURLCache alloc] initWithMemoryCapacity:memoryCapacity + diskCapacity:diskCapacity + diskPath:[cacheURL path]]; +#endif } + (NSURLSessionConfiguration *)defaultURLSessionConfiguration { @@ -163,7 +167,7 @@ - (instancetype)initWithSessionManager:(AFHTTPSessionManager *)sessionManager if (self = [super init]) { self.sessionManager = sessionManager; - self.downloadPrioritizaton = downloadPrioritization; + self.downloadPrioritization = downloadPrioritization; self.maximumActiveDownloads = maximumActiveDownloads; self.imageCache = imageCache; @@ -254,14 +258,14 @@ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *) completionHandler:^(NSURLResponse * _Nonnull response, id _Nullable responseObject, NSError * _Nullable error) { dispatch_async(self.responseQueue, ^{ __strong __typeof__(weakSelf) strongSelf = weakSelf; - AFImageDownloaderMergedTask *mergedTask = strongSelf.mergedTasks[URLIdentifier]; + AFImageDownloaderMergedTask *mergedTask = [strongSelf safelyGetMergedTask:URLIdentifier]; if ([mergedTask.identifier isEqual:mergedTaskIdentifier]) { mergedTask = [strongSelf safelyRemoveMergedTaskWithURLIdentifier:URLIdentifier]; if (error) { for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { if (handler.failureBlock) { dispatch_async(dispatch_get_main_queue(), ^{ - handler.failureBlock(request, (NSHTTPURLResponse*)response, error); + handler.failureBlock(request, (NSHTTPURLResponse *)response, error); }); } } @@ -273,7 +277,7 @@ - (nullable AFImageDownloadReceipt *)downloadImageForURLRequest:(NSURLRequest *) for (AFImageDownloaderResponseHandler *handler in mergedTask.responseHandlers) { if (handler.successBlock) { dispatch_async(dispatch_get_main_queue(), ^{ - handler.successBlock(request, (NSHTTPURLResponse*)response, responseObject); + handler.successBlock(request, (NSHTTPURLResponse *)response, responseObject); }); } } @@ -333,14 +337,14 @@ - (void)cancelTaskForImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownloa } } - if (mergedTask.responseHandlers.count == 0 && mergedTask.task.state == NSURLSessionTaskStateSuspended) { + if (mergedTask.responseHandlers.count == 0) { [mergedTask.task cancel]; [self removeMergedTaskWithURLIdentifier:URLIdentifier]; } }); } -- (AFImageDownloaderMergedTask*)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { +- (AFImageDownloaderMergedTask *)safelyRemoveMergedTaskWithURLIdentifier:(NSString *)URLIdentifier { __block AFImageDownloaderMergedTask *mergedTask = nil; dispatch_sync(self.synchronizationQueue, ^{ mergedTask = [self removeMergedTaskWithURLIdentifier:URLIdentifier]; @@ -383,7 +387,7 @@ - (void)startMergedTask:(AFImageDownloaderMergedTask *)mergedTask { } - (void)enqueueMergedTask:(AFImageDownloaderMergedTask *)mergedTask { - switch (self.downloadPrioritizaton) { + switch (self.downloadPrioritization) { case AFImageDownloadPrioritizationFIFO: [self.queuedMergedTasks addObject:mergedTask]; break; @@ -404,6 +408,14 @@ - (BOOL)isActiveRequestCountBelowMaximumLimit { return self.activeRequestCount < self.maximumActiveDownloads; } +- (AFImageDownloaderMergedTask *)safelyGetMergedTask:(NSString *)URLIdentifier { + __block AFImageDownloaderMergedTask *mergedTask; + dispatch_sync(self.synchronizationQueue, ^(){ + mergedTask = self.mergedTasks[URLIdentifier]; + }); + return mergedTask; +} + @end #endif diff --git a/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m index e6f9b65ea1..8cb5677eff 100644 --- a/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m +++ b/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -109,11 +109,9 @@ - (BOOL)isNetworkActivityOccurring { - (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible { if (_networkActivityIndicatorVisible != networkActivityIndicatorVisible) { - [self willChangeValueForKey:@"networkActivityIndicatorVisible"]; @synchronized(self) { - _networkActivityIndicatorVisible = networkActivityIndicatorVisible; + _networkActivityIndicatorVisible = networkActivityIndicatorVisible; } - [self didChangeValueForKey:@"networkActivityIndicatorVisible"]; if (self.networkActivityActionBlock) { self.networkActivityActionBlock(networkActivityIndicatorVisible); } else { @@ -122,35 +120,20 @@ - (void)setNetworkActivityIndicatorVisible:(BOOL)networkActivityIndicatorVisible } } -- (void)setActivityCount:(NSInteger)activityCount { - @synchronized(self) { - _activityCount = activityCount; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [self updateCurrentStateForNetworkActivityChange]; - }); -} - (void)incrementActivityCount { - [self willChangeValueForKey:@"activityCount"]; - @synchronized(self) { - _activityCount++; - } - [self didChangeValueForKey:@"activityCount"]; - + @synchronized(self) { + self.activityCount++; + } dispatch_async(dispatch_get_main_queue(), ^{ [self updateCurrentStateForNetworkActivityChange]; }); } - (void)decrementActivityCount { - [self willChangeValueForKey:@"activityCount"]; - @synchronized(self) { - _activityCount = MAX(_activityCount - 1, 0); - } - [self didChangeValueForKey:@"activityCount"]; - + @synchronized(self) { + self.activityCount = MAX(_activityCount - 1, 0); + } dispatch_async(dispatch_get_main_queue(), ^{ [self updateCurrentStateForNetworkActivityChange]; }); @@ -172,7 +155,6 @@ - (void)networkRequestDidFinish:(NSNotification *)notification { - (void)setCurrentState:(AFNetworkActivityManagerState)currentState { @synchronized(self) { if (_currentState != currentState) { - [self willChangeValueForKey:@"currentState"]; _currentState = currentState; switch (currentState) { case AFNetworkActivityManagerStateNotActive: @@ -191,9 +173,7 @@ - (void)setCurrentState:(AFNetworkActivityManagerState)currentState { [self startCompletionDelayTimer]; break; } - [self didChangeValueForKey:@"currentState"]; } - } } diff --git a/UIKit+AFNetworking/UIButton+AFNetworking.m b/UIKit+AFNetworking/UIButton+AFNetworking.m index 2da601273f..03aaf2a84e 100644 --- a/UIKit+AFNetworking/UIButton+AFNetworking.m +++ b/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -103,11 +103,11 @@ @implementation UIButton (AFNetworking) + (AFImageDownloader *)sharedImageDownloader { - return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; + return objc_getAssociatedObject([UIButton class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; } + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { - objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject([UIButton class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - @@ -168,7 +168,7 @@ - (void)setImageForState:(UIControlState)state if ([[strongSelf af_imageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (success) { success(request, response, responseObject); - } else if(responseObject) { + } else if (responseObject) { [strongSelf setImage:responseObject forState:state]; } [strongSelf af_setImageDownloadReceipt:nil forState:state]; @@ -247,7 +247,7 @@ - (void)setBackgroundImageForState:(UIControlState)state if ([[strongSelf af_backgroundImageDownloadReceiptForState:state].receiptID isEqual:downloadID]) { if (success) { success(request, response, responseObject); - } else if(responseObject) { + } else if (responseObject) { [strongSelf setBackgroundImage:responseObject forState:state]; } [strongSelf af_setBackgroundImageDownloadReceipt:nil forState:state]; diff --git a/UIKit+AFNetworking/UIImage+AFNetworking.h b/UIKit+AFNetworking/UIImage+AFNetworking.h deleted file mode 100644 index 14744cddd5..0000000000 --- a/UIKit+AFNetworking/UIImage+AFNetworking.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// UIImage+AFNetworking.h -// -// -// Created by Paulo Ferreira on 08/07/15. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#if TARGET_OS_IOS || TARGET_OS_TV - -#import - -@interface UIImage (AFNetworking) - -+ (UIImage*) safeImageWithData:(NSData*)data; - -@end - -#endif diff --git a/UIKit+AFNetworking/UIImageView+AFNetworking.m b/UIKit+AFNetworking/UIImageView+AFNetworking.m index 41c18a61d6..8ae49509e1 100644 --- a/UIKit+AFNetworking/UIImageView+AFNetworking.m +++ b/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -48,11 +48,11 @@ - (void)af_setActiveImageDownloadReceipt:(AFImageDownloadReceipt *)imageDownload @implementation UIImageView (AFNetworking) + (AFImageDownloader *)sharedImageDownloader { - return objc_getAssociatedObject(self, @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; + return objc_getAssociatedObject([UIImageView class], @selector(sharedImageDownloader)) ?: [AFImageDownloader defaultInstance]; } + (void)setSharedImageDownloader:(AFImageDownloader *)imageDownloader { - objc_setAssociatedObject(self, @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject([UIImageView class], @selector(sharedImageDownloader), imageDownloader, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } #pragma mark - @@ -75,7 +75,6 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, UIImage *image))success failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * _Nullable response, NSError *error))failure { - if ([urlRequest URL] == nil) { self.image = placeholderImage; if (failure) { @@ -85,7 +84,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest return; } - if ([self isActiveTaskURLEqualToURLRequest:urlRequest]){ + if ([self isActiveTaskURLEqualToURLRequest:urlRequest]) { return; } @@ -119,7 +118,7 @@ - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest if ([strongSelf.af_activeImageDownloadReceipt.receiptID isEqual:downloadID]) { if (success) { success(request, response, responseObject); - } else if(responseObject) { + } else if (responseObject) { strongSelf.image = responseObject; } [strongSelf clearActiveDownloadInformation]; diff --git a/UIKit+AFNetworking/UIKit+AFNetworking.h b/UIKit+AFNetworking/UIKit+AFNetworking.h index febacfc755..aa9c0b0281 100644 --- a/UIKit+AFNetworking/UIKit+AFNetworking.h +++ b/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -20,23 +20,24 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#if TARGET_OS_IOS || TARGET_OS_TV -#import +#import #ifndef _UIKIT_AFNETWORKING_ #define _UIKIT_AFNETWORKING_ -#if TARGET_OS_IOS +#if TARGET_OS_IOS || TARGET_OS_TV #import "AFAutoPurgingImageCache.h" #import "AFImageDownloader.h" - #import "AFNetworkActivityIndicatorManager.h" - #import "UIRefreshControl+AFNetworking.h" - #import "UIWebView+AFNetworking.h" -#endif - #import "UIActivityIndicatorView+AFNetworking.h" #import "UIButton+AFNetworking.h" #import "UIImageView+AFNetworking.h" #import "UIProgressView+AFNetworking.h" -#endif /* _UIKIT_AFNETWORKING_ */ #endif + +#if TARGET_OS_IOS + #import "AFNetworkActivityIndicatorManager.h" + #import "UIRefreshControl+AFNetworking.h" + #import "WKWebView+AFNetworking.h" +#endif + +#endif /* _UIKIT_AFNETWORKING_ */ diff --git a/UIKit+AFNetworking/UIWebView+AFNetworking.h b/UIKit+AFNetworking/WKWebView+AFNetworking.h similarity index 83% rename from UIKit+AFNetworking/UIWebView+AFNetworking.h rename to UIKit+AFNetworking/WKWebView+AFNetworking.h index b9a56af4bf..680fedff80 100644 --- a/UIKit+AFNetworking/UIWebView+AFNetworking.h +++ b/UIKit+AFNetworking/WKWebView+AFNetworking.h @@ -1,4 +1,4 @@ -// UIWebView+AFNetworking.h +// WkWebView+AFNetworking.h // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,47 +26,47 @@ #if TARGET_OS_IOS #import +#import NS_ASSUME_NONNULL_BEGIN @class AFHTTPSessionManager; -/** - This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. - - @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. - */ -@interface UIWebView (AFNetworking) +@interface WKWebView (AFNetworking) /** - The session manager used to download all requests. + The session manager used to download all request */ @property (nonatomic, strong) AFHTTPSessionManager *sessionManager; /** Asynchronously loads the specified request. - + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. @param progress A progress object monitoring the current download progress. @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. */ - (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success failure:(nullable void (^)(NSError *error))failure; /** Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. - + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param navigation The WKNavigation object that containts information for tracking the loading progress of a webpage. This must not be `nil`. @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. -@param progress A progress object monitoring the current download progress. + @param progress A progress object monitoring the current download progress. @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. @param failure A block object to be executed when the data task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. */ - (void)loadRequest:(NSURLRequest *)request + navigation:(WKNavigation * _Nonnull)navigation MIMEType:(nullable NSString *)MIMEType textEncodingName:(nullable NSString *)textEncodingName progress:(NSProgress * _Nullable __autoreleasing * _Nullable)progress diff --git a/UIKit+AFNetworking/UIWebView+AFNetworking.m b/UIKit+AFNetworking/WKWebView+AFNetworking.m similarity index 68% rename from UIKit+AFNetworking/UIWebView+AFNetworking.m rename to UIKit+AFNetworking/WKWebView+AFNetworking.m index 030c3e9453..6eca3c3a54 100644 --- a/UIKit+AFNetworking/UIWebView+AFNetworking.m +++ b/UIKit+AFNetworking/WKWebView+AFNetworking.m @@ -1,4 +1,4 @@ -// UIWebView+AFNetworking.m +// WkWebView+AFNetworking.m // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -19,7 +19,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "UIWebView+AFNetworking.h" +#import "WKWebView+AFNetworking.h" #import @@ -29,11 +29,11 @@ #import "AFURLResponseSerialization.h" #import "AFURLRequestSerialization.h" -@interface UIWebView (_AFNetworking) +@interface WKWebView (_AFNetworking) @property (readwrite, nonatomic, strong, setter = af_setURLSessionTask:) NSURLSessionDataTask *af_URLSessionTask; @end -@implementation UIWebView (_AFNetworking) +@implementation WKWebView (_AFNetworking) - (NSURLSessionDataTask *)af_URLSessionTask { return (NSURLSessionDataTask *)objc_getAssociatedObject(self, @selector(af_URLSessionTask)); @@ -47,9 +47,9 @@ - (void)af_setURLSessionTask:(NSURLSessionDataTask *)af_URLSessionTask { #pragma mark - -@implementation UIWebView (AFNetworking) +@implementation WKWebView (AFNetworking) -- (AFHTTPSessionManager *)sessionManager { +- (AFHTTPSessionManager *)sessionManager { static AFHTTPSessionManager *_af_defaultHTTPSessionManager = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ @@ -57,7 +57,7 @@ - (AFHTTPSessionManager *)sessionManager { _af_defaultHTTPSessionManager.requestSerializer = [AFHTTPRequestSerializer serializer]; _af_defaultHTTPSessionManager.responseSerializer = [AFHTTPResponseSerializer serializer]; }); - + return objc_getAssociatedObject(self, @selector(sessionManager)) ?: _af_defaultHTTPSessionManager; } @@ -71,7 +71,7 @@ - (void)setSessionManager:(AFHTTPSessionManager *)sessionManager { dispatch_once(&onceToken, ^{ _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; }); - + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; } @@ -82,11 +82,11 @@ - (void)setResponseSerializer:(AFHTTPResponseSerializer