Programing

iOS 10은 NSLogs를 인쇄하지 않습니다.

lottogame 2020. 9. 10. 08:17
반응형

iOS 10은 NSLogs를 인쇄하지 않습니다.


NSLogXcode 8.0 베타 (8S128d)에서는 아무것도 인쇄되지 않습니다 . printf변경되지 않음

내 코드는 다음과 같습니다.

NSLog(@"hello from NSLog");
printf("hello from printf");

다음은 iOS 9 Simulator의 출력입니다.

2016-06-17 09:49:10.887 calmapp-dev[28517:567025] hello from NSLog
hello from printf

다음은 iOS 10 Simulator의 출력입니다.

hello from printf

Scheme 환경 변수에 "OS_ACTIVITY_MODE": "disable"속성을 추가하고 (시뮬레이터에서 OS 출력을 숨기기 위해) 잊어 버리고 이제 실제 장치에서 실행 중일 수 있습니다.

Xcode 8에서

Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables

추가 OS_ACTIVITY_MODE및 확인 만 (값을 추가하지 마십시오)

여기에 이미지 설명 입력

여기에 이미지 설명 입력

요약 : 이것은 Xcode 8 + iOS10의 버그입니다. 다음과 같이 해결할 수 있습니다.

  • 시뮬레이터를 사용할 때 이름 "OS_ACTIVITY_MODE"와 값 "비활성화"를 추가하고 확인하십시오.

  • When on a real device, only add "OS_ACTIVITY_MODE" and check it(Don't add the Value). You will see the NSLog in the Xcode8 Console.


If you check the Xcode 8 beta release notes, you'll find that it says:

When debugging an app running on Simulator, logs may not be visible in the console. Workaround: Use command + / in Simulator.app to open the system log in the Console app to view NSLogs. (26457535)


the NSlog or print actually is executed but is hidden among lots of other console debug outputs to solve this issue Open Xcode8:

Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables

add "OS_ACTIVITY_MODE" and set the Value to "disable" and check it.

click close

xcode9

add "OS_ACTIVITY_MODE" and set the Value to "default" and check it.

여기에 이미지 설명 입력 여기에 이미지 설명 입력


I can't see NSLog output in real iOS 10 device neither. If you're using real devices, you can open Devices window from Xcode (Shift + Command + 2) and see device logs there, but it's hard to look at your app's logs because the console shows logs from system and all apps.

(I'm using Xcode 7, so it's may not Xcode's problem but iOS 10 problem)


Also, make sure the Console is actually visible in Xcode (i.e., make sure the right-hand side icon is highlighted in blue, as per the image below). After I upgraded Xcode, it hide the Console and showed me just the Variables view. This made it look like NSLog() was not working properly, whereas it was indeed working correct, I just couldn't see the output.

여기에 이미지 설명 입력


Hmmm... it seems like the property "OS_ACTIVITY_MODE": "disable" PREVENTS NSlog from showing up in the Xcode 9 log.

Unchecking this value in my scheme restored my logs.


For anyone who comes upon this in the future. The reason NSLog doesn't print to syslog in iOS 10 and iOS 11 is due to Apple changing to Unified Logging.

You can see the WWDC talk about it here: https://developer.apple.com/videos/play/wwdc2016/721/

Documentation here: https://developer.apple.com/documentation/os/logging

From 10 on you should be using os_log instead of NSLog.

How to find the logs on disk: https://www.blackbagtech.com/blog/2017/09/22/accessing-unified-logs-image/

To summarize, the logs are located in /var/db/diagnostics which can be found for a VM at /Users/USERNAME/Library/Developer/CoreSimulator/Devices/SIMULATOR-GUID/data/var/db/

Copy all items inside diagnostics and uuidtext into a single folder (don't include the folders diagnostics or uuidtext just what is inside).

Rename that folder foldername.xarchive.

Open it in Console.app or use the OSX util log: log show <path to archive> --info --predicate <options>


I'm using Xcode 8,so I also encountered the same problem . And I solved this problem by adding value = disable on the simulator, but on a real machine I don't add value.


NSLog messages no longer displayed when I upgraded to Xcode 9.1 + iOS 11.1. Initially the accepted answer gave me a way to work around this using the Console app and enabling the Simulator (see Lucas' answer).

콘솔 앱에서 Action선택 Include Debug Messages및 선택 취소를 시도했습니다 Include Info Messages(따라서 콘솔이 시스템 메시지로 가득 차 있지 않습니다). NSLogXcode의 콘솔 창에는 메시지가 나타나지만 콘솔 앱에는 나타나지 않습니다.

나는에 더 직접적인 방법이있을 깨달았다 disable또는 (즉, 수 default) NSLogs에 응답 쾨르의 의견 덕분에 이 답변. 제 생각에는이 설정 때문에 가장 좋은 대답 OS_ACTIVITY_MODEdisable하거나하는 것은 default초보자를위한 더 의미가 뜻.

참고 URL : https://stackoverflow.com/questions/37886600/ios-10-doesnt-print-nslogs

반응형