Skip to content

Guide · Open source

How to use IQKeyboardManager in iOS apps: setup and tips

Updated · written with AI from the project's own documentation and checked against our catalogue data

IQKeyboardManager is an open-source iOS library that stops the on-screen keyboard from sliding up and hiding UITextField and UITextView inputs. It is written in Swift and licensed under MIT. This guide shows iOS developers how to add it to a project, enable it, and turn on optional features such as the toolbar.

IQKeyboardManagerhackiftekhar/IQKeyboardManager · ★ 16.6k · MIT

Quick start

  1. 1Confirm your target. Check that your project targets iOS 13.0 or later and uses Xcode 13 or later.
  2. 2Add the library. Add pod 'IQKeyboardManagerSwift' to your Podfile, or use Carthage or Swift Package Manager.
  3. 3Import the module. Add import IQKeyboardManagerSwift to AppDelegate.swift.
  4. 4Enable it at launch. Set IQKeyboardManager.shared.isEnabled = true in didFinishLaunchingWithOptions.
  5. 5Test a form. Run the app and open a screen with several text fields to confirm the keyboard no longer covers the active input.
  6. 6Add optional subspecs. If you want the Previous/Next/Done toolbar, include the IQKeyboardToolbarManager subspec in your Podfile.

What IQKeyboardManager does

The keyboard on an iPhone often slides up and covers the text field or text view a user is typing in. IQKeyboardManager is meant to prevent this without you writing custom scroll-view code or subclassing your UIKit components.

According to the README, the library supports UIScrollView, UITableView and UICollectionView, works in all interface orientations, and offers a configurable keyboard distance and class-level enable/disable control.

  • Automatic keyboard avoidance for UITextField and UITextView
  • Support for UIScrollView, UITableView and UICollectionView
  • Configurable keyboard distance
  • Class-level enable/disable control

Check the requirements before you install

The README lists iOS 13.0 as the minimum deployment target for IQKeyboardManagerSwift and Xcode 13 as the minimum Xcode version. The library is for iOS only, and the README says the Objective-C version has moved to a separate repository.

The Swift version you can use depends on your Xcode release. The README's support table maps Xcode versions to IQKeyboardManagerSwift versions, so check that table if you build with an older toolchain.

  • iOS 13.0 deployment target or later
  • Xcode 13 or later
  • CocoaPods, Carthage, or Swift Package Manager

Install IQKeyboardManager with CocoaPods, Carthage or Swift Package Manager

The simplest route in the README is CocoaPods. Add the pod line to your Podfile, then install as usual. If you need an older release that matches your Swift version, the README shows how to pin a version using the support table.

For Carthage, add the GitHub dependency to your Cartfile and run the build command the README gives, then drag IQKeyboardManagerSwift.xcframework into your project. Add only one framework, not both. For Swift Package Manager, open File, then Swift Packages, then Add Package Dependency, and search for the repository URL listed in the README.

The README says source code installation is not supported since version 7.2.0, because the library now depends on other independent libraries.

pod 'IQKeyboardManagerSwift'

Enable IQKeyboardManager in your app

Import the module in AppDelegate.swift and turn the library on when the app launches. The README's minimal setup sets the shared instance's isEnabled property to true inside didFinishLaunchingWithOptions. After that, the keyboard adjusts automatically for text fields.

The README's full setup also uses enableAutoToolbar, but it marks that property as deprecated and recommends the IQKeyboardToolbarManager pod instead.

  • Import IQKeyboardManagerSwift
  • Set IQKeyboardManager.shared.isEnabled = true at launch
import IQKeyboardManagerSwift // Enable keyboard management IQKeyboardManager.shared.isEnabled = true

Add optional features with subspecs

IQKeyboardManagerSwift is split into subspecs. The core is always included. Others add features such as the Previous/Next/Done toolbar (IQKeyboardToolbarManager), return key handling (IQKeyboardReturnManager), tap-to-resign (Resign), keyboard appearance (Appearance) and UITextView placeholder support (IQTextView). By default all subspecs are included, so you can narrow the list to what you need.

To include only one subspec, name it in your Podfile as the README example shows.

  • Core: basic keyboard distance management (always included)
  • Appearance: keyboard appearance configuration
  • IQKeyboardReturnManager: return key handling
  • IQKeyboardToolbarManager: Previous/Next/Done toolbar
  • IQTextView: UITextView with placeholder support
  • Resign: tap-to-resign keyboard
pod 'IQKeyboardManagerSwift/IQKeyboardToolbarManager'

Know when not to ship IQKeyboardManager

The README is firm on this point: if you are building an SDK, library or framework, do not add IQKeyboardManager as a dependency. Doing so could discourage other developers who use their own solution from adopting your project.

If IQKeyboardManager conflicts with a third-party library's UI, the README says it is the developer's responsibility to enable or disable IQKeyboardManager when that UI is presented or dismissed.

What people use it for

  • Login and sign-up screens with several text fields stacked vertically
  • Long forms in a table view or collection view where inputs sit below the keyboard
  • Message or notes screens that use UITextView and need the cursor kept visible
  • Forms that benefit from a Previous/Next/Done toolbar via the IQKeyboardToolbarManager subspec

Frequently asked questions

Do I need to write code to use IQKeyboardManager?

The README says no custom code is required to prevent the keyboard covering inputs. You add the library and set IQKeyboardManager.shared.isEnabled to true at launch, which is one line.

Is IQKeyboardManager free and open source?

Yes. The repository is licensed under the MIT license, as stated in the README and the LICENSE.md file linked from it.

What iOS version does IQKeyboardManager support?

The README lists iOS 13.0 as the minimum deployment target for IQKeyboardManagerSwift, with Xcode 13 as the minimum Xcode version.

How do I install IQKeyboardManager with CocoaPods?

Add pod 'IQKeyboardManagerSwift' to your Podfile. The README also shows how to pin a specific version using the Swift support table.

Can I use IQKeyboardManager with Objective-C?

The README says the Objective-C version has moved to a separate repository, so this Swift version is the one documented here.

Are there alternatives to IQKeyboardManager?

The comparable projects listed for this item are TPKeyboardAvoiding and RSKeyboardAvoidingScrollView, which also handle keyboard avoidance on iOS.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

IQKeyboardManager suits iOS app developers with forms or screens that have several text inputs, especially teams that want keyboard avoidance without custom scroll-view code. Do not use it inside an SDK or framework, since the README advises against shipping it as a dependency. Teams that need Objective-C only, or that do not target iOS, should look elsewhere.

Install options & downloads