Containing App과 App Extension을 동시에 디버깅
6264 단어 iOSSwiftdebugAppExtension
소개
Containing App을 디버깅 할 때
동시에 App Extension의 디버깅도하는 방법을 정리합니다.
샘플 구성
샘플 앱은 다음과 같이 구성됩니다.
카테고리
대상 이름
Description
Containing App
iOSTodayExtension
확장 앱 (개발 앱)
App Extension
TodayEx
Today Extension
아무것도 고려하지 않고 디버그 실행 (실패 사례)
TodayViewController.swiftextension TodayViewController: NCWidgetProviding {
func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
label.text = TodayViewData.fetchMessage()
completionHandler(NCUpdateResult.newData)
}
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
switch activeDisplayMode {
case .compact:
preferredContentSize = maxSize
case .expanded:
preferredContentSize = CGSize(width: 0, height: expandedContentHeight)
}
// iOSTodayExtension(Containing App)実行時は、以下のデバッグログはコンソールに表示されない
print("NCWidgetDisplayMode: \(activeDisplayMode)")
print("preferredContentSize: \(preferredContentSize)")
}
}
TodayEx측의 코드에 상기와 같이, print문을 써 보았더니,
"TodayEx"를 실행하여 위젯 표시를 늘리거나 줄이면 콘솔에 로그를 출력 할 수있었습니다.
또, 상기 TodayViewController내에 브레이크 포인트를 설정했는데, 제대로 정지했습니다.

NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (0.0, 200.0)
NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (398.0, 105.0)
그러나 'iOSTodayExtension'을 실행하여 마찬가지로 위젯 표시를 늘리거나 줄이면,
콘솔에 로그가 출력되지 않았습니다.
또한 브레이크 포인트를 설정해도 중지되지 않았습니다.

프로세스에 연결
Containing App과 App Extension은 다른 프로세스에서 작동하기 때문에
iOSTodayExtension 실행시에는 TodayEx는 print 문의 내용을 콘솔에 출력하거나
브레이크 포인트에서 멈추지 않는 것 같습니다.
iOSTodayExtension 실행 후,
Debug > Attach to Process by PID or Name...
또는
Debug > Attach to Process
에서 연결합니다. (아래 이미지는 "Attach to Process by PID or Name..."을 선택한 경우)


브레이크 포인트에서 멈추게되었습니다!

그러나 print 문의 내용은 출력 할 수 없으며 이것만으로는
매번 lldb 명령으로 값을 출력해야합니다.

중단점을 편집하여 로그를 출력합니다.
print 문은 작동하지 않았지만 중단 점은 작동하기 때문에
중단점에 로그를 설정하여 콘솔에 로그를 출력할 수 있습니다.


하단의 'Automatically continue after evaluating actions'를 체크하면,
로그 출력 후 처리를 중지하지 않습니다.
요약
Containing App을 디버깅하는 동안 App Extension 측 디버깅을 수행하려면 ...
샘플 앱은 다음과 같이 구성됩니다.
카테고리
대상 이름
Description
Containing App
iOSTodayExtension
확장 앱 (개발 앱)
App Extension
TodayEx
Today Extension
아무것도 고려하지 않고 디버그 실행 (실패 사례)
TodayViewController.swiftextension TodayViewController: NCWidgetProviding {
func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
label.text = TodayViewData.fetchMessage()
completionHandler(NCUpdateResult.newData)
}
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
switch activeDisplayMode {
case .compact:
preferredContentSize = maxSize
case .expanded:
preferredContentSize = CGSize(width: 0, height: expandedContentHeight)
}
// iOSTodayExtension(Containing App)実行時は、以下のデバッグログはコンソールに表示されない
print("NCWidgetDisplayMode: \(activeDisplayMode)")
print("preferredContentSize: \(preferredContentSize)")
}
}
TodayEx측의 코드에 상기와 같이, print문을 써 보았더니,
"TodayEx"를 실행하여 위젯 표시를 늘리거나 줄이면 콘솔에 로그를 출력 할 수있었습니다.
또, 상기 TodayViewController내에 브레이크 포인트를 설정했는데, 제대로 정지했습니다.

NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (0.0, 200.0)
NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (398.0, 105.0)
그러나 'iOSTodayExtension'을 실행하여 마찬가지로 위젯 표시를 늘리거나 줄이면,
콘솔에 로그가 출력되지 않았습니다.
또한 브레이크 포인트를 설정해도 중지되지 않았습니다.

프로세스에 연결
Containing App과 App Extension은 다른 프로세스에서 작동하기 때문에
iOSTodayExtension 실행시에는 TodayEx는 print 문의 내용을 콘솔에 출력하거나
브레이크 포인트에서 멈추지 않는 것 같습니다.
iOSTodayExtension 실행 후,
Debug > Attach to Process by PID or Name...
또는
Debug > Attach to Process
에서 연결합니다. (아래 이미지는 "Attach to Process by PID or Name..."을 선택한 경우)


브레이크 포인트에서 멈추게되었습니다!

그러나 print 문의 내용은 출력 할 수 없으며 이것만으로는
매번 lldb 명령으로 값을 출력해야합니다.

중단점을 편집하여 로그를 출력합니다.
print 문은 작동하지 않았지만 중단 점은 작동하기 때문에
중단점에 로그를 설정하여 콘솔에 로그를 출력할 수 있습니다.


하단의 'Automatically continue after evaluating actions'를 체크하면,
로그 출력 후 처리를 중지하지 않습니다.
요약
Containing App을 디버깅하는 동안 App Extension 측 디버깅을 수행하려면 ...
extension TodayViewController: NCWidgetProviding {
func widgetPerformUpdate(completionHandler: (@escaping (NCUpdateResult) -> Void)) {
label.text = TodayViewData.fetchMessage()
completionHandler(NCUpdateResult.newData)
}
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
switch activeDisplayMode {
case .compact:
preferredContentSize = maxSize
case .expanded:
preferredContentSize = CGSize(width: 0, height: expandedContentHeight)
}
// iOSTodayExtension(Containing App)実行時は、以下のデバッグログはコンソールに表示されない
print("NCWidgetDisplayMode: \(activeDisplayMode)")
print("preferredContentSize: \(preferredContentSize)")
}
}
NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (0.0, 200.0)
NCWidgetDisplayMode: NCWidgetDisplayMode
preferredContentSize: (398.0, 105.0)
Containing App과 App Extension은 다른 프로세스에서 작동하기 때문에
iOSTodayExtension 실행시에는 TodayEx는 print 문의 내용을 콘솔에 출력하거나
브레이크 포인트에서 멈추지 않는 것 같습니다.
iOSTodayExtension 실행 후,
Debug > Attach to Process by PID or Name...
또는
Debug > Attach to Process
에서 연결합니다. (아래 이미지는 "Attach to Process by PID or Name..."을 선택한 경우)


브레이크 포인트에서 멈추게되었습니다!

그러나 print 문의 내용은 출력 할 수 없으며 이것만으로는
매번 lldb 명령으로 값을 출력해야합니다.

중단점을 편집하여 로그를 출력합니다.
print 문은 작동하지 않았지만 중단 점은 작동하기 때문에
중단점에 로그를 설정하여 콘솔에 로그를 출력할 수 있습니다.


하단의 'Automatically continue after evaluating actions'를 체크하면,
로그 출력 후 처리를 중지하지 않습니다.
요약
Containing App을 디버깅하는 동안 App Extension 측 디버깅을 수행하려면 ...
Containing App을 디버깅하는 동안 App Extension 측 디버깅을 수행하려면 ...
Reference
이 문제에 관하여(Containing App과 App Extension을 동시에 디버깅), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/y-okudera/items/1ca4f380854f9e0cb30d텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)