Setting up your project

This topic explains how to integrate the LINE SDK for iOS Swift into your iOS project and apply necessary configurations.

To make your app compatible with the latest iOS versions and make full use of cutting-edge features, we strongly recommend you follow this installation guide and use the latest version of the LINE SDK for iOS Swift.

Prerequisites

To build and use the LINE SDK for iOS Swift, you need:

  • A provider and a LINE Login channel. You can create both in the LINE Developers console.
  • iOS 10.0 or later as the deployment target
  • Xcode 10 or later

You can use the LINE SDK for iOS Swift with either Swift or Objective-C code. This guide assumes that you use Swift code to implement the LINE SDK for iOS Swift. To use Objective-C code to integrate the LINE SDK for iOS Swift, see Using the SDK with Objective-C.

Installation

The LINE SDK for iOS Swift is not compatible with previous LINE SDK for iOS Objective-C versions. If you are upgrading the version of the LINE SDK, see Upgrading the SDK before proceeding with the upgrade.

CocoaPods

If you are not familiar with CocoaPods, refer to the CocoaPods Getting Started Guide. You will need the CocoaPods gem installed on your machine before integrating the LINE SDK for iOS Swift into your app through CocoaPods.

  1. Once your Podfile is prepared, add the pod command below to your target:
    platform :ios, '10.0'
    use_frameworks!
    
    target '<Your App Target Name>' do
        pod 'LineSDKSwift', '~> 5.0'
    end
    
  2. Run the following command:
    $ pod install
    

The LINE SDK for iOS Swift will be downloaded and integrated into your Xcode workspace.

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

  1. To install the Carthage tool, use Homebrew.
    $ brew update
    $ brew install carthage
    
  2. To integrate the LINE SDK for iOS Swift into your Xcode project using Carthage, specify the GitHub repository of the SDK in your Cartfile as below:
    github "line/line-sdk-ios-swift" ~> 5.0
    
  3. Run the following command to build the LINE SDK for iOS Swift:
    $ carthage update line-sdk-ios-swift
    

Now you can add the built LineSDK.framework file to your Xcode project by following the steps described in the following sections.

Linking the LineSDK.framework file to your Xcode project

Drag and drop the LineSDK.framework file from the Carthage/Build/iOS folder to the "Linked Frameworks and Libraries" section on your application target’s “General” settings tab.

Copying the LineSDK.framework file during the build phase

  1. Click the "+" icon on your application target's "Build Phases" settings tab and choose "New Run Script Phase". Create a run script with the following content:
    /usr/local/bin/carthage copy-frameworks
    
  2. Add the path to the LineSDK.framework file under the "Input Files" section:
    $(SRCROOT)/Carthage/Build/iOS/LineSDK.framework
    
  3. Add the path to the LineSDK.framework file under the "Output Files" section:
    $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/LineSDK.framework
    

The run script should look like this:

Linking your app to your channel

Linking your app to a LINE Login channel requires some configuration. Go to the "App settings" page of the console and complete the following fields.

  • iOS bundle ID: Bundle identifier of your app found in the "General" tab in your Xcode project settings. Must be lowercase. For example, com.example.app. You can specify multiple bundle identifiers by entering each one on a new line.
  • iOS scheme: Set to line3rdp. followed by the bundle identifier. For example, if your bundle identifier is com.example.app, set the iOS scheme to line3rdp.com.example.app. Only one iOS scheme can be specified.
  • iOS universal link: Optional. Set to the universal link configured for your app. For more information on how to handle the login process using a universal link, see Universal Links support.

iOS app settings

Configuring the Info.plist file

In Xcode, right-click your app's Info.plist file and select "Open As" > "Source Code". Insert the following snippet just before the last </dict> tag:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <!-- Specify URL scheme to use when returning from LINE to your app. -->
            <string>line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        </array>
    </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <!-- Specify URL scheme to use when launching LINE from your app. -->
    <string>lineauth2</string>
</array>

This snippet adds the following settings:

Key Description
CFBundleURLSchemes Use line3rdp.$(PRODUCT_BUNDLE_IDENTIFIER) to define the URL scheme needed to open your app. iOS stores this URL scheme for later reference. LINE Login uses this scheme to open your app after the LINE Platform returns a login result.
Note: The URL scheme lineauth2 is already used to activate LINE. Do not use this scheme in CFBundleURLSchemes.
LSApplicationQueriesSchemes Specify lineauth2 to allow launching of LINE from your app. The app will launch LINE as part of the login process.

{{ $t("form.question.helpful") }}

{{ $t("form.question.detail") }}

{{ $t("form.question.improve") }}

{{ $t("form.info.start") }}{{ $t("form.info.link") }}{{ $t("form.info.end") }}


{{ $t("form.result.success") }}
{{ $t("form.result.error") }}
{{ $t("form.result.errorLink") }}