├── .gitignore ├── LICENSE ├── README.md ├── SwiftStatusBarApplication.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── SwiftStatusBarApplication.xccheckout ├── SwiftStatusBarApplication ├── AppDelegate.swift ├── Base.lproj │ └── MainMenu.xib ├── IconView.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── Resources │ ├── icon.pxm │ └── icon@2x.png └── SwiftStatusBarApplicationTests ├── Info.plist └── SwiftStatusBarApplicationTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | SwiftStatusBarApplication.xcodeproj/xcuserdata 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Tommy Leung 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | swift-status-bar-app-osx 2 | ======================== 3 | 4 | Example of a status bar application for OS X in Swift. 5 | 6 | ### Resources 7 | 8 | [Swift Language Guide](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097) 9 | 10 | [Swift Blog](https://developer.apple.com/swift/blog/) 11 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 65DED9641943997E0059A266 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65DED9631943997E0059A266 /* AppDelegate.swift */; }; 11 | 65DED9661943997E0059A266 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 65DED9651943997E0059A266 /* Images.xcassets */; }; 12 | 65DED9691943997E0059A266 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 65DED9671943997E0059A266 /* MainMenu.xib */; }; 13 | 65DED9751943997E0059A266 /* SwiftStatusBarApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65DED9741943997E0059A266 /* SwiftStatusBarApplicationTests.swift */; }; 14 | 65DED97F194399AB0059A266 /* IconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65DED97E194399AB0059A266 /* IconView.swift */; }; 15 | 65DED98419439B020059A266 /* icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 65DED98219439B020059A266 /* icon@2x.png */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXContainerItemProxy section */ 19 | 65DED96F1943997E0059A266 /* PBXContainerItemProxy */ = { 20 | isa = PBXContainerItemProxy; 21 | containerPortal = 65DED9541943997E0059A266 /* Project object */; 22 | proxyType = 1; 23 | remoteGlobalIDString = 65DED95B1943997E0059A266; 24 | remoteInfo = SwiftStatusBarApplication; 25 | }; 26 | /* End PBXContainerItemProxy section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 65DED95C1943997E0059A266 /* SwiftStatusBarApplication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftStatusBarApplication.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 65DED9601943997E0059A266 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 65DED9631943997E0059A266 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 32 | 65DED9651943997E0059A266 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 33 | 65DED9681943997E0059A266 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; 34 | 65DED96E1943997E0059A266 /* SwiftStatusBarApplicationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftStatusBarApplicationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 65DED9731943997E0059A266 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 65DED9741943997E0059A266 /* SwiftStatusBarApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftStatusBarApplicationTests.swift; sourceTree = ""; }; 37 | 65DED97E194399AB0059A266 /* IconView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IconView.swift; sourceTree = ""; }; 38 | 65DED98219439B020059A266 /* icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "icon@2x.png"; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | 65DED9591943997E0059A266 /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | 65DED96B1943997E0059A266 /* Frameworks */ = { 50 | isa = PBXFrameworksBuildPhase; 51 | buildActionMask = 2147483647; 52 | files = ( 53 | ); 54 | runOnlyForDeploymentPostprocessing = 0; 55 | }; 56 | /* End PBXFrameworksBuildPhase section */ 57 | 58 | /* Begin PBXGroup section */ 59 | 65DED9531943997E0059A266 = { 60 | isa = PBXGroup; 61 | children = ( 62 | 65DED95E1943997E0059A266 /* SwiftStatusBarApplication */, 63 | 65DED9711943997E0059A266 /* SwiftStatusBarApplicationTests */, 64 | 65DED95D1943997E0059A266 /* Products */, 65 | ); 66 | sourceTree = ""; 67 | }; 68 | 65DED95D1943997E0059A266 /* Products */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | 65DED95C1943997E0059A266 /* SwiftStatusBarApplication.app */, 72 | 65DED96E1943997E0059A266 /* SwiftStatusBarApplicationTests.xctest */, 73 | ); 74 | name = Products; 75 | sourceTree = ""; 76 | }; 77 | 65DED95E1943997E0059A266 /* SwiftStatusBarApplication */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 65DED98019439B020059A266 /* Resources */, 81 | 65DED9631943997E0059A266 /* AppDelegate.swift */, 82 | 65DED97E194399AB0059A266 /* IconView.swift */, 83 | 65DED9651943997E0059A266 /* Images.xcassets */, 84 | 65DED9671943997E0059A266 /* MainMenu.xib */, 85 | 65DED95F1943997E0059A266 /* Supporting Files */, 86 | ); 87 | path = SwiftStatusBarApplication; 88 | sourceTree = ""; 89 | }; 90 | 65DED95F1943997E0059A266 /* Supporting Files */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 65DED9601943997E0059A266 /* Info.plist */, 94 | ); 95 | name = "Supporting Files"; 96 | sourceTree = ""; 97 | }; 98 | 65DED9711943997E0059A266 /* SwiftStatusBarApplicationTests */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 65DED9741943997E0059A266 /* SwiftStatusBarApplicationTests.swift */, 102 | 65DED9721943997E0059A266 /* Supporting Files */, 103 | ); 104 | path = SwiftStatusBarApplicationTests; 105 | sourceTree = ""; 106 | }; 107 | 65DED9721943997E0059A266 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 65DED9731943997E0059A266 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | 65DED98019439B020059A266 /* Resources */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 65DED98219439B020059A266 /* icon@2x.png */, 119 | ); 120 | path = Resources; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | 65DED95B1943997E0059A266 /* SwiftStatusBarApplication */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 65DED9781943997E0059A266 /* Build configuration list for PBXNativeTarget "SwiftStatusBarApplication" */; 129 | buildPhases = ( 130 | 65DED9581943997E0059A266 /* Sources */, 131 | 65DED9591943997E0059A266 /* Frameworks */, 132 | 65DED95A1943997E0059A266 /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | ); 138 | name = SwiftStatusBarApplication; 139 | productName = SwiftStatusBarApplication; 140 | productReference = 65DED95C1943997E0059A266 /* SwiftStatusBarApplication.app */; 141 | productType = "com.apple.product-type.application"; 142 | }; 143 | 65DED96D1943997E0059A266 /* SwiftStatusBarApplicationTests */ = { 144 | isa = PBXNativeTarget; 145 | buildConfigurationList = 65DED97B1943997E0059A266 /* Build configuration list for PBXNativeTarget "SwiftStatusBarApplicationTests" */; 146 | buildPhases = ( 147 | 65DED96A1943997E0059A266 /* Sources */, 148 | 65DED96B1943997E0059A266 /* Frameworks */, 149 | 65DED96C1943997E0059A266 /* Resources */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | 65DED9701943997E0059A266 /* PBXTargetDependency */, 155 | ); 156 | name = SwiftStatusBarApplicationTests; 157 | productName = SwiftStatusBarApplicationTests; 158 | productReference = 65DED96E1943997E0059A266 /* SwiftStatusBarApplicationTests.xctest */; 159 | productType = "com.apple.product-type.bundle.unit-test"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | 65DED9541943997E0059A266 /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | LastUpgradeCheck = 0600; 168 | ORGANIZATIONNAME = "Tommy Leung"; 169 | TargetAttributes = { 170 | 65DED95B1943997E0059A266 = { 171 | CreatedOnToolsVersion = 6.0; 172 | }; 173 | 65DED96D1943997E0059A266 = { 174 | CreatedOnToolsVersion = 6.0; 175 | TestTargetID = 65DED95B1943997E0059A266; 176 | }; 177 | }; 178 | }; 179 | buildConfigurationList = 65DED9571943997E0059A266 /* Build configuration list for PBXProject "SwiftStatusBarApplication" */; 180 | compatibilityVersion = "Xcode 3.2"; 181 | developmentRegion = English; 182 | hasScannedForEncodings = 0; 183 | knownRegions = ( 184 | en, 185 | Base, 186 | ); 187 | mainGroup = 65DED9531943997E0059A266; 188 | productRefGroup = 65DED95D1943997E0059A266 /* Products */; 189 | projectDirPath = ""; 190 | projectRoot = ""; 191 | targets = ( 192 | 65DED95B1943997E0059A266 /* SwiftStatusBarApplication */, 193 | 65DED96D1943997E0059A266 /* SwiftStatusBarApplicationTests */, 194 | ); 195 | }; 196 | /* End PBXProject section */ 197 | 198 | /* Begin PBXResourcesBuildPhase section */ 199 | 65DED95A1943997E0059A266 /* Resources */ = { 200 | isa = PBXResourcesBuildPhase; 201 | buildActionMask = 2147483647; 202 | files = ( 203 | 65DED98419439B020059A266 /* icon@2x.png in Resources */, 204 | 65DED9661943997E0059A266 /* Images.xcassets in Resources */, 205 | 65DED9691943997E0059A266 /* MainMenu.xib in Resources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | 65DED96C1943997E0059A266 /* Resources */ = { 210 | isa = PBXResourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXResourcesBuildPhase section */ 217 | 218 | /* Begin PBXSourcesBuildPhase section */ 219 | 65DED9581943997E0059A266 /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 65DED9641943997E0059A266 /* AppDelegate.swift in Sources */, 224 | 65DED97F194399AB0059A266 /* IconView.swift in Sources */, 225 | ); 226 | runOnlyForDeploymentPostprocessing = 0; 227 | }; 228 | 65DED96A1943997E0059A266 /* Sources */ = { 229 | isa = PBXSourcesBuildPhase; 230 | buildActionMask = 2147483647; 231 | files = ( 232 | 65DED9751943997E0059A266 /* SwiftStatusBarApplicationTests.swift in Sources */, 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXSourcesBuildPhase section */ 237 | 238 | /* Begin PBXTargetDependency section */ 239 | 65DED9701943997E0059A266 /* PBXTargetDependency */ = { 240 | isa = PBXTargetDependency; 241 | target = 65DED95B1943997E0059A266 /* SwiftStatusBarApplication */; 242 | targetProxy = 65DED96F1943997E0059A266 /* PBXContainerItemProxy */; 243 | }; 244 | /* End PBXTargetDependency section */ 245 | 246 | /* Begin PBXVariantGroup section */ 247 | 65DED9671943997E0059A266 /* MainMenu.xib */ = { 248 | isa = PBXVariantGroup; 249 | children = ( 250 | 65DED9681943997E0059A266 /* Base */, 251 | ); 252 | name = MainMenu.xib; 253 | sourceTree = ""; 254 | }; 255 | /* End PBXVariantGroup section */ 256 | 257 | /* Begin XCBuildConfiguration section */ 258 | 65DED9761943997E0059A266 /* Debug */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 263 | CLANG_CXX_LIBRARY = "libc++"; 264 | CLANG_ENABLE_MODULES = YES; 265 | CLANG_ENABLE_OBJC_ARC = YES; 266 | CLANG_WARN_BOOL_CONVERSION = YES; 267 | CLANG_WARN_CONSTANT_CONVERSION = YES; 268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 269 | CLANG_WARN_EMPTY_BODY = YES; 270 | CLANG_WARN_ENUM_CONVERSION = YES; 271 | CLANG_WARN_INT_CONVERSION = YES; 272 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 273 | CLANG_WARN_UNREACHABLE_CODE = YES; 274 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 275 | CODE_SIGN_IDENTITY = "-"; 276 | COPY_PHASE_STRIP = NO; 277 | ENABLE_STRICT_OBJC_MSGSEND = YES; 278 | GCC_C_LANGUAGE_STANDARD = gnu99; 279 | GCC_DYNAMIC_NO_PIC = NO; 280 | GCC_OPTIMIZATION_LEVEL = 0; 281 | GCC_PREPROCESSOR_DEFINITIONS = ( 282 | "DEBUG=1", 283 | "$(inherited)", 284 | ); 285 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 286 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 287 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 288 | GCC_WARN_UNDECLARED_SELECTOR = YES; 289 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 290 | GCC_WARN_UNUSED_FUNCTION = YES; 291 | GCC_WARN_UNUSED_VARIABLE = YES; 292 | MACOSX_DEPLOYMENT_TARGET = 10.9; 293 | METAL_ENABLE_DEBUG_INFO = YES; 294 | ONLY_ACTIVE_ARCH = YES; 295 | SDKROOT = macosx; 296 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 297 | }; 298 | name = Debug; 299 | }; 300 | 65DED9771943997E0059A266 /* Release */ = { 301 | isa = XCBuildConfiguration; 302 | buildSettings = { 303 | ALWAYS_SEARCH_USER_PATHS = NO; 304 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 305 | CLANG_CXX_LIBRARY = "libc++"; 306 | CLANG_ENABLE_MODULES = YES; 307 | CLANG_ENABLE_OBJC_ARC = YES; 308 | CLANG_WARN_BOOL_CONVERSION = YES; 309 | CLANG_WARN_CONSTANT_CONVERSION = YES; 310 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INT_CONVERSION = YES; 314 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | CODE_SIGN_IDENTITY = "-"; 318 | COPY_PHASE_STRIP = YES; 319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 320 | ENABLE_NS_ASSERTIONS = NO; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | GCC_C_LANGUAGE_STANDARD = gnu99; 323 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 324 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 325 | GCC_WARN_UNDECLARED_SELECTOR = YES; 326 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 327 | GCC_WARN_UNUSED_FUNCTION = YES; 328 | GCC_WARN_UNUSED_VARIABLE = YES; 329 | MACOSX_DEPLOYMENT_TARGET = 10.9; 330 | METAL_ENABLE_DEBUG_INFO = NO; 331 | SDKROOT = macosx; 332 | }; 333 | name = Release; 334 | }; 335 | 65DED9791943997E0059A266 /* Debug */ = { 336 | isa = XCBuildConfiguration; 337 | buildSettings = { 338 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 339 | COMBINE_HIDPI_IMAGES = YES; 340 | INFOPLIST_FILE = SwiftStatusBarApplication/Info.plist; 341 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | }; 344 | name = Debug; 345 | }; 346 | 65DED97A1943997E0059A266 /* Release */ = { 347 | isa = XCBuildConfiguration; 348 | buildSettings = { 349 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 350 | COMBINE_HIDPI_IMAGES = YES; 351 | INFOPLIST_FILE = SwiftStatusBarApplication/Info.plist; 352 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | }; 355 | name = Release; 356 | }; 357 | 65DED97C1943997E0059A266 /* Debug */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftStatusBarApplication.app/Contents/MacOS/SwiftStatusBarApplication"; 361 | COMBINE_HIDPI_IMAGES = YES; 362 | FRAMEWORK_SEARCH_PATHS = ( 363 | "$(DEVELOPER_FRAMEWORKS_DIR)", 364 | "$(inherited)", 365 | ); 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | INFOPLIST_FILE = SwiftStatusBarApplicationTests/Info.plist; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 372 | METAL_ENABLE_DEBUG_INFO = YES; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | TEST_HOST = "$(BUNDLE_LOADER)"; 375 | }; 376 | name = Debug; 377 | }; 378 | 65DED97D1943997E0059A266 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SwiftStatusBarApplication.app/Contents/MacOS/SwiftStatusBarApplication"; 382 | COMBINE_HIDPI_IMAGES = YES; 383 | FRAMEWORK_SEARCH_PATHS = ( 384 | "$(DEVELOPER_FRAMEWORKS_DIR)", 385 | "$(inherited)", 386 | ); 387 | INFOPLIST_FILE = SwiftStatusBarApplicationTests/Info.plist; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 389 | METAL_ENABLE_DEBUG_INFO = NO; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | TEST_HOST = "$(BUNDLE_LOADER)"; 392 | }; 393 | name = Release; 394 | }; 395 | /* End XCBuildConfiguration section */ 396 | 397 | /* Begin XCConfigurationList section */ 398 | 65DED9571943997E0059A266 /* Build configuration list for PBXProject "SwiftStatusBarApplication" */ = { 399 | isa = XCConfigurationList; 400 | buildConfigurations = ( 401 | 65DED9761943997E0059A266 /* Debug */, 402 | 65DED9771943997E0059A266 /* Release */, 403 | ); 404 | defaultConfigurationIsVisible = 0; 405 | defaultConfigurationName = Release; 406 | }; 407 | 65DED9781943997E0059A266 /* Build configuration list for PBXNativeTarget "SwiftStatusBarApplication" */ = { 408 | isa = XCConfigurationList; 409 | buildConfigurations = ( 410 | 65DED9791943997E0059A266 /* Debug */, 411 | 65DED97A1943997E0059A266 /* Release */, 412 | ); 413 | defaultConfigurationIsVisible = 0; 414 | defaultConfigurationName = Release; 415 | }; 416 | 65DED97B1943997E0059A266 /* Build configuration list for PBXNativeTarget "SwiftStatusBarApplicationTests" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | 65DED97C1943997E0059A266 /* Debug */, 420 | 65DED97D1943997E0059A266 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | /* End XCConfigurationList section */ 426 | }; 427 | rootObject = 65DED9541943997E0059A266 /* Project object */; 428 | } 429 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication.xcodeproj/project.xcworkspace/xcshareddata/SwiftStatusBarApplication.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 8D44C34E-1728-4050-A052-933C93C2F686 9 | IDESourceControlProjectName 10 | SwiftStatusBarApplication 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 398B0E3BBF9302030890DBF8C391A80E2F32A931 14 | github.com:supertommy/swift-status-bar-app-osx.git 15 | 16 | IDESourceControlProjectPath 17 | SwiftStatusBarApplication.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 398B0E3BBF9302030890DBF8C391A80E2F32A931 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:supertommy/swift-status-bar-app-osx.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 398B0E3BBF9302030890DBF8C391A80E2F32A931 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 398B0E3BBF9302030890DBF8C391A80E2F32A931 36 | IDESourceControlWCCName 37 | SwiftStatusBarApplication 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftStatusBarApplication 4 | // 5 | // Created by Tommy Leung on 6/7/14. 6 | // Copyright (c) 2014 Tommy Leung. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate 13 | { 14 | @IBOutlet var window: NSWindow? 15 | @IBOutlet var popover : NSPopover? 16 | 17 | private let icon: IconView; 18 | 19 | override init() 20 | { 21 | let bar = NSStatusBar.systemStatusBar(); 22 | 23 | let length: CGFloat = -1 //NSVariableStatusItemLength 24 | let item = bar.statusItemWithLength(length); 25 | 26 | self.icon = IconView(imageName: "icon", item: item); 27 | item.view = icon; 28 | 29 | super.init(); 30 | } 31 | 32 | func applicationDidFinishLaunching(aNotification: NSNotification?) 33 | { 34 | // Insert code here to initialize your application 35 | } 36 | 37 | func applicationWillTerminate(aNotification: NSNotification?) 38 | { 39 | // Insert code here to tear down your application 40 | } 41 | 42 | override func awakeFromNib() 43 | { 44 | let edge = NSMinYEdge 45 | let icon = self.icon 46 | let rect = icon.frame 47 | 48 | icon.onMouseDown = { 49 | if (icon.isSelected) 50 | { 51 | self.popover?.showRelativeToRect(rect, ofView: icon, preferredEdge: edge); 52 | return 53 | } 54 | self.popover?.close() 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication/Base.lproj/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | Default 539 | 540 | 541 | 542 | 543 | 544 | 545 | Left to Right 546 | 547 | 548 | 549 | 550 | 551 | 552 | Right to Left 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | Default 564 | 565 | 566 | 567 | 568 | 569 | 570 | Left to Right 571 | 572 | 573 | 574 | 575 | 576 | 577 | Right to Left 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication/IconView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IconView.swift 3 | // SwiftStatusBarApplication 4 | // 5 | // Created by Tommy Leung on 6/7/14. 6 | // Copyright (c) 2014 Tommy Leung. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Cocoa 11 | 12 | class IconView : NSView 13 | { 14 | private(set) var image: NSImage 15 | private let item: NSStatusItem 16 | 17 | var onMouseDown: () -> () 18 | 19 | var isSelected: Bool 20 | { 21 | didSet 22 | { 23 | //redraw if isSelected changes for bg highlight 24 | if (isSelected != oldValue) 25 | { 26 | self.needsDisplay = true 27 | } 28 | } 29 | } 30 | 31 | init(imageName: String, item: NSStatusItem) 32 | { 33 | self.image = NSImage(named: imageName)! 34 | self.item = item 35 | self.isSelected = false 36 | self.onMouseDown = {} 37 | 38 | let thickness = NSStatusBar.systemStatusBar().thickness 39 | let rect = CGRectMake(0, 0, thickness, thickness) 40 | 41 | super.init(frame: rect) 42 | } 43 | 44 | required init?(coder: NSCoder) { 45 | fatalError("init(coder:) has not been implemented") 46 | } 47 | 48 | 49 | override func drawRect(dirtyRect: NSRect) 50 | { 51 | self.item.drawStatusBarBackgroundInRect(dirtyRect, withHighlight: self.isSelected) 52 | 53 | let size = self.image.size 54 | let rect = CGRectMake(2, 2, size.width, size.height) 55 | 56 | self.image.drawInRect(rect) 57 | } 58 | 59 | override func mouseDown(theEvent: NSEvent) 60 | { 61 | self.isSelected = !self.isSelected; 62 | self.onMouseDown(); 63 | } 64 | 65 | override func mouseUp(theEvent: NSEvent) 66 | { 67 | } 68 | } -------------------------------------------------------------------------------- /SwiftStatusBarApplication/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /SwiftStatusBarApplication/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.leungllc.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | ${MACOSX_DEPLOYMENT_TARGET} 27 | NSHumanReadableCopyright 28 | Copyright © 2014 Tommy Leung. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | LSUIElement 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /SwiftStatusBarApplication/Resources/icon.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertommy/swift-status-bar-app-osx/e99a9f4fbb2a2f35ffa3360e8f045b0505430e0f/SwiftStatusBarApplication/Resources/icon.pxm -------------------------------------------------------------------------------- /SwiftStatusBarApplication/Resources/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/supertommy/swift-status-bar-app-osx/e99a9f4fbb2a2f35ffa3360e8f045b0505430e0f/SwiftStatusBarApplication/Resources/icon@2x.png -------------------------------------------------------------------------------- /SwiftStatusBarApplicationTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.leungllc.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftStatusBarApplicationTests/SwiftStatusBarApplicationTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftStatusBarApplicationTests.swift 3 | // SwiftStatusBarApplicationTests 4 | // 5 | // Created by Tommy Leung on 6/7/14. 6 | // Copyright (c) 2014 Tommy Leung. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SwiftStatusBarApplicationTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------