Skip to content

Fix iOS build and microphone capture for Defold Extender - #2

Open
jcypher wants to merge 5 commits into
HalfstarDev:mainfrom
jcypher:main
Open

Fix iOS build and microphone capture for Defold Extender#2
jcypher wants to merge 5 commits into
HalfstarDev:mainfrom
jcypher:main

Conversation

@jcypher

@jcypher jcypher commented Jul 28, 2026

Copy link
Copy Markdown

Fixes #1

Summary

Makes defold-mic build and record on iOS under Defold Extender, without changing the non-Apple capture path.

On iOS, miniaudio pulls in AVFoundation (Objective-C). Compiling mic.cpp as pure C++ fails on Foundation headers (@class NSString, etc.). Extender’s allowed ext.manifest flags also don’t include -x objective-c++, so this PR compiles Apple targets via mic.mm and keeps mic.cpp for Windows / Linux / HTML5 / Android.

Changes

  • ObjC++ on Apple: shared implementation in mic/src/mic_body.inl; mic.mm includes it on iOS/macOS; mic.cpp includes it everywhere else. Extender only compiles .mm on Apple platforms.
  • ext.manifest: link AVFoundation, AudioToolbox, Foundation + -ObjC for ios / arm64-ios / x86_64-ios.
  • Plist merge stubs: rename mic/manifests/{ios,osx}/mic-Info.plistInfo.plist so Defold’s merge tool actually picks up NSMicrophoneUsageDescription.
  • iOS audio session: init miniaudio with PlayAndRecord (+ default_to_speaker, mix_with_others). Before capture / device enumeration, re-apply that session (and re-init the miniaudio context if capture devices are empty) because Defold’s OpenAL sound init can clear capture after launch.

Testing

  • Verified: physical iPhone — mic.request_permissionmic.start / meter → mic.stop → playback.
  • Also working in consumer project: macOS and HTML5.
  • Not device-tested here: Windows, Linux, Android. Static review: Android AndroidManifest.xml unchanged; non-iOS AppInitialize still uses a NULL ma_context_config (same as before); iOS-only session helpers are behind DM_PLATFORM_IOS.

Notes for reviewers

  • Call mic.request_permission() on Apple before recording (unchanged API).
  • No changes to noise-gate / normalize DSP behavior.

jcypher and others added 5 commits July 28, 2026 15:01
Compile mic.cpp as ObjC++ with AVFoundation frameworks, rename plist stubs so Defold merges them, and set PlayAndRecord so recording can coexist with engine audio.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop Extender-rejected -x objective-c++ flags; share implementation in mic_body.inl with mic.mm on Apple and mic.cpp elsewhere.

Co-authored-by: Cursor <cursoragent@cursor.com>
OpenAL init clears capture devices post AppInitialize; re-apply AVAudioSession and re-init miniaudio context before is_connected/start.

Co-authored-by: Cursor <cursoragent@cursor.com>
Deactivate AVAudioSession before switching to PlayAndRecord so OpenAL cannot block the category change; prepare on get_devices too.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep PlayAndRecord session restore; drop temporary build markers and verbose is_connected probes.

Co-authored-by: Cursor <cursoragent@cursor.com>
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

Successfully merging this pull request may close these issues.

iOS build fails: mic.cpp compiled as C++ can't parse Objective-C Foundation headers via miniaudio

1 participant