페이지 이동경로
  • Docs>
  • iOS>
  • Getting started

iOS

Getting started

This document guides how to use the Kakao SDK for iOS("iOS SDK") provided by the Kakao API platform.

Before you begin

Requirements

The minimum requirements for iOS SDK are below.

  • Xcode 14.3 or higher
  • iOS 13.0 or higher
  • iOS Deployment Target 13.0 or higher
  • Swift 5.0 or higher
Note: External library dependency

The iOS SDK uses the following libraries that are automatically installed when installing the iOS SDK.

Module

Swift
RxSwift
Module Description
KakaoSDKCommon Common module that contains essential elements
KakaoSDKCommonCore Common module without network features
KakaoSDKAuth Authentication
KakaoSDKUser Kakao Login, User Management
KakaoSDKShare Kakao Talk Sharing
KakaoSDKTalk Kakao Talk Social, Kakao Talk Messaging
KakaoSDKTemplate Message template
KakaoSDKNavi Kakao Navi
KakaoSDKFriend Friend picker
KakaoSDKFriendCore Module for picker
KakaoSDKCert Kakao Certificate
KakaoSDKCertCore Module for Kakao Certificate
Module Description
RxKakaoSDKCommon Common module that contains essential elements
RxKakaoSDKCommonCore Common module without network features
RxKakaoSDKAuth Authentication
RxKakaoSDKUser Kakao Login, User Management
RxKakaoSDKShare Kakao Talk Sharing
RxKakaoSDKTalk Kakao Talk Social, Kakao Talk Messaging
RxKakaoSDKFriend Module for picker
Note: Module dependency

Some modules in the Kakao SDK are dependent on another module. If you add the Common or Auth module, its subordinate modules are automatically added together.

Kakao SDK module dependency tree

Platform

Set iOS app information on [My Application] > [Platform]. Refer to Platform.

Project settings

Allowlist

Since iOS 9.0, iOS only allows apps registered in Allowlist to enhance security. Register Allowlist to allow the app to run Kakao apps, such as Kakao Talk, Kakao Navi, and so on.

  1. Add the LSApplicationQueriesSchemes key with an array type on [Info] > [Custom iOS Target Properties]
  2. Add [Item] kakaokompassauth, kakaolink, and kakaoplus to the LSApplicationQueriesSchemes key for the Custom URL Scheme.
How to register Allowlist in Xcode

Or add the keys manaully in the Info.plst file as follows.

 <key>LSApplicationQueriesSchemes</key>
  <array>
      <!-- Login with Kakao Talk -->
      <string>kakaokompassauth</string>
      <!-- Kakao Talk Sharing -->
      <string>kakaolink</string>
      <!-- Kakao Talk Channel -->
      <string>kakaoplus</string>
  </array>
Caution: Change key for allowlist

For Xcode 14 or above, the key for allowlist may be automatically converted from the current key LSApplicationQueriesSchemes to the new key Queried URL Schemes. The Info.plist file internally uses the existing key. When modifing the Info.plist file directly, use the current key.

URL Schemes

Set the Native app key in kakao${YOUR_NATIVE_APP_KEY} format on [Info] > [URL Type] > [URL Schemes]. For example, if your Native app key is 123456789, set 'URL Schemes' to "kakao123456789".

How to set custom URL scheme in Xcode

The URL Schemes are used to generate the Custom URL Scheme. The Custom URL Scheme is used to run an app through a Kakao Talk message or to go back to the app after logging in through Kakao Talk or Kakao Account. The Custom URL Schemes are in the following format.

  • Kakao Login: kakao${NATIVE_APP_KEY}://oauth
  • Kakao Talk Sharing: kakao${NATIVE_APP_KEY}://kakaolink

Install

To install the Kakao SDK, use CocoaPods or Swift Package Manager (SPM).

Using CocoaPods

CocoaPods version 1.8 or higher is requried. Add the entire modules of the Kakao SDK or the desired modules in the Podfile in the project as below.

Swift
RxSwift
# Add all modules
pod 'KakaoSDK'

# or

# Add the desired modules
pod 'KakaoSDKCommon'  # Common module that contains essential elements
pod 'KakaoSDKAuth'  # Authentication
pod 'KakaoSDKUser'  # Kakao Login, User management
pod 'KakaoSDKTalk'  # Kakao Talk Social, Kakao Talk Messaging
pod 'KakaoSDKFriend' # Friend picker, 'Cocoapods settings for picker' is required.
pod 'KakaoSDKShare'  # Kakao Talk Sharing
pod 'KakaoSDKTemplate'  # Message default template
pod 'KakaoSDKNavi'  # Kakao Navi
pod 'KakaoSDKCert'  # Kakao Certificate
# Add all modules
pod 'RxKakaoSDK'

# or

# Add the desired modules
pod 'RxKakaoSDKCommon'  # Common module that contains essential elements
pod 'RxKakaoSDKAuth'  # Authentication
pod 'RxKakaoSDKUser'  # Kakao Login, User
pod 'RxKakaoSDKTalk'  # Kakao Talk Social, Kakao Talk Messaging
pod 'RxKakaoSDKFriend' # Friend picker, 'Cocoapods settings for picker' is required.
pod 'RxKakaoSDKShare'  # Kakao Talk Sharing
pod 'KakaoSDKTemplate'  # Message default template
pod 'KakaoSDKNavi'  # Kakao Navi
pod 'KakaoSDKCert'  # Kakao Certificate

Using Swift Package Manager

1. Add Swift Packages

Select ➊ [Project Target] > ➋ [Package Dependencies] > ➌ [Packages] and click [+].

SPM Setting screen
2. Search repository

Search the repository URL below for the iOS SDK on ➍ [Search].

SDK Repository Name Repository URL
iOS SDK kakao-ios-sdk https://github.com/kakao/kakao-ios-sdk
ReactiveX iOS SDK kakao-ios-sdk-rx https://github.com/kakao/kakao-ios-sdk-rx

Check the name of the repository and select [Branch] for ➎ [Dependency Rule]. Input the branch name as master and click ➏ [Add Packages].

Search screen
Note: How to specify the version

Set [Dependency Rule] to install a specific version. But only versions higher than 2.8.5 are available.

3. Select and install modules

On the screen presenting avaiable packages, check the desired modules on ➐ [Package Product] and click ➑ [Add Packages]. To install all of the modules, select [KakaoSDK] or [RxKakaoSDK].

Select packages

The installed iOS SDK is presented on [Packages].

Packages
Note: Target

Each target of the project requires the iOS SDK separately. To install the iOS SDK for the test app, set the [Add to Target] to the test app.

4. Set resource bundle

When using SPM to install KakaoSDKFriend and RxKakaoSDKFriend modules, set the resource bundle for the picker. Add KakaoSDKFriendResources.bundle file to [Build Phase] > [Copy Bundle Resources] by clicking [+] or drag and drop.

Initialize

Import the iOS SDK and initialize it with the Native app key. Add the codes below in AppDelegate.swift.

When using SwiftUI Life Cycle, add the codes in ${PROJECT_NAME}App instead of AppDelegate.swift.

Swift
RxSwift
SwiftUI App
import KakaoSDKCommon

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

  ...
  KakaoSDK.initSDK(appKey: "${NATIVE_APP_KEY}")
  ...

}
import RxKakaoSDKCommon

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

  ...
  RxKakaoSDK.initSDK(appKey: "${NATIVE_APP_KEY}")
  ...

}
import SwiftUI
import KakaoSDKCommon
import KakaoSDKAuth
...

@main
struct SwiftUI_testApp: App {

    ...
    init() {
        // Initialize Kakao SDK.
        KakaoSDK.initSDK(appKey: "${NATIVE_APP_KEY}")
    }
    ...

}
Note: Class name change

In iOS SDK 2.8.3, the class names, used for initialization, have been changed.
- KakaoSDKCommon → KakaoSDK
- RxKakaoSDKCommon → RxKakaoSDK