diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9eaaa1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +# macOS metadata +.DS_Store +.AppleDouble +.LSOverride +._* + +# Xcode per-user state and source-control metadata +xcuserdata/ +*.xcuserstate +*.xccheckout +*.xcscmblueprint + +# Local build products and diagnostics +/DerivedData/ +/build/ +/.build/ +/Archives/ +*.app/ +*.xcarchive/ +*.xcresult/ +*.dSYM/ +*.dSYM.zip + +# SwiftPM local workspace state (keep Package.resolved) +.swiftpm/ + +# Distribution packages +*.dmg +*.pkg + +# Local editor configuration and temporary files +.idea/ +*.swp +*.swo +*~ + +# Local secrets and signing material (keep example configuration) +.env +.env.* +!.env.example +!.env.*.example +*.p12 +*.pfx +*.p8 +*.mobileprovision +*.provisionprofile + +# Shared Xcode schemes, asset catalogs, SVG sources and lockfiles are versioned. diff --git a/Artwork/AppIcon.svg b/Artwork/AppIcon.svg new file mode 100644 index 0000000..ef6e4cc --- /dev/null +++ b/Artwork/AppIcon.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Artwork/README.md b/Artwork/README.md new file mode 100644 index 0000000..b73ee5c --- /dev/null +++ b/Artwork/README.md @@ -0,0 +1,13 @@ +# Application artwork + +`AppIcon.svg` is the vector master for the application icon. The circular Traccar mark remains dominant; the small Apple silhouette is transparent negative space within the lower-left dish. + +The integrated master uses the agreed solid green `#2d7930`. It preserves the approved vector paths and canvas. The Xcode asset catalog contains the generated macOS application icon slots (16–1024 pixels) and a monochrome 18-point menu-bar template at 1× and 2×. + +The About panel uses the bundled application icon. The menu-bar template follows system appearance and retains the artwork's transparent cutouts. + +## Regeneration + +Normal Xcode builds use the checked-in assets and require no additional packages. To regenerate after editing the SVG, run `node scripts/generate-icons.cjs` from the repository with Node.js and the `sharp` package available. If installed outside this repository, set `NODE_PATH` to that installation's `node_modules` directory. The initial asset generation used sharp 0.35.5. + +The generator writes `TraccarClient/Resources/Assets.xcassets`. Each size is rasterized directly from the vector master. Preserve the SVG as the editable source. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..efdb764 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Traccar Client for macOS + +An independent, unofficial native Traccar client for Apple Silicon Macs. + +**Development status:** initial application shell for [issue #1](https://github.com/jayanezj/traccar-client-macos/issues/1). This build stays paused. Location access, tracking, server configuration and position/SOS delivery are not implemented; their menu actions are disabled. + +## Requirements + +- Apple Silicon, starting with M1. +- macOS 15.0 or later. Deployment target 15.0 does not by itself establish runtime test coverage. +- Stable Xcode 27.1 for the initial development toolchain; Swift 6 language mode. + +## Build and run + +Open `TraccarClient.xcodeproj`, select the shared **TraccarClient** scheme and run the macOS target. Set Xcode's Derived Data and Archives locations to your external development volume before building if internal storage is limited. + +For a terminal build, supply an absolute build directory on that volume: + +```sh +scripts/build.sh /path/to/external/build-directory Debug +``` + +Replace the example path with your actual directory. The app is produced at `DerivedData/Build/Products/Debug/Traccar Client macOS.app` beneath it. Use `Release` instead of `Debug` for an optimized build. The shared scheme also supports archiving; configure Xcode's archive location separately. + +The app uses ad hoc signing, with no Apple developer account, provisioning profile or paid certificate. It is not notarized. Downloaded application Gatekeeper behaviour and DMG installation will be validated in [issue #16](https://github.com/jayanezj/traccar-client-macos/issues/16). + +## Initial shell smoke check + +1. Launch the built app. It should show a menu-bar icon, no permanent Dock icon and a paused status. +2. Confirm Start tracking, Send location now and Send SOS are disabled. +3. Open Settings, close its window and reopen it from the menu. The process should remain running. +4. Open About and check the version, unofficial-client statement and Apache-2.0 license information. +5. Quit from the menu. The process should terminate. + +No location permission request or server connection is part of this shell. Real-Mac UI checks remain distinct from automated compilation. Early CI is tracked in [issue #2](https://github.com/jayanezj/traccar-client-macos/issues/2), before subsequent functionality. + +## Artwork + +The application and menu-bar icons are derived from the editable SVG in [Artwork](Artwork/README.md). PNG assets are checked in; normal builds require no artwork tooling. The menu-bar image uses system template rendering for light and dark appearances. + +## License + +[Apache License 2.0](LICENSE). This project is independent of the official Traccar project and does not claim official affiliation. diff --git a/TraccarClient.xcodeproj/project.pbxproj b/TraccarClient.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a2fa5d7 --- /dev/null +++ b/TraccarClient.xcodeproj/project.pbxproj @@ -0,0 +1,33 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = {}; + objectVersion = 77; + objects = { + A00000000000000000000001 = {isa = PBXBuildFile; fileRef = B00000000000000000000001; }; + B00000000000000000000001 = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Application/TraccarClientApp.swift; sourceTree = ""; }; + A00000000000000000000002 = {isa = PBXBuildFile; fileRef = B00000000000000000000002; }; + B00000000000000000000002 = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interface/TrackingMenu.swift; sourceTree = ""; }; + A00000000000000000000003 = {isa = PBXBuildFile; fileRef = B00000000000000000000003; }; + B00000000000000000000003 = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Interface/SettingsView.swift; sourceTree = ""; }; + B00000000000000000000004 = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Resources/Info.plist; sourceTree = ""; }; + A00000000000000000000004 = {isa = PBXBuildFile; fileRef = B00000000000000000000006; }; + B00000000000000000000006 = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Resources/Assets.xcassets; sourceTree = ""; }; + B00000000000000000000005 = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Traccar Client macOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + C00000000000000000000001 = {isa = PBXGroup; children = (C00000000000000000000002, C00000000000000000000003); sourceTree = ""; }; + C00000000000000000000002 = {isa = PBXGroup; children = (B00000000000000000000001, B00000000000000000000002, B00000000000000000000003, B00000000000000000000004, B00000000000000000000006); path = TraccarClient; sourceTree = ""; }; + C00000000000000000000003 = {isa = PBXGroup; children = (B00000000000000000000005); name = Products; sourceTree = ""; }; + D00000000000000000000001 = {isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = (A00000000000000000000001, A00000000000000000000002, A00000000000000000000003); runOnlyForDeploymentPostprocessing = 0; }; + D00000000000000000000002 = {isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = (); runOnlyForDeploymentPostprocessing = 0; }; + D00000000000000000000003 = {isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = (A00000000000000000000004); runOnlyForDeploymentPostprocessing = 0; }; + E00000000000000000000001 = {isa = PBXNativeTarget; buildConfigurationList = F00000000000000000000002; buildPhases = (D00000000000000000000001, D00000000000000000000002, D00000000000000000000003); buildRules = (); dependencies = (); name = TraccarClient; productName = "Traccar Client macOS"; productReference = B00000000000000000000005; productType = "com.apple.product-type.application"; }; + E00000000000000000000002 = {isa = PBXProject; attributes = {BuildIndependentTargetsInParallel = YES; LastUpgradeCheck = 2710; TargetAttributes = {E00000000000000000000001 = {CreatedOnToolsVersion = 27.1; }; }; }; buildConfigurationList = F00000000000000000000001; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = (en, Base); mainGroup = C00000000000000000000001; minimizedProjectReferenceProxies = 1; preferredProjectObjectVersion = 77; productRefGroup = C00000000000000000000003; projectDirPath = ""; projectRoot = ""; targets = (E00000000000000000000001); }; + F00000000000000000000001 = {isa = XCConfigurationList; buildConfigurations = (F00000000000000000000003, F00000000000000000000004); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + F00000000000000000000002 = {isa = XCConfigurationList; buildConfigurations = (F00000000000000000000005, F00000000000000000000006); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + F00000000000000000000003 = {isa = XCBuildConfiguration; buildSettings = {CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; SDKROOT = macosx; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_TESTABILITY = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone";}; name = Debug; }; + F00000000000000000000004 = {isa = XCBuildConfiguration; buildSettings = {CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; ENABLE_USER_SCRIPT_SANDBOXING = YES; SDKROOT = macosx; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O";}; name = Release; }; + F00000000000000000000005 = {isa = XCBuildConfiguration; buildSettings = {ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = TraccarClient/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 0.1.0; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.codigojose.traccar-client-macos; PRODUCT_NAME = "Traccar Client macOS"; SUPPORTED_PLATFORMS = macosx; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_MODULE_NAME = TraccarClient; SWIFT_VERSION = 6.0;}; name = Debug; }; + F00000000000000000000006 = {isa = XCBuildConfiguration; buildSettings = {ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = NO; INFOPLIST_FILE = TraccarClient/Resources/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 15.0; MARKETING_VERSION = 0.1.0; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = com.codigojose.traccar-client-macos; PRODUCT_NAME = "Traccar Client macOS"; SUPPORTED_PLATFORMS = macosx; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_MODULE_NAME = TraccarClient; SWIFT_VERSION = 6.0;}; name = Release; }; + }; + rootObject = E00000000000000000000002; +} diff --git a/TraccarClient.xcodeproj/xcshareddata/xcschemes/TraccarClient.xcscheme b/TraccarClient.xcodeproj/xcshareddata/xcschemes/TraccarClient.xcscheme new file mode 100644 index 0000000..6788076 --- /dev/null +++ b/TraccarClient.xcodeproj/xcshareddata/xcschemes/TraccarClient.xcscheme @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/TraccarClient/Application/TraccarClientApp.swift b/TraccarClient/Application/TraccarClientApp.swift new file mode 100644 index 0000000..e0bd98a --- /dev/null +++ b/TraccarClient/Application/TraccarClientApp.swift @@ -0,0 +1,29 @@ +import AppKit +import SwiftUI + +@main +struct TraccarClientApp: App { + @NSApplicationDelegateAdaptor(ApplicationDelegate.self) private var delegate + + var body: some Scene { + MenuBarExtra { + TrackingMenu() + } label: { + Image("MenuBarIcon") + .renderingMode(.template) + .accessibilityLabel("Traccar Client — Paused") + } + .menuBarExtraStyle(.menu) + + Settings { + SettingsView() + } + } +} + +@MainActor +final class ApplicationDelegate: NSObject, NSApplicationDelegate { + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + false + } +} diff --git a/TraccarClient/Interface/SettingsView.swift b/TraccarClient/Interface/SettingsView.swift new file mode 100644 index 0000000..c44b16d --- /dev/null +++ b/TraccarClient/Interface/SettingsView.swift @@ -0,0 +1,34 @@ +import SwiftUI + +struct SettingsView: View { + var body: some View { + TabView { + Form { + LabeledContent("Status", value: "Paused") + Text("Server and device configuration will be available in a later build.") + } + .tabItem { Label("Connection", systemImage: "network") } + + Form { + Text("Continuous tracking, manual location and SOS are not implemented yet.") + Text("This build does not request your location or send positions.") + } + .tabItem { Label("Tracking", systemImage: "location") } + + Form { + Text("Login startup and tracking restoration are not enabled.") + Text("Closing Settings keeps the app in the menu bar. Use Quit to exit.") + } + .tabItem { Label("General", systemImage: "gearshape") } + + Form { + LabeledContent("Status", value: "Paused") + Text("No location or network activity is started by this application shell.") + } + .tabItem { Label("Diagnostics", systemImage: "waveform.path.ecg") } + } + .formStyle(.grouped) + .padding() + .frame(width: 560, height: 320) + } +} diff --git a/TraccarClient/Interface/TrackingMenu.swift b/TraccarClient/Interface/TrackingMenu.swift new file mode 100644 index 0000000..af7e3c2 --- /dev/null +++ b/TraccarClient/Interface/TrackingMenu.swift @@ -0,0 +1,45 @@ +import AppKit +import SwiftUI + +struct TrackingMenu: View { + @Environment(\.openSettings) private var openSettings + + var body: some View { + Text("Paused") + Text("Tracking is not available in this build.") + + Divider() + + Button("Start tracking") {} + .disabled(true) + Button("Send location now") {} + .disabled(true) + Button("Send SOS") {} + .disabled(true) + + Divider() + + Button("Settings…") { + NSApplication.shared.activate(ignoringOtherApps: true) + openSettings() + } + .keyboardShortcut(",") + + Button("About Traccar Client for macOS") { + NSApplication.shared.activate(ignoringOtherApps: true) + NSApplication.shared.orderFrontStandardAboutPanel(options: [ + .applicationName: "Traccar Client for macOS", + .credits: NSAttributedString( + string: "An independent, unofficial Traccar client.\nLicensed under Apache License 2.0." + ), + ]) + } + + Divider() + + Button("Quit Traccar Client macOS") { + NSApplication.shared.terminate(nil) + } + .keyboardShortcut("q") + } +} diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..6fcd02e --- /dev/null +++ b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images": [ + { + "filename": "icon_16x16.png", + "idiom": "mac", + "size": "16x16", + "scale": "1x" + }, + { + "filename": "icon_16x16@2x.png", + "idiom": "mac", + "size": "16x16", + "scale": "2x" + }, + { + "filename": "icon_32x32.png", + "idiom": "mac", + "size": "32x32", + "scale": "1x" + }, + { + "filename": "icon_32x32@2x.png", + "idiom": "mac", + "size": "32x32", + "scale": "2x" + }, + { + "filename": "icon_128x128.png", + "idiom": "mac", + "size": "128x128", + "scale": "1x" + }, + { + "filename": "icon_128x128@2x.png", + "idiom": "mac", + "size": "128x128", + "scale": "2x" + }, + { + "filename": "icon_256x256.png", + "idiom": "mac", + "size": "256x256", + "scale": "1x" + }, + { + "filename": "icon_256x256@2x.png", + "idiom": "mac", + "size": "256x256", + "scale": "2x" + }, + { + "filename": "icon_512x512.png", + "idiom": "mac", + "size": "512x512", + "scale": "1x" + }, + { + "filename": "icon_512x512@2x.png", + "idiom": "mac", + "size": "512x512", + "scale": "2x" + } + ], + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png new file mode 100644 index 0000000..a81f524 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png new file mode 100644 index 0000000..902c623 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png new file mode 100644 index 0000000..d3344e3 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png new file mode 100644 index 0000000..26d9c0f Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png new file mode 100644 index 0000000..902c623 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png new file mode 100644 index 0000000..8dece87 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png new file mode 100644 index 0000000..26d9c0f Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png new file mode 100644 index 0000000..e0c0745 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png new file mode 100644 index 0000000..8dece87 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png new file mode 100644 index 0000000..66c5cf8 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/Contents.json b/TraccarClient/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000..74d6a72 --- /dev/null +++ b/TraccarClient/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info": { + "author": "xcode", + "version": 1 + } +} diff --git a/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/Contents.json b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/Contents.json new file mode 100644 index 0000000..4e3f0c0 --- /dev/null +++ b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images": [ + { + "filename": "menu.png", + "idiom": "mac", + "scale": "1x" + }, + { + "filename": "menu@2x.png", + "idiom": "mac", + "scale": "2x" + } + ], + "info": { + "author": "xcode", + "version": 1 + }, + "properties": { + "template-rendering-intent": "template" + } +} diff --git a/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu.png b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu.png new file mode 100644 index 0000000..ec62fd3 Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu.png differ diff --git a/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu@2x.png b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu@2x.png new file mode 100644 index 0000000..dedc2ae Binary files /dev/null and b/TraccarClient/Resources/Assets.xcassets/MenuBarIcon.imageset/menu@2x.png differ diff --git a/TraccarClient/Resources/Info.plist b/TraccarClient/Resources/Info.plist new file mode 100644 index 0000000..198d9ff --- /dev/null +++ b/TraccarClient/Resources/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Traccar Client for macOS + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSApplicationCategoryType + public.app-category.utilities + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSHumanReadableCopyright + Licensed under the Apache License, Version 2.0. + NSPrincipalClass + NSApplication + + diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..1c36025 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -euo pipefail + +build_root="${1:?Usage: scripts/build.sh /absolute/path/to/external/build-directory [Debug|Release]}" +configuration="${2:-Debug}" +case "$build_root" in + /*) ;; + *) echo "The build directory must be an absolute path." >&2; exit 2 ;; +esac +case "$configuration" in + Debug|Release) ;; + *) echo "Configuration must be Debug or Release." >&2; exit 2 ;; +esac +repo_root="$(cd "$(dirname "$0")/.." && pwd)" +mkdir -p "$build_root" + +exec xcodebuild \ + -project "$repo_root/TraccarClient.xcodeproj" \ + -scheme TraccarClient \ + -configuration "$configuration" \ + -destination 'platform=macOS,arch=arm64' \ + -derivedDataPath "$build_root/DerivedData" \ + "CLANG_MODULE_CACHE_PATH=$build_root/ModuleCache" \ + "SWIFT_MODULE_CACHE_PATH=$build_root/ModuleCache" \ + build diff --git a/scripts/generate-icons.cjs b/scripts/generate-icons.cjs new file mode 100644 index 0000000..a1723a1 --- /dev/null +++ b/scripts/generate-icons.cjs @@ -0,0 +1,61 @@ +#!/usr/bin/env node +'use strict'; + +// Optional artwork tooling only; Xcode builds use the checked-in PNGs. +const fs = require('node:fs/promises'); +const path = require('node:path'); +const sharp = require('sharp'); + +const root = path.resolve(__dirname, '..'); +const assets = path.join(root, 'TraccarClient/Resources/Assets.xcassets'); +const info = { author: 'xcode', version: 1 }; + +async function writeJSON(file, value) { + await fs.writeFile(file, `${JSON.stringify(value, null, 2)}\n`); +} + +async function render(svg, size, destination) { + // Rasterize the vector at each output size, without enlarging a raster master. + const input = svg.replace(/]*>/, (tag) => tag + .replace(/\bwidth="[^"]*"/, `width="${size}px"`) + .replace(/\bheight="[^"]*"/, `height="${size}px"`)); + await sharp(Buffer.from(input)).ensureAlpha().png().toFile(destination); +} + +async function main() { + const svg = await fs.readFile(path.join(root, 'Artwork/AppIcon.svg'), 'utf8'); + const appIcon = path.join(assets, 'AppIcon.appiconset'); + const menuIcon = path.join(assets, 'MenuBarIcon.imageset'); + await fs.mkdir(appIcon, { recursive: true }); + await fs.mkdir(menuIcon, { recursive: true }); + await writeJSON(path.join(assets, 'Contents.json'), { info }); + + const images = []; + for (const size of [16, 32, 128, 256, 512]) { + for (const scale of [1, 2]) { + const filename = `icon_${size}x${size}${scale === 2 ? '@2x' : ''}.png`; + await render(svg, size * scale, path.join(appIcon, filename)); + images.push({ filename, idiom: 'mac', size: `${size}x${size}`, scale: `${scale}x` }); + } + } + await writeJSON(path.join(appIcon, 'Contents.json'), { images, info }); + + const menuImages = []; + const templateSVG = svg.replaceAll('#2d7930', '#000000'); + for (const scale of [1, 2]) { + const filename = `menu${scale === 2 ? '@2x' : ''}.png`; + await render(templateSVG, 18 * scale, path.join(menuIcon, filename)); + menuImages.push({ filename, idiom: 'mac', scale: `${scale}x` }); + } + await writeJSON(path.join(menuIcon, 'Contents.json'), { + images: menuImages, + info, + properties: { 'template-rendering-intent': 'template' }, + }); + console.log(`Generated 10 app icon slots and 2 menu images with sharp ${sharp.versions.sharp}.`); +} + +main().catch((error) => { + console.error(error.message); + process.exitCode = 1; +});