rmbrone / flutter_audio_recorder

Flutter plugin that can support audio recording and level metering
MIT License
121 stars 150 forks source link

Error while running Pod install #4

Closed iNima closed 4 years ago

iNima commented 4 years ago

Hi there and thanks for sharing this plugin with the community.

I'd like to use this plugin in both iOS and Android but when I run pod install for the iOS I receive this error:

- `flutter_audio_recorder` does not specify a Swift version and none of the targets (`Runner`) integrating it has the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

I think you need to add the SWIFT_VERSION in your podspec file. For example, the current SWIFT_VERSION in my app is 4.2

Could you please check this and modify your code?

nikli2009 commented 4 years ago

hi @iNima , thanks a lot ! I just added this config(swift_version = 4.0), please let me know if this works for you. Latest version is 0.4.5

iNima commented 4 years ago

Hi @nikli2009 , thanks for your prompt update.

Yes, now the pod install is done correctly without any error but when I'm building the app it is not successful and shows these two errors:

/Users/iNima/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.4.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift:69:108: error: 'AVAudioSessionCategoryOptions' has been renamed to 'AVAudioSession.CategoryOptions'
                    try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker)
                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                               AVAudioSession.CategoryOptions

    AVFoundation.AVAudioSessionCategoryOptions:2:18: note: 'AVAudioSessionCategoryOptions' was obsoleted in Swift 4.2
    public typealias AVAudioSessionCategoryOptions = AVAudioSession.CategoryOptions
                     ^
    /Users/iNima/.pub-cache/hosted/pub.dartlang.org/flutter_audio_recorder-0.4.5/ios/Classes/SwiftFlutterAudioRecorderPlugin.swift:153:68: error: cannot call value of non-function type 'AVAudioSession.RecordPermission'
                switch AVAudioSession.sharedInstance().recordPermission(){
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

The first one is related to the Swift version. The latest Swift version of my app is 4.2 by the way but I don't know why that error happened. Maybe using the deprecated AVAudioSessionCategoryOptions is not supported in 4.2 anymore and it is not backward compatible!

nikli2009 commented 4 years ago

Thanks for all the details information :) @iNima my apology for the late response. I added some swift version specific code to help Xcode to compile for swift 4.2 below and 4.2 above. Hope this can resolve this issue. ;) Latest version is 0.4.7

Just in case it doesn't work, pls try

  1. Xcode -> Product -> Clean Build Folder.
  2. Clear /ios/Pods folder, Delete /ios/Podfile.lock, Clear /ios/.symlinks/ folder
  3. Run flutter pub get
  4. cd /ios, run pod install
  5. in Xcode, try Product -> Run
iNima commented 4 years ago

Great! Thanks @nikli2009 It works correctly now. There is only one minor issue which is the version of the plugin in the flutter_audio_recorder.podspec which is still 0.4.5 instead of 0.4.7. https://github.com/shadow-app/flutter_audio_recorder/blob/8b3b58e55ce61e8de7ae5a8eb8e93653a9f06e26/ios/flutter_audio_recorder.podspec#L6 It is not an impediment by the way. The only drawback of it is showing an incorrect version in Podfile.lock and Manifest.lock.

nikli2009 commented 4 years ago

Haha my mistake, just updated it in 0.4.8. @iNima Going to close this issue as It's working for you now. ;)