speech_recognition
speech_recognition copied to clipboard
XCode10 required => Xcode Build Fails (AVAudioSession?)
I'm unable to run an iOS build. The following errors happen to me running against iOS 12. This is a simulator (perhaps a reason?), have not tried on a device. Please let me know if you need more info.
XCode 10.1 Project is swift (Language version 4)
flutter run
Launching lib/main.dart on iPhone XR in debug mode...
Running pod install... 1.2s
Starting Xcode build...
Xcode build done. 1.6s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET path_provider OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/me/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/speech_recognition-0.3.0/ios/Classes/SwiftSpeechRecognitionPlugin.swift:109:34: error: type
'AVAudioSession.Category' (aka 'NSString') has no member 'record'
try audioSession.setCategory(AVAudioSession.Category.record, mode: .default)
^~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
/Users/me/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/speech_recognition-0.3.0/ios/Classes/SwiftSpeechRecognitionPlugin.swift:110:30: error: type
'AVAudioSession.Mode' (aka 'NSString') has no member 'measurement'
try audioSession.setMode(AVAudioSession.Mode.measurement)
^~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
/Users/me/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/speech_recognition-0.3.0/ios/Classes/SwiftSpeechRecognitionPlugin.swift:188:9: error: value of
type 'AVAudioSession.Category' (aka 'NSString') has no member 'rawValue'
return input.rawValue
^~~~~ ~~~~~~~~
Could not build the application for the simulator.
Error launching application on iPhone XR.
~/Documents/personal/xglasses/x 2 ↵ 7238 16:28:02
$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.9, on Mac OS X 10.13.6 17G65, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.29.1)
[✓] Connected device (1 available)
• No issues found!
ok.... Here's how i fixed this:
- remove the dependency and get flutter app to compile as was before installing
speech_recognition
- In XCode, update the target to latest Swift Syntax (apparently, needs to be 4.2?)
- add back the dependency to
pubspec.yml
in flutter app - in the
SwiftSpeechRecognitionPlugin.swift
file, change line 111 (see old commented line)
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(AVAudioSession.Category.record, mode: .default)
try audioSession.setMode(AVAudioSession.Mode.measurement)
// try audioSession.setActive(true, with: .notifyOthersOnDeactivation)
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
i'd PR this, but don't have the time right now. Just making a note here.
I'm having a similar issue... @mcconkiee 's fix didn't work for me.
`Launching lib/main.dart on iPhone 7 in debug mode... Xcode build done. 1.3s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ === BUILD TARGET speech_recognition OF PROJECT Pods WITH CONFIGURATION Debug === /Users/Downloads/speech_recognition-master/ios/Classes/SwiftSpeechRecognitionPlugin.swift:186:76: error: 'Category' is not a member type of 'AVAudioSession' fileprivate func convertFromAVAudioSessionCategory(_ input: AVAudioSession.Category) -> String {
try audioSession.setCategory(AVAudioSession.Category.record, mode: .default)
^~~~~~~~~~~~~~ ~~~~~~~~
AVFoundation.AVAudioSession:23:14: note: did you mean 'category'?
open var category: String { get }
^
/Users/Downloads/speech_recognition-master/ios/Classes/SwiftSpeechRecognitionPlugin.swift:112:30: error: type 'AVAudioSession' has no member 'Mode'
try audioSession.setMode(AVAudioSession.Mode.measurement)
^~~~~~~~~~~~~~ ~~~~
AVFoundation.AVAudioSession:33:14: note: did you mean 'mode'?
open var mode: String { get }
^
ObjectiveC.NSObject:160:15: note: did you mean 'zone'?
open func zone() -> NSZone!
^
ObjectiveC.NSObject:162:21: note: did you mean 'zone'?
open class func zone() -> NSZone!
^
/Users/Downloads/speech_recognition-master/ios/Classes/SwiftSpeechRecognitionPlugin.swift:114:48: error: extra argument 'options' in call
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
~^~~~~~~~~~~~~~~~~~~~~~~~~~
Could not build the application for the simulator.
Error launching application on iPhone 7.
Exited (sigterm)
`
Just to follow up... my errors above were because I wasn't using Swift 4.2 (which requires XCode 10). The syntax used in this package is specific to Swift 4.2.... compiling with 4.1 won't work. Also, the Podfile requires:
config.build_settings['SWIFT_VERSION'] = '4.2'
just below the 'ENABLE_BITCODE' line, and also:
use_frameworks!
just below
target 'Runner' do
This was all very painful to figure out for myself... perhaps the readme should make it clear?
sorry I did not realized that 4.2 was available for XCode10 only. I updated the README.
I was able to make it running by changing my podfile as that:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
sorry I did not realized that 4.2 was available for XCode10 only. I updated the README.
I still dont see the config on the README man. Still struggle on this one, fix follow @ROTGP & @shinayser but no luck. When I ran debug, this is showing:
Installing speech_recognition (0.3.0) - Running pre install hooks [!] Unable to determine Swift version for the following pods: -
speech_recognition
does not specify a Swift version and none of the targets (Runner
) integrating it have theSWIFT_VERSION
attribute set. Please contact the author or set theSWIFT_VERSION
attribute in at least one of the targets that integrate this pod.