├── .gitignore ├── LICENSE ├── MultiTabbed.xcodeproj └── project.pbxproj ├── MultiTabbed ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Info.plist ├── MultiTabbed.entitlements ├── NotificationToken.swift ├── TabService.swift ├── ViewController.swift ├── WindowController.storyboard └── WindowController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Based on by https://www.gitignore.io/api/swift 2 | 3 | ## Various settings 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata/ 13 | 14 | ## Other 15 | *.moved-aside 16 | *.xccheckout 17 | *.xcscmblueprint 18 | 19 | ## Obj-C/Swift specific 20 | *.hmap 21 | *.ipa 22 | *.dSYM.zip 23 | *.dSYM 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Christian Tietze 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. 22 | -------------------------------------------------------------------------------- /MultiTabbed.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 50438AF322DF1BAF002C9F44 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438AF222DF1BAF002C9F44 /* AppDelegate.swift */; }; 11 | 50438AF522DF1BAF002C9F44 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438AF422DF1BAF002C9F44 /* ViewController.swift */; }; 12 | 50438AF722DF1BB0002C9F44 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50438AF622DF1BB0002C9F44 /* Assets.xcassets */; }; 13 | 50438AFA22DF1BB0002C9F44 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50438AF822DF1BB0002C9F44 /* Main.storyboard */; }; 14 | 50438B0322DF1BBC002C9F44 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50438B0222DF1BBC002C9F44 /* WindowController.swift */; }; 15 | 50F8575D22E2FDBD00BC0BAB /* TabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8575C22E2FDBD00BC0BAB /* TabService.swift */; }; 16 | 50F8575F22E2FEC600BC0BAB /* NotificationToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F8575E22E2FEC600BC0BAB /* NotificationToken.swift */; }; 17 | 50F8576122E3047000BC0BAB /* WindowController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50F8576022E3047000BC0BAB /* WindowController.storyboard */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | 50438AEF22DF1BAF002C9F44 /* MultiTabbed.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MultiTabbed.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | 50438AF222DF1BAF002C9F44 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 23 | 50438AF422DF1BAF002C9F44 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | 50438AF622DF1BB0002C9F44 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 50438AF922DF1BB0002C9F44 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 50438AFB22DF1BB0002C9F44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 50438AFC22DF1BB0002C9F44 /* MultiTabbed.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MultiTabbed.entitlements; sourceTree = ""; }; 28 | 50438B0222DF1BBC002C9F44 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = ""; }; 29 | 50F8575C22E2FDBD00BC0BAB /* TabService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabService.swift; sourceTree = ""; }; 30 | 50F8575E22E2FEC600BC0BAB /* NotificationToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationToken.swift; sourceTree = ""; }; 31 | 50F8576022E3047000BC0BAB /* WindowController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = WindowController.storyboard; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 50438AEC22DF1BAF002C9F44 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 50438AE622DF1BAF002C9F44 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 50438AF122DF1BAF002C9F44 /* MultiTabbed */, 49 | 50438AF022DF1BAF002C9F44 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 50438AF022DF1BAF002C9F44 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 50438AEF22DF1BAF002C9F44 /* MultiTabbed.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 50438AF122DF1BAF002C9F44 /* MultiTabbed */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 50438AF222DF1BAF002C9F44 /* AppDelegate.swift */, 65 | 50438AF422DF1BAF002C9F44 /* ViewController.swift */, 66 | 50F8575C22E2FDBD00BC0BAB /* TabService.swift */, 67 | 50438B0222DF1BBC002C9F44 /* WindowController.swift */, 68 | 50F8576022E3047000BC0BAB /* WindowController.storyboard */, 69 | 50F8575E22E2FEC600BC0BAB /* NotificationToken.swift */, 70 | 50438AF622DF1BB0002C9F44 /* Assets.xcassets */, 71 | 50438AF822DF1BB0002C9F44 /* Main.storyboard */, 72 | 50438AFB22DF1BB0002C9F44 /* Info.plist */, 73 | 50438AFC22DF1BB0002C9F44 /* MultiTabbed.entitlements */, 74 | ); 75 | path = MultiTabbed; 76 | sourceTree = ""; 77 | }; 78 | /* End PBXGroup section */ 79 | 80 | /* Begin PBXNativeTarget section */ 81 | 50438AEE22DF1BAF002C9F44 /* MultiTabbed */ = { 82 | isa = PBXNativeTarget; 83 | buildConfigurationList = 50438AFF22DF1BB0002C9F44 /* Build configuration list for PBXNativeTarget "MultiTabbed" */; 84 | buildPhases = ( 85 | 50438AEB22DF1BAF002C9F44 /* Sources */, 86 | 50438AEC22DF1BAF002C9F44 /* Frameworks */, 87 | 50438AED22DF1BAF002C9F44 /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = MultiTabbed; 94 | productName = MultiTabbed; 95 | productReference = 50438AEF22DF1BAF002C9F44 /* MultiTabbed.app */; 96 | productType = "com.apple.product-type.application"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | 50438AE722DF1BAF002C9F44 /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | LastSwiftUpdateCheck = 1020; 105 | LastUpgradeCheck = 1240; 106 | ORGANIZATIONNAME = "Christian Tietze"; 107 | TargetAttributes = { 108 | 50438AEE22DF1BAF002C9F44 = { 109 | CreatedOnToolsVersion = 10.2; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = 50438AEA22DF1BAF002C9F44 /* Build configuration list for PBXProject "MultiTabbed" */; 114 | compatibilityVersion = "Xcode 9.3"; 115 | developmentRegion = en; 116 | hasScannedForEncodings = 0; 117 | knownRegions = ( 118 | en, 119 | Base, 120 | ); 121 | mainGroup = 50438AE622DF1BAF002C9F44; 122 | productRefGroup = 50438AF022DF1BAF002C9F44 /* Products */; 123 | projectDirPath = ""; 124 | projectRoot = ""; 125 | targets = ( 126 | 50438AEE22DF1BAF002C9F44 /* MultiTabbed */, 127 | ); 128 | }; 129 | /* End PBXProject section */ 130 | 131 | /* Begin PBXResourcesBuildPhase section */ 132 | 50438AED22DF1BAF002C9F44 /* Resources */ = { 133 | isa = PBXResourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | 50438AF722DF1BB0002C9F44 /* Assets.xcassets in Resources */, 137 | 50438AFA22DF1BB0002C9F44 /* Main.storyboard in Resources */, 138 | 50F8576122E3047000BC0BAB /* WindowController.storyboard in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | 50438AEB22DF1BAF002C9F44 /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | 50438AF522DF1BAF002C9F44 /* ViewController.swift in Sources */, 150 | 50F8575F22E2FEC600BC0BAB /* NotificationToken.swift in Sources */, 151 | 50438B0322DF1BBC002C9F44 /* WindowController.swift in Sources */, 152 | 50438AF322DF1BAF002C9F44 /* AppDelegate.swift in Sources */, 153 | 50F8575D22E2FDBD00BC0BAB /* TabService.swift in Sources */, 154 | ); 155 | runOnlyForDeploymentPostprocessing = 0; 156 | }; 157 | /* End PBXSourcesBuildPhase section */ 158 | 159 | /* Begin PBXVariantGroup section */ 160 | 50438AF822DF1BB0002C9F44 /* Main.storyboard */ = { 161 | isa = PBXVariantGroup; 162 | children = ( 163 | 50438AF922DF1BB0002C9F44 /* Base */, 164 | ); 165 | name = Main.storyboard; 166 | sourceTree = ""; 167 | }; 168 | /* End PBXVariantGroup section */ 169 | 170 | /* Begin XCBuildConfiguration section */ 171 | 50438AFD22DF1BB0002C9F44 /* Debug */ = { 172 | isa = XCBuildConfiguration; 173 | buildSettings = { 174 | ALWAYS_SEARCH_USER_PATHS = NO; 175 | CLANG_ANALYZER_NONNULL = YES; 176 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 178 | CLANG_CXX_LIBRARY = "libc++"; 179 | CLANG_ENABLE_MODULES = YES; 180 | CLANG_ENABLE_OBJC_ARC = YES; 181 | CLANG_ENABLE_OBJC_WEAK = YES; 182 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 183 | CLANG_WARN_BOOL_CONVERSION = YES; 184 | CLANG_WARN_COMMA = YES; 185 | CLANG_WARN_CONSTANT_CONVERSION = YES; 186 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 187 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 188 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 189 | CLANG_WARN_EMPTY_BODY = YES; 190 | CLANG_WARN_ENUM_CONVERSION = YES; 191 | CLANG_WARN_INFINITE_RECURSION = YES; 192 | CLANG_WARN_INT_CONVERSION = YES; 193 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 194 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 195 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 196 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 197 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 198 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 199 | CLANG_WARN_STRICT_PROTOTYPES = YES; 200 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 201 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 202 | CLANG_WARN_UNREACHABLE_CODE = YES; 203 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 204 | CODE_SIGN_IDENTITY = "-"; 205 | COPY_PHASE_STRIP = NO; 206 | DEBUG_INFORMATION_FORMAT = dwarf; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | ENABLE_TESTABILITY = YES; 209 | GCC_C_LANGUAGE_STANDARD = gnu11; 210 | GCC_DYNAMIC_NO_PIC = NO; 211 | GCC_NO_COMMON_BLOCKS = YES; 212 | GCC_OPTIMIZATION_LEVEL = 0; 213 | GCC_PREPROCESSOR_DEFINITIONS = ( 214 | "DEBUG=1", 215 | "$(inherited)", 216 | ); 217 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 218 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 219 | GCC_WARN_UNDECLARED_SELECTOR = YES; 220 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 221 | GCC_WARN_UNUSED_FUNCTION = YES; 222 | GCC_WARN_UNUSED_VARIABLE = YES; 223 | MACOSX_DEPLOYMENT_TARGET = 10.14; 224 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 225 | MTL_FAST_MATH = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = macosx; 228 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | }; 231 | name = Debug; 232 | }; 233 | 50438AFE22DF1BB0002C9F44 /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_ENABLE_OBJC_WEAK = YES; 244 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_COMMA = YES; 247 | CLANG_WARN_CONSTANT_CONVERSION = YES; 248 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 257 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 258 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 259 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 260 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 261 | CLANG_WARN_STRICT_PROTOTYPES = YES; 262 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 263 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 264 | CLANG_WARN_UNREACHABLE_CODE = YES; 265 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 266 | CODE_SIGN_IDENTITY = "-"; 267 | COPY_PHASE_STRIP = NO; 268 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 269 | ENABLE_NS_ASSERTIONS = NO; 270 | ENABLE_STRICT_OBJC_MSGSEND = YES; 271 | GCC_C_LANGUAGE_STANDARD = gnu11; 272 | GCC_NO_COMMON_BLOCKS = YES; 273 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 274 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 275 | GCC_WARN_UNDECLARED_SELECTOR = YES; 276 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 277 | GCC_WARN_UNUSED_FUNCTION = YES; 278 | GCC_WARN_UNUSED_VARIABLE = YES; 279 | MACOSX_DEPLOYMENT_TARGET = 10.14; 280 | MTL_ENABLE_DEBUG_INFO = NO; 281 | MTL_FAST_MATH = YES; 282 | SDKROOT = macosx; 283 | SWIFT_COMPILATION_MODE = wholemodule; 284 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 285 | }; 286 | name = Release; 287 | }; 288 | 50438B0022DF1BB0002C9F44 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 292 | CODE_SIGN_ENTITLEMENTS = MultiTabbed/MultiTabbed.entitlements; 293 | CODE_SIGN_IDENTITY = "-"; 294 | CODE_SIGN_STYLE = Manual; 295 | COMBINE_HIDPI_IMAGES = YES; 296 | DEVELOPMENT_TEAM = ""; 297 | INFOPLIST_FILE = MultiTabbed/Info.plist; 298 | LD_RUNPATH_SEARCH_PATHS = ( 299 | "$(inherited)", 300 | "@executable_path/../Frameworks", 301 | ); 302 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.MultiTabbed; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | PROVISIONING_PROFILE_SPECIFIER = ""; 305 | SWIFT_VERSION = 5.0; 306 | }; 307 | name = Debug; 308 | }; 309 | 50438B0122DF1BB0002C9F44 /* Release */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 313 | CODE_SIGN_ENTITLEMENTS = MultiTabbed/MultiTabbed.entitlements; 314 | CODE_SIGN_IDENTITY = "-"; 315 | CODE_SIGN_STYLE = Manual; 316 | COMBINE_HIDPI_IMAGES = YES; 317 | DEVELOPMENT_TEAM = ""; 318 | INFOPLIST_FILE = MultiTabbed/Info.plist; 319 | LD_RUNPATH_SEARCH_PATHS = ( 320 | "$(inherited)", 321 | "@executable_path/../Frameworks", 322 | ); 323 | PRODUCT_BUNDLE_IDENTIFIER = de.christiantietze.MultiTabbed; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | PROVISIONING_PROFILE_SPECIFIER = ""; 326 | SWIFT_VERSION = 5.0; 327 | }; 328 | name = Release; 329 | }; 330 | /* End XCBuildConfiguration section */ 331 | 332 | /* Begin XCConfigurationList section */ 333 | 50438AEA22DF1BAF002C9F44 /* Build configuration list for PBXProject "MultiTabbed" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | 50438AFD22DF1BB0002C9F44 /* Debug */, 337 | 50438AFE22DF1BB0002C9F44 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | 50438AFF22DF1BB0002C9F44 /* Build configuration list for PBXNativeTarget "MultiTabbed" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | 50438B0022DF1BB0002C9F44 /* Debug */, 346 | 50438B0122DF1BB0002C9F44 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | /* End XCConfigurationList section */ 352 | }; 353 | rootObject = 50438AE722DF1BAF002C9F44 /* Project object */; 354 | } 355 | -------------------------------------------------------------------------------- /MultiTabbed/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. Distributed under the MIT License. 2 | 3 | import Cocoa 4 | 5 | @NSApplicationMain 6 | class AppDelegate: NSObject, NSApplicationDelegate { 7 | 8 | var tabService: TabService! 9 | 10 | func applicationDidFinishLaunching(_ aNotification: Notification) { 11 | replaceTabServiceWithInitialWindow() 12 | } 13 | 14 | /// Fallback for the menu bar action when all windows are closed. 15 | @IBAction func newWindowForTab(_ sender: Any?) { 16 | 17 | if let existingWindow = tabService.mainWindow { 18 | tabService.createTab(newWindowController: WindowController.create(), 19 | inWindow: existingWindow, 20 | ordered: .above) 21 | } else { 22 | replaceTabServiceWithInitialWindow() 23 | } 24 | } 25 | 26 | private func replaceTabServiceWithInitialWindow() { 27 | let windowController = WindowController.create() 28 | windowController.showWindow(self) 29 | tabService = TabService(initialWindowController: windowController) 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /MultiTabbed/Assets.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 | } -------------------------------------------------------------------------------- /MultiTabbed/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /MultiTabbed/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 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 | Default 530 | 531 | 532 | 533 | 534 | 535 | 536 | Left to Right 537 | 538 | 539 | 540 | 541 | 542 | 543 | Right to Left 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | Default 555 | 556 | 557 | 558 | 559 | 560 | 561 | Left to Right 562 | 563 | 564 | 565 | 566 | 567 | 568 | Right to Left 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 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 | 687 | 688 | 689 | 690 | -------------------------------------------------------------------------------- /MultiTabbed/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2019 Christian Tietze. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /MultiTabbed/MultiTabbed.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MultiTabbed/NotificationToken.swift: -------------------------------------------------------------------------------- 1 | // Code via 2 | // Copyright (c) 2018, Ole Begemann. All rights reserved. 3 | 4 | import Foundation 5 | 6 | /// Wraps the observer token received from 7 | /// NotificationCenter.addObserver(forName:object:queue:using:) 8 | /// and unregisters it in deinit. 9 | final class NotificationToken: NSObject { 10 | let notificationCenter: NotificationCenter 11 | let token: Any 12 | 13 | init(notificationCenter: NotificationCenter = .default, token: Any) { 14 | self.notificationCenter = notificationCenter 15 | self.token = token 16 | } 17 | 18 | deinit { 19 | notificationCenter.removeObserver(token) 20 | } 21 | } 22 | 23 | extension NotificationCenter { 24 | /// Convenience wrapper for addObserver(forName:object:queue:using:) 25 | /// that returns our custom NotificationToken. 26 | func observe(name: NSNotification.Name?, 27 | object obj: Any?, 28 | queue: OperationQueue? = nil, 29 | using block: @escaping (Notification) -> ()) 30 | -> NotificationToken 31 | { 32 | let token = addObserver(forName: name, object: obj, queue: queue, using: block) 33 | return NotificationToken(notificationCenter: self, token: token) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /MultiTabbed/TabService.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. Distributed under the MIT License. 2 | 3 | import Cocoa 4 | 5 | class TabService: TabDelegate { 6 | 7 | struct ManagedWindow { 8 | /// Keep the controller around to store a strong reference to it 9 | let windowController: NSWindowController 10 | 11 | /// Keep the window around to identify instances of this type 12 | let window: NSWindow 13 | 14 | /// React to window closing, auto-unsubscribing on dealloc 15 | let closingSubscription: NotificationToken 16 | } 17 | 18 | fileprivate(set) var managedWindows: [ManagedWindow] = [] 19 | 20 | /// Returns the main window of the managed window stack. 21 | /// Falls back the first element if no window is main. Note that this would 22 | /// likely be an internal inconsistency we gracefully handle here. 23 | var mainWindow: NSWindow? { 24 | let mainManagedWindow = managedWindows 25 | .first { $0.window.isMainWindow } 26 | 27 | // In case we run into the inconsistency, let it crash in debug mode so we 28 | // can fix our window management setup to prevent this from happening. 29 | assert(mainManagedWindow != nil || managedWindows.isEmpty) 30 | 31 | return (mainManagedWindow ?? managedWindows.first) 32 | .map { $0.window } 33 | } 34 | 35 | init(initialWindowController: WindowController) { 36 | precondition(addManagedWindow(windowController: initialWindowController) != nil) 37 | } 38 | 39 | func createTab(newWindowController: WindowController, 40 | inWindow window: NSWindow, 41 | ordered orderingMode: NSWindow.OrderingMode) { 42 | 43 | guard let newWindow = addManagedWindow(windowController: newWindowController)?.window else { preconditionFailure() } 44 | 45 | window.addTabbedWindow(newWindow, ordered: orderingMode) 46 | newWindow.makeKeyAndOrderFront(nil) 47 | } 48 | 49 | private func addManagedWindow(windowController: WindowController) -> ManagedWindow? { 50 | 51 | guard let window = windowController.window else { return nil } 52 | 53 | let subscription = NotificationCenter.default.observe(name: NSWindow.willCloseNotification, object: window) { [unowned self] notification in 54 | guard let window = notification.object as? NSWindow else { return } 55 | self.removeManagedWindow(forWindow: window) 56 | } 57 | let management = ManagedWindow( 58 | windowController: windowController, 59 | window: window, 60 | closingSubscription: subscription) 61 | managedWindows.append(management) 62 | 63 | windowController.tabDelegate = self 64 | 65 | return management 66 | } 67 | 68 | private func removeManagedWindow(forWindow window: NSWindow) { 69 | managedWindows.removeAll(where: { $0.window === window }) 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /MultiTabbed/ViewController.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. Distributed under the MIT License. 2 | 3 | import Cocoa 4 | 5 | class ViewController: NSViewController { 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | // Do any additional setup after loading the view. 11 | } 12 | 13 | override var representedObject: Any? { 14 | didSet { 15 | // Update the view, if already loaded. 16 | } 17 | } 18 | 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /MultiTabbed/WindowController.storyboard: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /MultiTabbed/WindowController.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Christian Tietze. All rights reserved. Distributed under the MIT License. 2 | 3 | import Cocoa 4 | 5 | var count = 0 6 | 7 | protocol TabDelegate: class { 8 | func createTab(newWindowController: WindowController, 9 | inWindow window: NSWindow, 10 | ordered orderingMode: NSWindow.OrderingMode) 11 | } 12 | 13 | class WindowController: NSWindowController { 14 | 15 | static func create() -> WindowController { 16 | let windowStoryboard = NSStoryboard(name: "WindowController", bundle: nil) 17 | return windowStoryboard.instantiateInitialController() as! WindowController 18 | } 19 | 20 | override func windowDidLoad() { 21 | super.windowDidLoad() 22 | count += 1 23 | self.window!.title = "Window #\(count)" 24 | } 25 | 26 | weak var tabDelegate: TabDelegate? 27 | 28 | override func newWindowForTab(_ sender: Any?) { 29 | 30 | guard let window = self.window else { preconditionFailure("Expected window to be loaded") } 31 | guard let tabDelegate = self.tabDelegate else { return } 32 | 33 | tabDelegate.createTab(newWindowController: WindowController.create(), 34 | inWindow: window, 35 | ordered: .above) 36 | 37 | inspectWindowHierarchy() 38 | } 39 | 40 | func inspectWindowHierarchy() { 41 | let rootWindow = self.window! 42 | print("Root window", rootWindow, rootWindow.title, "has tabs:") 43 | rootWindow.tabbedWindows?.forEach { window in 44 | print("- ", window, window.title, "isKey =", window.isKeyWindow, ", isMain =", window.isMainWindow, " at ", window.frame) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Programmatic NSWindow Tabbing 2 | 3 | ![Swift 5.3](https://img.shields.io/badge/Swift-5.3-blue.svg?style=flat) 4 | ![License](https://img.shields.io/github/license/DivineDominion/NSWindow-Tabbing.svg?style=flat) 5 | ![Platform](https://img.shields.io/badge/platform-macOS-lightgrey.svg?style=flat) 6 | 7 | Demonstrating how to implement programmatic creation of tabs in `NSWindow`s without the use of `NSDocument`. 8 | 9 | - Checkout the `shared-window-controller` tag to see how to re-use a single `NSWindowController` for all tabs as [per my experimental blog post](https://christiantietze.de/posts/2019/07/nswindow-tabbing-single-nswindowcontroller/). Don't use this in production, though. 10 | - Checkout the `multiple-window-controllers` tag or the current `master` branch to see how to manage `NSWindowController`s for your tabs. I [wrote about this production-ready approach, too](https://christiantietze.de/posts/2019/07/nswindow-tabbing-multiple-nswindowcontroller/). 11 | 12 | The underlying difficulty people on StackOverflow etc. are experiencing is that creating your `NSWindowController` from a storyboard will initialize the window contents, but you need to keep the window controller itself alive to respond to main menu actions. Otherwise, the "+" (add tab) button will appear broken for all but the initial tab. 13 | 14 | ## License 15 | 16 | Copyright (c) 2019--2021 Christian Tietze. Distributed under the MIT License. 17 | --------------------------------------------------------------------------------