iOS/SwiftUI

[iOS / SwiftUI] Use Deep Link in SwiftUI

TDCIAN 2022. 1. 11. 23:26

Hi! this is TDCIAN!

 

Today, let's find out how to use deep link in SwiftUI!

 

First, if your Xcode version is bigger than 13.0 or equal, then you should go to 'Info' file and

add 'URL Types' under 'Information Property List', and finally add 'URL Schemes' that you want to use.

In my case, I used "hi-hello" for URL of my application.

You can use any URL! 'hi-hello' is just my own URL.

 

and if your Xcode version is smaller than 13.0, then you should go to project file andclick 'info' tab, and then click 'URL Types'

If you click this picutre, than you can show original video of '개발하는 정대리'. He is a brilliant guru for developer.

and just like this picture, add your own URL Schemes, in this video, the teacher used 'deeplink-swiftui'.

 

(1) TodosView

 

To make 'Todo' list, check this code. You can find 'TodosView.swift' file in my full source code.

 

 

 

(2) ProfileView

To make 'Profile' view, check this code. You can find 'ProfileView.swift' file in my full source code.

 

 

 

 

(3) TabView

 

Finally, to make tab view contains todo list and profie view, check this code. You can find 'SwiftUIDeepLinkApp.swift' file in my full source code.

 

 

 

* Use in Simulator

 

(1) Build app

 

(2) Open Safari

 

 

(3) Type your own scheme

In this picture, I set 'hi-hello' as URL Schemes in my 'Info' file, and I set 'profile' as tab identifier in my SwiftUIDeepLinkApp.swift(Check line 63th).

 

 

 

 

 

(4) Open your app with Safari

 

 

(5) App is opened with 'Profile' tab, not 'Todo' tab.

 

 

Full source code: https://github.com/TDCIAN/SwiftUIDeepLink

 

GitHub - TDCIAN/SwiftUIDeepLink

Contribute to TDCIAN/SwiftUIDeepLink development by creating an account on GitHub.

github.com

 

Reference: https://www.youtube.com/watch?v=kjDl_15fOEQ