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

New iOS error: Unexpectedly found nil while unwrapping an Optional value #30

Open
herrmayr opened this issue May 21, 2020 · 2 comments
Open

Comments

@herrmayr
Copy link

herrmayr commented May 21, 2020

In the latest build of my app, without making any changes to the part where the app uses flutter_audio_recorder, the app crashes when trying to start a recording.

Here is the error:

.wav /var/mobile/Containers/Data/Application/C35343CA-6921-4411-B589-3ACA6427E5DD/Library/Application Support/temp_voicerecording.wav
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file /Users/......./development/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.5.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift, line 75

In Xcode, the debugger jumps to this line:

audioRecorder = try AVAudioRecorder(url: URL(string: mPath)!, settings: settings)
with the error

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Since I haven't changed anything around the audio recorder implementation, I suspect a new bug regarding iOS with this package? Android works fine by the way...

Of course, I might have made a mistake I'm currently anaware of - any hints would be greatly appreciated!

@herrmayr
Copy link
Author

herrmayr commented Jun 3, 2020

I found the root of the problem, but I don't have a fix:
When the path contains a space, the error I mentioned above appears.

The iOS path to the app's temp folder does contain a path since it's called "Application Support", so I can only hot-fix this issue by using the app's user-visible documents folder, which is not ideal ...

@DitoHI
Copy link

DitoHI commented Jun 12, 2020

Thanks for pointing the cause of the problem. While waiting the library fixes this problem, I remove any space in the first argument of FlutterAudioRecorder.

The temporary fix such as:

var fileDir = 'example name of file';
var recorder = FlutterAudioRecorder(
   '$fileDir.wav'.replaceAll(' ', ''),
   audioFormat: AudioFormat.WAV,
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants