From c5c6b820b5dfc39e61d3882eb94dbbb793d5b1f6 Mon Sep 17 00:00:00 2001 From: Jakub Date: Wed, 22 Sep 2021 18:03:28 +0200 Subject: [PATCH] Fixed iOS crash issue on Swift 5.5 (#720) --- CHANGELOG.md | 3 +++ docs/install.md | 2 +- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +++--- ios/Classes/CachingPlayerItem.swift | 20 +++++++++++++------- pubspec.yaml | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c7eee05..5daba3fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.75 +* Fixed iOS build issue connected with Swift 5.5. + ## 0.0.74 * [BREAKING_CHANGE] `nextVideoTimeStreamController` is now marked as private. Please use `nextVideoTimeStream` to access stream. * [BREAKING_CHANGE] Removed BackdropFilter from cupertino theme. diff --git a/docs/install.md b/docs/install.md index 55c0d2b78..1bbeaef9c 100644 --- a/docs/install.md +++ b/docs/install.md @@ -4,7 +4,7 @@ ```yaml dependencies: - better_player: ^0.0.74 + better_player: ^0.0.75 ``` 2. Install it diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f78a..f2872cf47 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 4433338ef..29a2974e8 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -364,7 +364,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -451,7 +451,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -500,7 +500,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/ios/Classes/CachingPlayerItem.swift b/ios/Classes/CachingPlayerItem.swift index 3d45e113a..6dc8e1c18 100644 --- a/ios/Classes/CachingPlayerItem.swift +++ b/ios/Classes/CachingPlayerItem.swift @@ -56,24 +56,30 @@ open class CachingPlayerItem: AVPlayerItem { guard let initialUrl = owner?.url else { fatalError("internal inconsistency") } - startDataRequest(with: initialUrl) + startDataRequest( url: initialUrl) } pendingRequests.insert(loadingRequest) processPendingRequests() return true } - func startDataRequest(with url: URL) { + func startDataRequest(url: URL) { let configuration = URLSessionConfiguration.default configuration.requestCachePolicy = .reloadIgnoringLocalAndRemoteCacheData session = URLSession(configuration: configuration, delegate: self, delegateQueue: nil) var request = URLRequest(url: url) request.httpMethod = "GET" - if let unwrappedDict = self.headers { - for (_key, _value) in unwrappedDict.enumerated() { - request.setValue((_value as! String), forHTTPHeaderField: (_key as! String)) + let headersString = self.headers as? [String:AnyObject] + if let unwrappedDict = headersString { + for (headerKey,headerValue) in unwrappedDict{ + guard let headerValueString = headerValue as? String + else { + continue + } + request.setValue(headerValueString, forHTTPHeaderField: headerKey) + } - } + } session?.dataTask(with: request).resume() } @@ -182,7 +188,7 @@ open class CachingPlayerItem: AVPlayerItem { ///Starts current download. open func download() { if resourceLoaderDelegate.session == nil { - resourceLoaderDelegate.startDataRequest(with: url) + resourceLoaderDelegate.startDataRequest(url: url) } } ///Stops current download. diff --git a/pubspec.yaml b/pubspec.yaml index 5433f17fd..3fb3a2e18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: better_player description: Advanced video player based on video_player and Chewie. It's solves many typical use cases and it's easy to run. -version: 0.0.74 +version: 0.0.75 # Disabled because of warning from analyzer # authors: # - Jakub Homlala