티스토리 뷰

study - iOS

How To Make iOS CarPlay App

ODING2 2019. 4. 21. 22:39

carplay app을 뒤늦게 만들기 시작했다

내 app은 음악 &엔터테인먼트 관련된 app 이기에, 라이선스를 받아 진행할 수 있었다.

1. 라이선스 획득

우선 MFi 라이선스를 받아야한다. 며칠의 시간이 걸렸다.

https://developer.apple.com/programs/mfi/

 

MFi Program - Programs - Apple Developer

Hardware Components and Documentation Get the hardware connectors and components that are required to manufacture iPod, iPhone, iPad, and AirPlay audio accessories. And access the iPod Accessory protocol specification, the communication protocol used to interact with iPod, iPhone, and iPad. MFi Logo

developer.apple.com

위 페이지에서 Apply now > continue를 통해 MFi의 라이선스를 획득한다.

2. simulator 띄우기

획득 후, Xcode에 우선 CarPlay simulator를 띄워 보자(Xcode9 기준)

https://stackoverflow.com/questions/37469175/is-there-carplay-simulator-in-xcode

 

Is there CarPlay Simulator in Xcode

Is there a CarPlay Simulator available in Xcode or from another source? I would like to view if my current app has any interaction with it such as how notifications received from my app are display...

stackoverflow.com

또 구글링을 해보았다.

위에따르면, 터미널에 아래와 같이 입력하면 된다고 한다

 

Xcode.app 의 위치에서 위 코드를 실행한 후, 다시 Xcode를 재부팅 한다.

그 후 simulator에서 Hardware -> External Displays -> CarPlay 로 진입하면 완성!

반드시 Phone 시뮬을 하나 더 띄워야 한다. app을 실행하면 carPlayApp도 켜짐을 확인할 수 있다.

3. app Custom

이제 CarPlayApp 을 Custom 해 본다.

카플레이 소스는 MediaPlayer.framework에 있다.

우선 NSObject를 상속하는 CarplayManager파일을 생성한다.

그 후 MediaPlayer프레임워크를 import 하고,

header에 <MPPlayableContentDelegate, MPPlayableContentDataSource> 를 추가해 준다.

 

그 후, 구현부에에서, 해당 manager 를 init할 때 delegate, datasource를지정해 준다.

 

MPPlayableContentDataSource 에는 필수 매서드가 존재한다.

아래 두 가지인데, UITavleView의 numberOfRow 매서드와, CellForRow 매서드와 비슷하다고 보면 된다.

 

이부분에서 많이 헤메었는데, numberOfChildItemmsAtIndexPath 매서드는 NSIndexPath를 사용하고, navigation tree에 입각하기 때문에 일반적인 count를 return 하면 충돌이 날 수 있다.

그러므로, 아래 첨부한 WWDC 링크에서(6분지점) tree 를 참고하여 return값을 지정해 주면 된다.

나의 경우는, indexPath.row 를 [indexPath indexAtPosition:0] 로 대체하였는데, 안전한지는 좀 더 알아보아야할 것 같다.

이렇게 custom 한 carPlaymanager는

Appdelegate.m 파일 내 -

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

소스 위치 내에서 init해 주면 된다. (왠만하면 singleton 으로 바꿔서 start매서드를 call 하자)

이 모든 process 는 아래 WWDC Apple "Enabling Your App for CarPlay"를 참고했다.

https://developer.apple.com/videos/play/wwdc2017/719/?time=360

Enabling Your App for CarPlay - WWDC 2017 - Videos - Apple Developer

Understand how to enable your audio, messaging, VoIP calling or automaker app for CarPlay. Audio, messaging and VoIP calling apps use a...

developer.apple.com

https://stackoverflow.com/questions/45726467/adding-ui-for-carplay-audio-app

 

Adding UI for CarPlay audio app

I am adding a list (tableview) in my CarPlay audio app. In AppDelegate.m, I have - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ...

stackoverflow.com

여기에 tab 바를 추가하는 코드 예제는 plist 에 코드를 추가하는 방법이 있는데 나중에 다시 기록하자

 

 

https://blog.naver.com/dhekdp32/221142027986 ->이사중

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함