Join us on the demo, while our product experts provide a detailed walkthrough of our enterprise platform.


The latest news in the world of engineering.

Identity and Access Management (IAM), including security and customer experience.

Visit Blog

Grow your business to millions.Engage and retain your customers.

Visit Blog

How to obtain iOS application logs without Mac

Logs are very helpful in finding the root cause of the issues you may be experiencing in an app. It is an efficient way to resolve issues by knowing the exact…

Tanvi Jain
Tanvi Jain
July 22, 2020
2 min read

Free, Secure and Trusted Way to Authenticate Your Visitors

Add login to your website in 5 minutes completely for free!

Free Sign UpNo hidden costs. No credit card needed.

Logs are very helpful in finding the root cause of the issues you may be experiencing in an app. It is an efficient way to resolve issues by knowing the exact reason after checking Logs.

Let's say we have developed an iOS app. As in many situations, we want to test our app on another's phone for many reasons. And probably that phone cannot be connected to the Mac. So, the console logs of the app can be sent directly from the app to the developer(us).

This blog will provide step-by-step instructions for mailing iOS app logs directly from the app.

Getting started

Here we are having a project with a single ViewController. We may ask our users to install the app on their device, use it and at the end click on “Press for Logs” Button. By clicking IBAction pressForLogs function will get called which will open MailComposer and then the user can mail the Log file to us.

Steps to do in your own project

  • Find AppDelegate.swift in your project. Define following var and function as global before any import statement.
public var logFilePath:String!
func print(_ items: Any..., separator: String = " ", terminator: String = "\n") {
    let output = { "*\($0)"}.joined(separator: " ")
    //Swift.print(output, terminator: terminator)

Above function override any log calls in the app.

  • Then define the following method in AppDelegate.Swift file. And call from func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool function.
func printTheDataAtLogFile() {
    logFilePath = NSTemporaryDirectory().appending(String.init(format: "%@.log",Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as! String)) as String
       freopen((logFilePath as NSString).cString(using: String.Encoding(rawValue: String.Encoding.ascii.rawValue).rawValue)!, "a+", stderr)

Above function will write all logs into a file instead of console.

  • Open Viewcontroller.swift. Define below 2 functions in it.

    func allOptions() {
    let alert = UIAlertController(title: "Please Select an Option", message: nil, preferredStyle: .actionSheet)
    alert.addAction(UIAlertAction(title: "Log Mail", style: .default , handler:{ (UIAlertAction)in
        self.shareDocument(documentPath: logFilePath)
    alert.addAction(UIAlertAction(title: "dismis", style: .cancel, handler:{ (UIAlertAction)in
        print("User click Dismiss button")
    self.present(alert, animated: true, completion: {
        print("completion block")
    //  ============================= //
    // this is to share file //
    func shareDocument(documentPath: String) {
    if FileManager.default.fileExists(atPath: documentPath){
      let fileURL = URL(fileURLWithPath: documentPath)
      let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [fileURL], applicationActivities: nil)
      present(activityViewController, animated: true, completion: nil)
    else {
      print("Document was not found")

    Call allOptions() from IBAction pressForLogs. Above functions will open ActivityViewContrrolle to let the user mail log file to you.

Voila!! :)

Thanks for visiting us! We hope you find this knowledge base useful! Our mission is to make mobile app development happy. We hope we’re living up to the mission with your project.

Please write to us for suggestions and for the contents we should come up with!

Thanks for reading the blog. For detailed information and execution example of this blog, please refer to the video below:

LoginRadius Docs

Implement Authentication in Minutes

click here

Most Popular Tags


Do you want a free authentication solution?

Add the world's most secure, reliable and easy to implement user authentication solution on your applications at $0Get Started Free

Tanvi Jain

Tanvi Jain

A Mobile application developer based on Jaipur, India. Having 6+ years of experience in iOS App development with Client based & Product based organizations.

View Profile

Try a Modern Authentication Solution

$0/ month

Free Sign Up
  • 7,000 Monthly Active Users
  • 1 Web or Mobile App
  • Email/Password Login
  • 3 Social Login Providers
  • User Data Storage
  • Transactional Email Template
  • Customizable Login Interfaces