user7769023
user7769023

Reputation:

None of my print statements are appearing in the Xcode console

I have created this function called createTeams() which is creating data for the table.

func createTeams() {
    let team1 = teams(Team1: "Chelsea", Team2: "Arsenal" , startTime: "15/06/2019", location: "London")
    let team2 = teams(Team1: "Barcelona", Team2: "Manchester" , startTime: "16/06/2019", location: "London")
    let team3 = teams(Team1: "Real Madrid", Team2: "FC Bayern" , startTime: "17/06/2019", location: "London")
    let team4 = teams(Team1: "Chelsea", Team2: "Juvantis" , startTime: "18/06/2019", location: "London")
    let team5 = teams(Team1: "LiverPool", Team2: "FC Dallas" , startTime: "19/06/2019", location: "London")
    let team6 = teams(Team1: "Atlanta FC", Team2: "NewCastle Utd." , startTime: "20/06/2019", location: "London")

    teamsList.append(team1)
    teamsList.append(team2)
    teamsList.append(team3)
    teamsList.append(team4)
    teamsList.append(team5)
    teamsList.append(team6)
}

I call this function in viewDidLoad and it works fine.

However, I have this print statement in viewDidLoad that doesn't work.

override func viewDidLoad() {
    super.viewDidLoad()
    print("Awake");

    self.createTeams()
    tableView.dataSource = self
    tableView.delegate = self
}

I Even have this button with a simple print statement that is not working either.

@IBAction func subscribeButtonClicked(_ sender: UIButton) {
    print("Subscribe Button Clicked")

    if(isSubscribed) {
        print("User Subscribed to this ");
        isSubscribed = false
    } else {
        print("User Unsubbed");
        isSubscribed = true
    }
}

Edit: It is a watchKit Project i am developing so it was loading from the watch Interface and printing from there in order to print those statements i had to run the project on a iPhone simulator individually

Upvotes: 6

Views: 5989

Answers (3)

Markv07
Markv07

Reputation: 276

Another possibility is the console icon in the lower right corner has been flipped accidentally. If you don't use these icons much, its easy to forget about them. This was the case for me.

Upvotes: 0

Zakaria
Zakaria

Reputation: 103

So after doing a lot of research and following the previous steps mentioned about the console not showing it turned out that I've hid the console area or deactivated it. To activate/show it :

  1. Hover to "View" in the top menu in Xcode
  2. Tap "Debug Area"
  3. Choose "Activate Console"

or simply click command+shift+c

Upvotes: 12

Gourav Joshi
Gourav Joshi

Reputation: 2419

The problem is sometimes xcode debugger crashed due to some internal inconsistency or for other reasons. So what we write print statements cannot be shown in debugger window.

You need to do these steps:

  1. Clean the xcode.

  2. Force quit the xcode.

  3. Clean the derieved data.

  4. Restart the xcode and run it.

It will work fine.

Upvotes: 2

Related Questions