Tom Schulz
Tom Schulz

Reputation: 672

When I call objective-c functions from Swift, NSLog in those functions do nothing

I have a mixed Swift and Objective-C project (one view controller is in objective C). When I try to print some debug output from that view controller (ie in the .m file using NSLog) I do not see any output.

My swift prints are just fine.

I made a new objective-c project and did some NSLogging, that works fine.

I added this code to my appdelegate (swift), just to immediately test: NSLog("Testing 1 2 3") print("Is this thing on?") and I also do not see the NSLog output, but I do see output from the print statement.

What madness is this?

Upvotes: 0

Views: 616

Answers (2)

Tom Schulz
Tom Schulz

Reputation: 672

The solution teja_D proposes works, but then there's a lot of garbage in the logs. Myself, I am just going to use printf. Either that or reach back across the obj-c / swift barrier and make a swift object call 'print' for me.

This kind of thing really makes me shake my head.

Upvotes: 0

teja_D
teja_D

Reputation: 438

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

Uncheck this value in my scheme restored my logs.

Check this stack overflow post - iOS 10 doesn't print NSLogs

Upvotes: 3

Related Questions