How do you print debug messages from native iOS extensions? (SOLVED)

#1

I’m currently making an iOS extension, but at the moment I’m getting unexpected results at run time, and I want to see what my variables are holding. But since I’m bundling my app and running it on my device, I can’t see any print() logs from Lua or printf() logs from C++ or Objective C.

I’ve looked at this link and got up to the “path mappings” section before the instructions became too unclear to continue. I don’t know what the “engine source” is in this context, nor what the path names mean. This might be related to my issue.

0 Likes

#2

This manual lists the possible ways to read the output from your game: https://defold.com/manuals/debugging-game-and-system-logs/

2 Likes

#3

Solved, I ended up downloading a log file from the device thanks to that link. Unfortunately it doesn’t capture C++ or Objective C printf calls, but it will do for now.

0 Likes

#4

It should include dmLogInfo() and the rest of the log functions from the Defold SDK.

2 Likes

#5

That it does! I originally tested it with dmLogDebug, which wasn’t working for me, so I was confused. dmLogInfo is perfect though, thanks.

0 Likes

#6

I would have thought dmLogDebug would show as well. There’s also dmLogWarn() and a few others: https://defold.com/ref/stable/dmLog/

0 Likes

#7

This setting is extra verbose, and is disabled by default.
We don’t really use it much to be honest. We mainly use dmLogInfo, dmLogWarning and dmLogError.

2 Likes

#8

Hi,

I’ve the same problem : I’m trying to debug my own ios extension using log messages but I can’t see my printf(…) or fprintf(stderr,…) from my C files in my ‘log.txt’ downloaded file. How can I use dmLog Does I need to install all the dmEngine sdk?

Thanks for your help…

1 Like

#9

You already have access to the sdk on the cloud build server, so no need to install anything.

By using our dmLog* functions, you’ll make sure the output is visible in the logs on all platforms (e.g iOS and Android) where printf won’t work.

Note that these functions only work in debug builds.

0 Likes

#10

If you sign the application with an iOS Developer certificate (as opposed to a distribution cert) you will also be able to see the output in the Console app on macOS.

0 Likes

#11

I’m using “Personal Team” certificate to sign my ios application. Is there a known problem concerning the output in the Console app on macOS using this certificate?

Other remark/question:
I may have missed something : I build manually (and locally) my ios library calling make -f … and putting the “.a” file in my defold “lib” folder. How can I build this library on the cloud build server ?

0 Likes

#12

I think I understood…
I will group my native code in the “src” folder of my extension. By doing this, my native extension should be built in the cloud…

Currently, I compile it outside (external folder) to produce an external library that I copy into the “lib” folder of my extension (so I have to call manually xcrun make -f …)
I was inspired by the organization of the native extension fmod (https://github.com/dapetcu21/defold-fmod).
I will rather take inspiration from the organization of the native extension “ios-android in-app purchase” that you provide as an example in the documentation (https://github.com/defold/extension-iap ;o).

I will try and I will keep you posted…

1 Like

#13

Success and It’s better !
I put all my native code into the defold project (I gave up going through an external library) and now, I can trace/debug my ios native extension…
By the way, I gain a simpler, more fluid compilation ;o)

1 Like