This file provides guidance to any AI coding agent working with this repository.
NetworkMap — a macOS menu bar app (Swift 6 / SwiftUI) that shows the user's public IP address in real-time via MenuBarExtra. Runs as a background accessory with no Dock icon.
Requirements: macOS 13.0+, Swift 5.7+
./build.sh # release build + .app bundle packaging (embeds Sparkle & signs ad-hoc)
open NetworkMap.app # launch the app
swift build # debug build only (no .app bundle)Clean: rm -rf .build NetworkMap.app
The project uses GitHub Actions (.github/workflows/release.yml) to handle automated releases.
- Triggered on pushes to tags starting with
v*(e.g.,v1.0.0). - Derives
VERSIONandBUILD_NUMBERfrom the git tag and commit count. - Generates app and menu bar icons from
icon.svgviagenerate_icons.swift. - Builds the app using
build.shand ad-hoc signs it (codesign -s - -f --deep). - Packages the
.appinto a DMG viacreate-dmg.sh. - Publishes the DMG as a GitHub Release artifact.
- Generates a Sparkle appcast (
appcast.xml) and deploys it to GitHub Pages for auto-updates. - If the
TAP_GITHUB_TOKENsecret is set, auto-updates the Homebrew cask incarlosas/homebrew-tap.
There are no tests.
Source files in Sources/NetworkMap/:
-
NetworkMapApp.swift—@mainentry point. Declares a windowed-styleMenuBarExtrascene (SwiftUI) using a custom menu bar icon loaded from bundledMenuBarIconresources. The menu displays the public IP, and uses a customMenuItemButtonview for Refresh, Check for Updates, and Quit actions. UsesAppDelegateto setNSApp.setActivationPolicy(.accessory)so the app has no Dock icon. Initializes theSPUStandardUpdaterControllerfor Sparkle auto-updates. -
NetworkManager.swift—@MainActor ObservableObject. Fetches IP fromhttps://api.ipify.orgviaURLSessionasync/await. Monitors network changes withNWPathMonitorto auto-refresh. PublishescurrentIP("Fetching..."→ IP string or"Offline"). -
Resources/— Bundled assets:AppIcon.icns(application icon),MenuBarIcon.pngandMenuBarIcon@2x.png(template images for the menu bar). These are copied into the.appbundle bybuild.sh.
-
build.sh— Release build script. Runsswift build -c release, constructs the.appbundle, writesInfo.plist(withLSUIElement, Sparkle keys, and version strings), copies icon resources, embedsSparkle.framework, and sets the executable'srpath. DerivesVERSIONfrom the latest git tag andBUILD_NUMBERfrom the git commit count when not set by CI. -
create-dmg.sh— PackagesNetworkMap.appinto a distributable DMG. -
generate_icons.swift— GeneratesAppIcon.icnsandMenuBarIconPNGs fromicon.svgusingAppKitAPIs. -
icon.svg— Source vector asset for all app icons.
- Use
async/awaitandTaskfor all asynchronous work — no completion handlers. - Use
@StateObject/@Publishedfor SwiftUI state management. - UI uses
.monospacedsystem fonts for IP display and a customMenuItemButtoncomponent for interactive menu items. - The menu bar icon is a template image loaded from bundled resources (with SF Symbol fallback).
The app requires LSUIElement = 1 in Info.plist to hide from the Dock. Swift Package Manager cannot set this, so build.sh manually constructs the .app bundle structure, writes Info.plist after swift build -c release, embeds the Sparkle.framework, copies icon resources, and modifies the executable's rpath. Any new Info.plist keys (such as SUFeedURL or SUPublicEDKey) must be added to build.sh. Version strings (CFBundleShortVersionString, CFBundleVersion) are also injected by the script.