iOS平台下使用Kotlin调用并录制外接麦克风的可行性及技术选型建议
Hey there! Let's break down your questions clearly—since you know a bit of Kotlin but no Swift, I get why you’re weighing this option for your iOS app.
Is it possible to call and record with an external microphone on iOS using Kotlin?
Absolutely. Thanks to Kotlin Multiplatform Mobile (KMM), you can write Kotlin code that interfaces directly with iOS’s native APIs. Recording with an external microphone relies on iOS’s AVFoundation framework, and KMM’s interop system lets you bridge Kotlin to these native components seamlessly.
Here’s a high-level breakdown of how it would work:
- Use KMM’s
expect/actualpattern: Define anexpectfunction in your shared Kotlin code for handling audio recording, then write theactualimplementation in your iOS-specific Kotlin module. - In the iOS
actualcode, you’ll call into AVFoundation classes likeAVAudioSession(to detect and select the external microphone as the input device) andAVAudioRecorder(to manage the recording logic). Kotlin can interact directly with these Swift/Objective-C APIs without you needing to write Swift code yourself.
Should you use Kotlin for this iOS-only app?
This depends entirely on your broader goals:
If you’re building a cross-platform app (Android + iOS)
KMM is a fantastic choice. You can share core business logic (like file sync, photo handling) across both platforms, and only write the platform-specific audio recording code once per OS. Your existing Kotlin knowledge will reduce redundant learning, making this a efficient approach.
If this is an iOS-only app
I’d lean toward recommending Swift instead, and here’s why:
- While KMM works for iOS, debugging AVFoundation-related issues or configuring advanced audio settings will require you to understand iOS’s native concepts. Most iOS documentation, tutorials, and community support are in Swift/Objective-C—without Swift knowledge, you’ll struggle to troubleshoot problems or find solutions quickly.
- Xcode’s tooling (debuggers, performance profilers, simulator tools) is deeply optimized for Swift. Using Kotlin on iOS means you’ll be working outside the most streamlined workflow for the platform.
- Learning Swift for iOS-only development might actually be more efficient than learning KMM’s interop rules plus iOS native concepts on top of your existing Kotlin knowledge. Swift is built specifically for iOS, and the learning curve for basic audio recording tasks is manageable.
Quick Practical Tips
- If you go the KMM route: Start with small, testable chunks of audio code to get comfortable with interop. Focus first on understanding how
AVAudioSessionselects input devices (including external mics)—that’s the core of your use case. - If you switch to Swift: Apple’s official AVFoundation docs have great step-by-step guides on audio recording, and there are tons of beginner-friendly tutorials to get you up to speed with basic iOS development fast.
内容的提问来源于stack exchange,提问作者dankal444

