Ios Keyboard Limitations
by @usimic
iOS keyboard extension technical limitations and workarounds. Use when planning or building iOS custom keyboards with voice/audio features, dictation, or system integration needs. Covers memory limits, sandbox restrictions, microphone access, app launching, and viable alternative architectures.
clawhub install ios-keyboard-limitationsπ About This Skill
name: ios-keyboard-limitations description: iOS keyboard extension technical limitations and workarounds. Use when planning or building iOS custom keyboards with voice/audio features, dictation, or system integration needs. Covers memory limits, sandbox restrictions, microphone access, app launching, and viable alternative architectures.
iOS Keyboard Extension Limitations
When building iOS custom keyboards with voice/audio features, these are the hard limitations discovered through the PolyVoice project.
π΄ Hard Limitations (Cannot be worked around)
1. Microphone Access β DISALLOWED
Keyboard extensions cannot access the microphone.AVAudioRecorder will fail with permission errorSFSpeechRecognizer is unavailableWhy: Apple security model β keyboards run in sandbox and could keylog audio.
2. Open Other Apps β BLOCKED
Keyboards cannot programmatically open the main app or any other app.UIApplication.shared.open() returns falsemyapp://) ExtensionContext.open() not availableWhy: Prevents malicious keyboards from launching apps without user consent.
3. Memory Limit β ~50MB
Keyboard extensions have strict memory limits (~30-60MB).Mitigation:
4. No Persistent Storage
UserDefaults unavailable, only App Groups.UserDefaults doesn't persistUserDefaults(suiteName: "group.com.company.app")5. Network Requires "Full Access"
API calls fail without user enabling "Allow Full Access" in Settings.π‘ Partial Workarounds (User friction)
The "Open App" Workaround
Goal: Let user tap a button to open main app for recording.Attempt:
// This does NOT work
extensionContext?.open(URL(string: "myapp://record")!)
Reality: Must use UIApplication.shared.open() outside extension context, but keyboards can't call this.
The Manual Switch Pattern
What actually works (with friction):1. User taps button in keyboard β Shows alert: "Open PolyVoice to record?" 2. User manually switches to main app (Home button, swipe, etc.) 3. Main app detects active session (via App Groups / shared state) 4. Main app auto-records on appear 5. Auto-stops on silence (2 seconds) 6. Auto-copies to clipboard 7. User manually switches back to target app 8. Keyboard auto-pastes on reappear
User flow:
Keyboard β Tap mic β [Manual: Switch to app] β App auto-records β
[Manual: Switch back] β Keyboard auto-pastes
Friction points:
π’ Alternative Architectures
Option 1: Share Extension (Better for Audio)
Use Share Sheet instead of keyboard.Limitation: Not a keyboard β user must open share sheet per text field.
Option 2: Full App Mode
Don't use keyboard extension β use main app only.Benefit: No memory limits, full mic access, reliable. Cost: More friction than keyboard.
Option 3: Siri Shortcuts Integration
Provide Siri Shortcuts for voice-to-text.Limitation: Not instant, requires Siri setup.
π Decision Matrix
| Approach | Mic Access | Memory | User Friction | Apple Approved | |----------|-----------|---------|---------------|----------------| | Keyboard extension | β No | β οΈ 50MB | Low (if no audio) | β Yes | | Keyboard + audio workaround | β No | β οΈ 50MB | π΄ High | β Yes | | Share extension | β Yes | β Full | π‘ Medium | β Yes | | Full app only | β Yes | β Full | π‘ Medium | β Yes | | Siri Shortcuts | β Yes | β Full | π‘ Medium | β Yes |
π― Recommendation
For voice dictation/AI transcription:
1. Don't build a keyboard extension β the limitations make it frustrating 2. Use Share Extension β Apple-supported, full capabilities 3. Or full app β simplest to build, most reliable 4. Add Shortcuts β for power users who want speed
For non-audio keyboards (emoji, translation, etc.):
Keyboard extension works great. Just avoid audio features.