fpillet/NSLogger

No output - Request for help

mwyld opened this issue · 17 comments

mwyld commented

This looks great and keen to get it up and running. Although, I'm really struggling to get it to work.

I have followed the instructions, but feel I may be missing something? Could someone help me debug it?

I am using Xcode 12.2 on macOS Big Sur

I have downloaded the Desktop App and I have added the pod to my podfile

target 'MyApp' do
  capacitor_pods
  # Add your Pods here
  pod "NSLogger"
end

I have tried Real Devices running iOS 14 and Simulators on 12.4 with no luck.

I have tried adding the following snippets into the list

    <array>
        <string>_nslogger._tcp</string>
        <string>_nslogger-ssl._tcp</string>
    </array>
    <key>NSLocalNetworkUsageDescription</key>
    <string>Access to the local network for development builds</string>

I have tried adding OS_ACTIVITY_MODE set to disable in Environment Variables for the run schema
image

Could someone point me in the right direction?

@mwyld the snippet you copied is incomplete. Here is the full version:

<key>NSBonjourServices</key>
<array>
	<string>_nslogger._tcp</string>
	<string>_nslogger-ssl._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Access to the local network for development builds</string>

You were missing the first <key> line. I think this should solve your issue.

mwyld commented

Thanks @fpillet for checking this out for me. I got excited it could have been this fix but after checking it looks like I left it off my github description. I had the key in there all along

@mwyld ok the issue may be something else then. I don't use OS_ACTIVITY_MODE and it didn't cause any issue for me. On Big sur there may be some issue with capturing the local console, so try this very early when running your app (i.e. first thing in applicationDidFinishLaunching):

LoggerSetOptions(nil, (LoggerGetOptions(nil) & ~UInt32(kLoggerOption_CaptureSystemConsole)) | UInt32(kLoggerOption_BufferLogsUntilConnection))

This will prevent NSLogger from trying to capture the local console. Not sure it will fix your issue though.

I assume you have the desktop viewer up and running? When it's not logging, it doesn't display any window currently.

mwyld commented

I just had a quick go at adding it in (Will have a further look into it when I've got some more time available).
I build hybrid apps in the ionic framework and export it to Xcode so I don't have too much knowledge with swift/objectiveC

image

add this line along with the other import lines:

import NSLogger

Also if the problem is capturing the local console and you do not specifically use NSLogger for logging, I don't think it will be of much use to you...

@mwyld I also see that you patched the wrong function. Move the LoggerSetOptions call to the previous function just before FirebaseApp.configure()

mwyld commented

Okay, I've made those amendments and tried re-running. But it doesn't run the NSLogger.

I think I just need something easier to read than the xcode output version. When a JSON string comes through, it just becomes unreadable!

image

To verify that NSLogger works correctly you can add this just after LoggerSetOptions:

LogMessageRaw("Hello from NSLogger")

If everything works the NSLogger window will open on your Mac

mwyld commented

Ah interestingly, it still didn't come up?

Maybe I've missed a previous step. This may be a couple of dumb questions but...

  • Do you need to do both Podfile and Carthage install?
  • Once you add the pod line should I be doing some sort of pod refresh?

Apologies for, lack of experience with Xcode

You obviously did a pod install otherwise your import NSLogger wouldn't have compiled at all, so I think you're good on this front.

You don't need to have NSLogger installed both in Podfile and Carthage -- only one is necessary. Throw away the other.

No need to apologize, build systems have become more complex and macOS / iOS more restrictive over the years, and getting NSLogger to work can be more challenging than it should be. Sorry about that.

mwyld commented

No worries. I didn't realise the confirmation for

<key>NSLocalNetworkUsageDescription</key>
<string>Access to the local network for development builds</string>

popped up on my iPhone, after accepting this the NSLogger appeared! but looks like its not logging anything else.

Maybe it's because its a hybrid app. There could be craziness going on under the hood that bypasses the hooks this needs?

Now that you have the Alert thing sorted out, you can comment out the LoggerSetOptions line so that NSLogger can start capturing the console again! Try it that should work now.

mwyld commented

Scrap that. I pulled the two lines we originally put in. It now works! looks like all it needed was the import!

image

mwyld commented

Wheyyy! thanks so much @fpillet ! your a legend! Maybe just an update to the README file might help others that hit the same issue?

@mwyld yeah I'm a bit behind on documenting how to cope with the latest changes in the OS. Glad you got it working 👍 Enjoy !

azav commented
azav commented