iOS 개발시 AppDelegate의 applicationWillTerminate 호출이 되지 않거나 macOS의 NSApplicationWillTerminateNotification이 호출되지 않을 때 다음과 같이 Info.plist에서 해당 값을 확인해 볼 필요가 있습니다. 해당 값을 NO 로 설정하고 앱을 재실행하면 terminator가 잘 호출 되는 것을 확인 할 수 있습니다.
Application can be killed immediately when user is shutting down or logging out
NSSupportsSuddenTermination

▼ 아래 코드는 위젯 상태를 업데이트 하기 위해서 applicationWillTerminate 호출시 로그아웃 명령을 하는 코드로 Info.plist 파일을 수정하니 정상적으로 호출되는 것을 확인했습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func applicationWillTerminate(_: UIApplication) { | |
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | |
print("[\(LogFile.logFile.getDate())] Application Will Terminate]\n", to: &LogFile.logFile) | |
// 앱 종료시 자동 로그인이 아니면 위젯 로그아웃 | |
print("isAutoChecked : \(WidgetInterface.isAutoChecked)") | |
WidgetInterface.logout() | |
unsubscribeFromTopic() | |
} |
'개발툴 > Xcode' 카테고리의 다른 글
[Xcode] 다국어 테스트 Localization 시스템 스키마 언어 설정 (0) | 2023.05.24 |
---|---|
[Xcode] CocoaPods 14.3 libarclite_iphoneos.a 에러 수정하기 (0) | 2023.05.04 |
[Xcode] Cocoapods m1 맥에서 Homebrew로 설치하기 (0) | 2023.04.18 |
[Xcode] 오래된 Xcode에서 지원하지 않는 디바이스 빌드하기 (0) | 2023.04.15 |
[Xcode] 앱 종료 상태에서 푸시 Push 테스트 하기 (0) | 2023.04.12 |