[Swift] How to implement the LINE login function


Since I implemented the LINE login function when creating a personal application, We will share the command after the memorandum.

Please take a look at the code on GitHub. -> https://github.com/onishi-app/LINELogin

environment ・ Apple Swift version 5.3 ・ XCode version 12.3 ・ LINE Developers 5.2

Completed form


Implementation method

I will explain the mounting method from 1.

We have implemented the functions by referring to the following site, so we hope that you will also refer to them. -> Reference site

Basically, you can create it by referring to here. The flow when I created it is also described below. (Flow of adding channels to Developer, handling of errors, etc.) LINE Developers First of all, go to LINE Developer. Log in to your LINE account from the login on the upper right. スクリーンショット 2021-01-11 8.53.55.png

Scroll down and create a new provider. スクリーンショット 2021-01-11 8.53.58.png

Create a provider because you can use any name you like. スクリーンショット 2021-01-11 8.54.08.png

Then the provider will be created, so Create a LINE login channel from the created provider. スクリーンショット 2021-01-11 8.54.21.png

Fill in the required fields and create a channel. When created, the channel ID is defined. スクリーンショット 2021-01-11 8.56.41.png

Since you need to enter the bundle ID of the app after creating the channel, Create an app that implements the LINE login function.

For bundle ID, the bundle identifier in the image below is the bundle ID. スクリーンショット 2021-01-11 9.05.30.png

If you switch the channel tab to LINE login, there is a place to enter the iOS bundle ID, so Enter the bundle ID of the app you just created there. スクリーンショット 2021-01-11 9.06.20.png

This is the end of LINE Developer.

Then open a terminal. ** * CocoaPods and Homebrew must be installed Please install it in advance. ** **


Move the directory.

cd /**/**/**/App folder

If you don't know how to operate the terminal If you drag and drop the app folder from Finder after cd, it will be entered automatically.

Create a podfile.

$ pod init 

Add the following contents to the Podfile. (It doesn't matter whether you use the Finder or the vi command.)

pod 'LineSDKSwift', '~> 5.0'

Install the pod.

pod install


Create and edit a Cartfile. (It doesn't matter whether you use the Finder or the vi command. This time I will describe the operation from vi. )

$ vi Cartfile

Press "i" to enter edit mode. After entering the following command, press "esc"-> ": wq". (** vi command ** You can find the operation method by searching.)

github "line/line-sdk-ios-swift" ~> 5.0

Update when the screen returns.

$ carthage update line-sdk-ios-swift

At this time, if the following error is output, please refer to the article ** here **.

A shell task (/usr/bin/xcrun xcodebuild -workspace /Users/ryosuke/Desktop/project/LINELogin/Carthage/Checkouts/line-sdk-ios-swift/LineSDK.xcworkspace CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES -list) failed with exit code 72:
xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH

Please update again after dealing with the error.

In my case I went a little further, but I got more errors. If you get the following error, please refer to the article ** here **! If you do the part below from "How to make it work" in the article, it will work.

Build Failed
	Task failed with exit code 1:
	/usr/bin/xcrun lipo -create /Users/ryosuke/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/line-sdk-ios-swift/5.7.0/Build/Intermediates.noindex/ArchiveIntermediates/LineSDK/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/LineSDK.framework/LineSDK /Users/ryosuke/Library/Caches/org.carthage.CarthageKit/DerivedData/12.3_12C33/line-sdk-ios-swift/5.7.0/Build/Products/Release-iphonesimulator/LineSDK.framework/LineSDK -output /Users/ryosuke/Desktop/project/LINELogin/Carthage/Build/iOS/LineSDK.framework/LineSDK

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/4s/408j5zx12f1b7my_mjvm6xw80000gn/T/carthage-xcodebuild.FJHOKm.log

If all goes well, the following log will be output.

MacBook-Pro:LINELogin username$ carthage.sh bootstrap --platform iOS --cache-builds
*** Checking out line-sdk-ios-swift at "5.7.0"
*** No cache found for line-sdk-ios-swift, building with all downstream dependencies
*** xcodebuild output can be found in /var/folders/4s/408j5zx12f1b7my_mjvm6xw80000gn/T/carthage-xcodebuild.YksYHO.log
*** Downloading line-sdk-ios-swift.framework binary at "5.7.0"
*** Building scheme "LineSDKObjCBinary" in LineSDK.xcworkspace
*** Building scheme "LineSDKObjC" in LineSDK.xcworkspace
*** Building scheme "LineSDK" in LineSDK.xcworkspace
MacBook-Pro:LINELogin username$ 

If you check the directory, you will see that some files have been created. I think that Cartfile and Podfile have been created.

LINELogin is the name of the app I created this time.

$ ls -al
total 48
drwxr-xr-x  14 *******  staff   448  1 11 09:45 .
drwxr-xr-x@  8 *******  staff   256  1 11 09:04 ..
-rw-r--r--@  1 *******  staff  6148  1 11 09:32 .DS_Store
drwxr-xr-x  12 *******  staff   384  1 11 09:11 .git
-rw-r--r--   1 *******  staff     0  1 11 09:19 5.0
-rw-r--r--   1 *******  staff    40  1 11 09:44 Cartfile
-rw-r--r--@  1 *******  staff    41  1 11 09:45 Cartfile.resolved
drwxr-xr-x   3 *******  staff    96  1 11 09:45 Carthage
drwxr-xr-x   8 *******  staff   256  1 11 09:04 LINELogin
drwxr-xr-x@  5 *******  staff   160  1 11 09:10 LINELogin.xcodeproj
drwxr-xr-x@  5 *******  staff   160  1 11 09:10 LINELogin.xcworkspace
-rw-r--r--@  1 *******  staff   265  1 11 09:09 Podfile
-rw-r--r--@  1 *******  staff   330  1 11 09:10 Podfile.lock
drwxr-xr-x   8 *******  staff   256  1 11 09:10 Pods

That's it for using the terminal! thank you for your hard work.

Linking the LineSDK.framework file

If all goes well, ** LineSDK.framework ** will be created in the following hierarchy. Project> Carthage> Build> iOS> LineSDK.framework

Put it in XCode> project name> General> Frameworks, Libraries, and ... Drag and drop. スクリーンショット 2021-01-11 11.33.59.png

I chose General earlier, Select Build Phases and select ** New Run Script Phase ** from +. スクリーンショット 2021-01-11 11.39.10.png

Add the following three to the created Run Script. · / usr/local/bin/carthage copy-frameworks$ (SRCROOT) /Carthage/Build/iOS/LineSDK.framework$ (BUILT_PRODUCTS_DIR)/$ (FRAMEWORKS_FOLDER_PATH) /LineSDK.framework

Please refer to the image below for the place to add. スクリーンショット 2021-01-11 11.49.08.png

Info.plist The Info.plist file should have been created in the app, so Control-click> Open As> Source Code. スクリーンショット 2021-01-11 11.59.20.png

Insert the following snippet just before the last tag.

            <!--Added URL schema to use when returning to the app from LINE-->
    <!--Added URL schema to be used when launching LINE from the app-->

When added, it looks like this. スクリーンショット 2021-01-11 12.03.11.png

Incorporate LINE login into your iOS app

Now that the installation has been completed, the next step is to install it. The article I referred to is ** here **.

Since I only write the code, I can only write the same content as the reference site, so I will omit it.

at the end

It was a difficult process, but I managed to log in.

I've mentioned some of the errors I've encountered, You may get an error other than this article.

Instead of giving up because of an error Please search for the error text! It comes out unexpectedly! (Lol)

Thank you for watching until the end.


-Installation method -Installation error: Utility unknown -Installation error: Architecture duplication workaround -Embedded -Multiple commands produce Compile error workaround Corrective action for errors that occur after implementation -> The file "XXX.entitlements" was not opened.

Recommended Posts

[Swift] How to implement the LINE login function
[Swift] How to implement the countdown function
[swift5] How to implement the Twitter share function
[Swift] How to implement the fade-in / out function
[Swift] How to implement the Twitter login function using Firebase UI ①
[Swift] How to implement the Twitter login function using Firebase UI ②
How to implement the breadcrumb function using gretel
[For beginners] How to implement the delete function
How to add the delete function
[Swift] I tried to implement the function of the vending machine
[Java] How to use the hasNext function
Try to implement login function with Spring-Boot
How to implement TextInputLayout with validation function
[Swift5] How to implement standby screen using'PKHUD'
[Processing × Java] How to use the function
[Swift5] How to implement animation using "lottie-ios"
[Behavior confirmed in December 2020] How to implement the alert display function
How to add sound in the app (swift)
[Swift] How to link the app with Firebase
Try to implement login function with Spring Boot
How to implement the email authentication function at the time of user registration
How to implement UICollectionView in Swift with code only
How to implement login request processing (Rails / for beginners)
Rails learning How to implement search function using ActiveModel
[Swift] How to get the document ID of Firebase
How to add ActionText function
[Swift] How to use UserDefaults
How to use Swift UIScrollView
[Rails] How to implement scraping
[Java] How to implement multithreading
I tried to implement the like function by asynchronous communication
How to transition from the [Swift5] app to the iPhone settings screen
How to implement infinite scrolling (page nate) in Swift TableView
How to apply C code format from the command line
How to use the link_to method
How to use the include? method
How to use the form_with method
How to find the average angle
How to use the wrapper class
Try to implement iOS14 Widget function
Implement simple login function in Rails
[Swift] How to use SwiftLint (cocoapods)
[Swift] How to use Unwind segue
[Swift 5] Implement UI for review function
[Swift] How to send a notification
[Rails] How to implement star rating
[Swift] How to replace multiple strings
[Swift] How to dynamically change the height of the toolbar on the keyboard
How to create a registration / update function where the table crosses
[Swift] How to display when the quiz app answers correctly [Beginner]
[Swift5] How to get an array and the complement of arrays
I tried to implement the image preview function with Rails / jQuery
To use the "java" command line tool ... How to avoid popping up
[Swift UI] How to get the startup status of the application [iOS]
How to run a Kotlin Coroutine sample from the command line
[Rails] How to put a crown mark on the ranking function
[For beginners] How to get the Ruby delayed railway line name
How to use MinIO with the same function as S3 Use docker-compose
How to increment the value of Map in one line in Java
A story about using the CoreImage framework to erase stains with Swift and implement a blur erase function
[Swift] How to pass the Label value in the selected collectionViewCell to the destination TextField