top of page
Search
hardfuncgestnosacb

Getting More Logs From Xcode: Learn How to Use Console, OSLog, and Other Frameworks



Ah yes I misunderstood. If the log is from your own device then yes it should already be there and should already be symbolicated. I was thinking of the more common case where app review or a user sends you a .crash file and you have to import and symbolicate it.


It is common knowledge that when Xcode builds a project, it does not do the same thing that xcodebuild does. Just like xcodebuild, building in Xcode creates a Test folder inside Logs, and saves summary plists and attachments. However, Xcode itself creates a lot more logs.




Getting More Logs From Xcode



When opening up the multiple .xcactivitylog files, there is some overlap. It appears that Xcode will split the different sections of the build into different activity logs. Unfortunately, because the UUIDs are unique and not related, putting a full log back together from these pieces is fairly difficult.


If Swift compile time is the bottleneck, we can get more information by setting Other Swift Flags from the Xcode build settings. With these flags enabled Xcode will generate a warning for any function or expression that took longer than 100ms to type-check:


Lastly, let's take a look at the selected connection for Background URLSession. At first there may not appear to be much more information here than what is available on the active connections per process view, but if you take a look at the duplicates, out-of-order, and retransmitted columns, these are the key pieces of information that make this profile valuable. These values can tell you a lot about the state of the connection and if you are receiving packet loss or dropped connections. Also, notice how there are two packets out and one packet in, matching the CFNetwork Diagnostic transmission logs from above.


In summary, I hope you have gained some more insight about how to debug network traffic from Xcode a bit more efficiently. I know that CFNetwork Diagnostic Logging has saved me personally a lot of time just being able to see the data packets being transferred back and forth between the client and the server unencrypted. This traditionally is not the case when you do a tcpdump or grab a pcap with Wireshark. Also, utilizing Instruments to profile network connections can be very handy when reviewing individual connections to see if there have been any re-transmissions, out-of-order, or duplicate packets sent or received on your connection. This is also something that you will have to evaluate manually when using Wireshark or tcpdump. I hope you have enjoyed this article and please let me know if you have any questions comments or concerns as I would love to discuss more!


No problem! I'm glad you enjoyed the article. The OS_ACTIVITY_MODE = disable is unchecked. It was there but in order for CFNetwork logs to show up, it needs to unchecked. As for the RAW-SEND and RAW-READ, this should show up in CFNETWORK_DIAGNOSTICS=3 only. 1 and 2 will not contain this. I'll do a bit more debugging to see if this is something that was removed in XCode 10.1 and post an edit if so. Thank you for bringing this up.


As you can see in the screenshot, there are multiple Device Logs items. The Device Logs under LIBRARY contain all the logs from all devices you own (or have connected to Xcode). The Device Logs entries under each device are for that particular device.


Once your app is submitted, you can also get crash logs from your users using iTunes Connect. To do this, simply sign in to your iTunes Connect account, navigate to Manage Your Applications, click on the app you want crash logs for, click on the View Details button below the icon, and click on Crash Reports in the right-hand side pane in the Links section.


This section gives you some basic information about the date and time of the crash, and the version of iOS running on the device. If you have a lot of crash logs coming from iOS 6.0, it might mean that your problem is specific to iOS 6.


By writing a small extension you make it fairly easy to replace your print statements. Using the Console app in combination with your logs can help you debug issues in a more efficient way. OSLog has a low-performance overhead and is archived on the device for later retrieval. These are two of the advantages of using OSLog instead of print statements.


Alternatively, as a back-up, Crashlytics includes an upload-symbols scriptthat you can call from anywhere in your build process to manually upload yourdSYM files. The script provides more information about the upload process andmore comprehensive error messaging (for usage notes and additional instructions,run upload-symbols without any parameters).


Using %public@ instead of just %@ allows us to see the variables even with no debugger attached. Variables are private by default to prevent leaking sensitive data via logs.Read more about unified logging on SwiftLee.


To the end-user you might just display an alert with status message, but in logs you can express more detailed information by providing deeper insight in what happened. So if the application tried to save data into database and this process finished with error, you would output the error and all additional information, which could help you to diagnose and prevent the cause of it.


iOS developers can see application logs in XCode IDE (Integrated development environment) debug console. The device, on which the application is running, must be connected to the Mac and launched from XCode.


Even though `NSLog()` log messages will appear in Device Console, there still will be a lot of other OS level logs visible to user too, which makes log reading a lot more difficult, for example, for the QA team.


But QA and others will have a harder time reading logs from Device Console, because it outputs not only specific application logs, but also Operating System logs. And as you can guess, there are a lot of OS log outputs per second.


Working with mobile application development is far removed from web development. For starters, the IDEs, SDKs, and programming languages at your disposal are far more restrictive than the wild west that is the web browser.


You can see whether a workflow run is in progress or complete from the workflow run page. You must be logged in to a GitHub account to view workflow run information, including for public repositories. For more information, see "Access permissions on GitHub."


GitHub Actions use the Checks API to output statuses, results, and logs for a workflow. GitHub creates a new check suite for each workflow run. The check suite contains a check run for each job in the workflow, and each job includes steps. GitHub Actions are run as a step in a workflow. For more information about the Checks API, see "Checks."


You can download the log files from your workflow run. You can also download a workflow's artifacts. For more information, see "Persisting workflow data using artifacts." Read access to the repository is required to perform these steps.


Note: When you download the log archive for a workflow that was partially re-run, the archive only includes the jobs that were re-run. To get a complete set of logs for jobs that were run from a workflow, you must download the log archives for the previous run attempts that ran the other jobs.


To view the log for a specific job, use the run view subcommand. Replace run-id with the ID of run that you want to view logs for. GitHub CLI returns an interactive menu for you to choose a job from the run. If you don't specify run-id, GitHub CLI returns an interactive menu for you to choose a recent run, and then returns another interactive menu for you to choose a job from the run.


While xcpretty produces much more digestible output, it is quite common that you can't tell the exact error from the prettified output, but it's included at the end of the raw Xcode build log. So we updated our Xcode steps to print the last 10 lines of the build log into the standard output if the step failed and the output tool was xcpretty. This does not concern the full log, the file is still available.


I'll assume you have familiarity with XCUITest. But in case you are not so confident I'll do a quick review of UI Testing on Xcode, so we have a base to start from. If you would like more resources on UI Testing, check the "Related Topics" sections for more links on the topic.


Setup a Build Step This build step is probably the most important part. Building the project is quite easy. You setup the build to build from the command line using xcodebuild. (You can see usage for xcodebuild using xcodebuild -usage.) I have setup this project to just build all targets for this project. Also, I setup the reporting for my tests as JUnit and where it can find the xml file (more on this later).


In a previous blog post, I wrote about my app crashing when it was installed via TestFlight. In this blog post, I will go into more detail about how I debugged the problem using logs and crash reports.


Signposts seems like a really promising new tool, especially when it comes to quickly getting more thorough information when debugging tricky performance problems and asynchronous operations. However, we've only scratched the surface of what signposts can do in this post, so I'm sure this is a topic that we'll revisit in a future weekly article on the main blog.


The test logs are created inside the DerivedData/YourProjectName-UUID/Logs/Test directory. Xcode and xcodebuild create different logs. You can find a good description about which ones are created in this blog post.


XCLogParser is currently in alpha status. We are using it internally and tested it on various projects, but we need the help from the community to test and improve it with more iOS and Mac applications. 2ff7e9595c


2 views0 comments

Recent Posts

See All

Comments


bottom of page