Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't compile iOS #776

Closed
CripyIce opened this issue Oct 24, 2021 · 8 comments
Closed

[BUG] Can't compile iOS #776

CripyIce opened this issue Oct 24, 2021 · 8 comments
Assignees
Labels
info required The issue author didn't provide required informations.

Comments

@CripyIce
Copy link

Describe the bug
Trying to build my project and I get the following error:

    /Users/eitanaflalo/development/flutter/.pub-cache/hosted/pub.dartlang.org/better_player-0.0.77/ios/Classes/CacheManager.swift:121:62: error: value of optional type 'Data?' must be unwrapped to a value of type 'Data'
                        playerItem = CachingPlayerItem(data: data!, mimeType: mimeTypeResult.1, fileExtension: mimeTypeResult.0)

To Reproduce
Steps to reproduce the behavior:

  1. Add the library to the project
  2. Compile for iOS

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.3, on macOS 11.6 20G165 darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.2)
[✓] Connected device (3 available)

• No issues found!

Better Player version

  • Version:

Smartphone (please complete the following information):

  • Device: Simulator iPhone 13
  • OS: iOS 15.0
@CripyIce CripyIce added the new issue New issue which has not been checked yet label Oct 24, 2021
@adrianvintu
Copy link

Any estimates when this will work?

@jhomlala
Copy link
Owner

@adrianvintu please don't ask for estimate and read this: #702

To anyone who's having problem:
From my perspective everything is fine with BP. There's issue with your project configuration.

  • Please check if error happens on clear project. Create clear project and add BP dependency.
  • Try to remove other dependencies to see which collide with Better Player.
  • If nothing helps, please provide reproducible example.

Here's more details: #714

I'm able to help only if you will provide reproducible example.

@barees63
Copy link

I'm pretty rusty on Swift atm but if I change:

playerItem = CachingPlayerItem(data: data!, mimeType: mimeTypeResult.1, fileExtension: mimeTypeResult.0)

to

playerItem = CachingPlayerItem(data: data!!, mimeType: mimeTypeResult.1, fileExtension: mimeTypeResult.0)

It compiles fine. I also noticed in other projects (eg. the example for Better Player) I don't have this issue. FWIW My project is set to target iOS 13.0

@jhomlala
Copy link
Owner

jhomlala commented Nov 7, 2021

Changing example project target to iOS 13.0 didn't trigger this issue on my side. In order to fix this issue I need reproducible example.

@jhomlala jhomlala added info required The issue author didn't provide required informations. and removed new issue New issue which has not been checked yet labels Nov 7, 2021
@jblough
Copy link

jblough commented Nov 12, 2021

From a Swift perspective, would it be preferred to write

            // Trying to retrieve a track from cache syncronously
            let data = try? storage?.object(forKey: _key)
            if data != nil {

as

            // Trying to retrieve a track from cache synchronously
            if let data = try? storage?.object(forKey: _key) {

on line 112 of CacheManager.swift ?

@obrunsmann
Copy link

obrunsmann commented Dec 3, 2021

Edit: revised, see below

Have the same issue. I first thought that it's because we're on swift 4 so I migrated to a fresh swift 5 project. Still the same issue.

/Users/oliver/flutter/.pub-cache/hosted/pub.dartlang.org/better_player-0.0.79/ios/Classes/CacheManager.swift:121:63: error: cannot force unwrap value of non-optional type 'Data'

Adding a !! from #776 (comment) solves the issue temporarily.

@obrunsmann
Copy link

@jhomlala the reason is actually what I wrote before. So our project was on Swift 4, migration to Swift 5 solved the problem.

Please add some note to the package that only Swift 5 projects are supported or don't use optional try for Swift 4 support; this costs hours of debugging, especially for these guys, having no experience in swift.

Solution for anyone having the same problem:
You might see this if you have created a flutter 1 project. You can check your project's swift version here:
image

What I did to upgrade to latest flutter iOS scaffold:

cd projectfolder
rm -rf ios/
flutter create --platforms=ios .

Just check the basic settings like package identifier, certificates and app icon (by the way, suggest the following so that you have no effort: https://pub.dev/packages/flutter_launcher_icons) and then you're ready with swift 5.

Credits to @mitghi for the solution

@jhomlala
Copy link
Owner

I've added info about Swift 5. Thanks for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info required The issue author didn't provide required informations.
Projects
None yet
Development

No branches or pull requests

6 participants