Localization with SwiftUI

I have been performing a bit of localization lately on a project and was looking for a way to reduce human errors due to mistyped localization keys.

The best method I found was to create a separate Translation.swift file to storage all the i18n code. Here I extend the LocalizedStringKey struct with my own project localized strings for easy access on the Xcode autocomplete menu.

import SwiftUI

extension LocalizedStringKey {
    static var ourLocalizedProjectName: LocalizedStringKey {
        return "OurLocalizedProjectName"

struct Translation: View {
    var key: LocalizedStringKey

    var body: some View {

    init(_ key: LocalizedStringKey) {
        self.key = key

struct Translation_Previews: PreviewProvider {
    static var previews: some View {
            .environment(\.locale, .init(identifier: "en"))

And add to your Localizable.strings file, strings that correspond to the keys in the extension created earlier.

// Localized project strings
"OurLocalizedProjectName" = "Project Name";

Note, I don’t use the View anywhere in the project, other than to use it for previews in Xcode. I usually populate the view with translations and adjust the locale environment variable to see the different project translations.

Happy translating and stay save in COVIDLand.

Jul 6th, 2020 • Filed under Apple, iOS, Swift, SwiftUI

Customizing Navigation Bar Appreance using SwiftUI

If you are having trouble trying to customize the navigation appearance like I have been.

You can use the following code, I have been placing my code in its own function and calling from the delegate function application(application:launchOptions:).

func customNavigationAppearance() {
     let appearance = UINavigationBarAppearance()

     appearance.backgroundColor = .black
     appearance.titleTextAttributes = [ .foregroundColor: UIColor.white ]
     appearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.white ]

     UINavigationBar.appearance().tintColor = .white
     UINavigationBar.appearance().backgroundColor = .black
     UINavigationBar.appearance().standardAppearance = appearance
     UINavigationBar.appearance().scrollEdgeAppearance = appearance

You can create another appearance for when your navigation is in a scrolled state by setting standardAppearance to an object with your appearance preferences.

Colour appropriately.

Jun 11th, 2020 • Filed under Apple, iOS, SwiftUI

Reduce Array to String for Text and Other Views

If you ever need to concatenate an array of strings for formatting in SwiftUI view, you can use the reduce() function, like this:

let words = ["Hello", "World"]

var body: some View {
    words.reduce(Text(""), { $0 + Text($1) + Text(" ")} ) }

$0 = First parameter of reduce function
$1 = Reduce string

Jun 9th, 2020 • Filed under Apple, iOS, SwiftUI

How-to Investigate Active Directory Logon Mischief

The Windows domain feature for locking accounts can be a helpful feature against malicious attempts to guess a password via brute force.

The version of netlogon.dll that has tracing included is installed by default on all currently supported versions of Windows. To enable debug logging, set the debug flag that you want by using nltest.exe, the registry, or Group Policy.

Group Policy

You will have to adjust a few policy settings to get the DCs to audit logon events. This are usually set correctly, but it can be worth a check of the environment to make sure the DCs are get the proper audit settings.

Audit account logon events for domain accounts and Audit logon events for logons to the computer.


The Event IDs we are most concerned with are under the Windows Logs > Security section of Event Viewer.

  • 4624
  • 4776

If the auditing of Events on Domain Controllers doesn’t reveal the whole story, you can enable debug tracing in the NETLOGON service.

Enable Trace Logging in NETLOGON

If you try audit account logon but the workstation field keeps turning up empty you can enable trace logging on the DC trace debug logs output to C:\Windows\debug\netlogon.log

The log file netlogon.log can grow to 20MB and will be rotated out for a new log file.

To enable and disable trace logging in netlogon service, use the following nltest.exe commands respectively.

nltest.exe /dbflag:2080ffff
nltest.exe /dbflag:0

The following will be written to netlogon.log when you set the flags.

[MISC] [5584] DbFlag is set to 2080ffff

You will find entries these in the netlogon.log file.

[LOGON] [884] X: SamLogon: Transitive Network logon of (null)\ADMIN from (via X) Entered
[LOGON] [884] X: SamLogon: Transitive Network logon of (null)\ADMIN from (via X) Returns 0xC0000064

More information


Increase Service Logging

At times it can be help to increase the logging for a given component, like LDAP Interface Events. You have to do this using regedit, under the following key:



It can be hard to find logon activity in a Windows environment. But, if you have the right policies enabled and know which debug settings to turn when you need to troubleshoot activity, you will be that much further ahead.

Jun 2nd, 2020 • Filed under Active Directory, Microsoft, Windows Server