├── Swift Custom Control
├── Swift Custom Control.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
└── Swift Custom Control
│ ├── ViewController.swift
│ ├── AppDelegate.swift
│ ├── Info.plist
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
│ ├── wwUtils.swift
│ ├── ClickCounter.swift
│ ├── ClickCounter.xib
│ └── Base.lproj
│ └── Main.storyboard
├── LICENSE
├── .gitignore
└── README.md
/Swift Custom Control/Swift Custom Control.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Swift Custom Control
4 | //
5 | // Created by William Waggoner on 2/21/17.
6 | // Copyright © 2017 William C Waggoner. Available under the MIT License.
7 | //
8 |
9 | import Cocoa
10 |
11 | class ViewController: NSViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | // Do any additional setup after loading the view.
17 | }
18 |
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Swift Custom Control
4 | //
5 | // Created by William Waggoner on 2/21/17.
6 | // Copyright © 2017 William C Waggoner. Available under the MIT License.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 | func applicationDidFinishLaunching(_ aNotification: Notification) {
15 | // Insert code here to initialize your application
16 | }
17 |
18 | func applicationWillTerminate(_ aNotification: Notification) {
19 | // Insert code here to tear down your application
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bill Waggoner
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 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
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 © 2017 William C Waggoner. Available under the MIT License.
27 | NSMainStoryboardFile
28 | Main
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/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 | }
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/wwUtils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // wwUtils.swift
3 | // Swift Custom Control
4 | //
5 | // Created by William Waggoner on 2/21/17.
6 | // Copyright © 2017 William C Waggoner. Available under the MIT License.
7 | //
8 | // Just a couple of useful utility functions
9 | //
10 |
11 | import Foundation
12 |
13 | /**
14 | Get the last path component in a file or URL string
15 |
16 | - parameters:
17 | * path: The string representing a file path or URL
18 |
19 | - returns: The last path component or the original input path
20 | */
21 | fileprivate func lastPath(_ path: String) -> String {
22 | path.components(separatedBy: "/").last ?? ""
23 | }
24 |
25 | /**
26 | Log message prepending the requesting file and function names
27 |
28 | - parameters:
29 | * myMsg: The string to log
30 | * myFile: The originating file name
31 | * myFunc: The originating function name
32 | * myLine: The current line number within the source file
33 |
34 | - note: *myFile* and *myFunc* are usually not specified and are allowed to default
35 |
36 | */
37 | public func wwLog(_ myMsg: String = "Entry",
38 | myFile: String = #file,
39 | myFunc: String = #function,
40 | myLine: UInt = #line) {
41 | NSLog("%@(%u):%@ %@",
42 | lastPath(myFile),
43 | myLine,
44 | myFunc,
45 | myMsg)
46 | }
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | ## Playgrounds
31 | timeline.xctimeline
32 | playground.xcworkspace
33 |
34 | # Swift Package Manager
35 | #
36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37 | # Packages/
38 | .build/
39 |
40 | # CocoaPods
41 | #
42 | # We recommend against adding the Pods directory to your .gitignore. However
43 | # you should judge for yourself, the pros and cons are mentioned at:
44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45 | #
46 | # Pods/
47 |
48 | # Carthage
49 | #
50 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
51 | # Carthage/Checkouts
52 |
53 | Carthage/Build
54 |
55 | # fastlane
56 | #
57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58 | # screenshots whenever they are needed.
59 | # For more information about the recommended setup visit:
60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61 |
62 | fastlane/report.xml
63 | fastlane/Preview.html
64 | fastlane/screenshots
65 | fastlane/test_output
66 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/ClickCounter.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ClickCounter.swift
3 | // Swift Custom Control
4 | //
5 | // Created by William Waggoner on 2/21/17.
6 | // Copyright © 2017 William C Waggoner. Available under the MIT License.
7 | //
8 |
9 | import Cocoa
10 |
11 | /// Test class to demonstrate an embedded custom designable view
12 | @IBDesignable
13 | class ClickCounter: NSView {
14 |
15 | /// The highest level view in the XIB. This is actually not used within the app
16 | @IBOutlet var topView: NSView!
17 |
18 | /// The topmost subview in the XIB. It's easier but not necessary to have only one
19 | @IBOutlet weak var stackView: NSStackView!
20 |
21 | /// A reference to an interior view we want to affect
22 | @IBOutlet weak var counterView: NSTextField!
23 |
24 | /// Our data
25 | var clickCounter = 0 {
26 | didSet {
27 | counterView.stringValue = String(clickCounter)
28 | }
29 | }
30 |
31 | /// An action
32 | ///
33 | /// - parameter sender: The NSButton that was clicked
34 | @IBAction func pushed(_ sender: NSButton) {
35 | clickCounter += 1
36 | }
37 |
38 | /// Called when drawing the topmost view (us)
39 | /// We set the background to brown for visibility
40 | ///
41 | /// - parameter dirtyRect: The NSRect area that needs to be redrawn
42 | /// We fill it with brown
43 | override func draw(_ dirtyRect: NSRect) {
44 | NSColor.brown.setFill()
45 | dirtyRect.fill()
46 | super.draw(dirtyRect)
47 | }
48 |
49 | /// The initializer
50 | ///
51 | /// The setup work goes here
52 | required public init?(coder: NSCoder) {
53 |
54 | /// Call the superview's init. In this case it doesn't do much for us
55 | super.init(coder: coder)
56 |
57 | /// Extract our name string from the multi-level class name. We need it to reference the NIB name
58 | /// This is just Best Practice. The NIB may be named anything you like but makes sense to be named
59 | /// the same as the class that drives it.
60 | guard let myName = type(of: self)
61 | .className()
62 | .components(separatedBy: ".")
63 | .last else {
64 | return nil
65 | }
66 |
67 | /// Log the name for reference
68 | wwLog("I am \(myName)")
69 |
70 | /// Get our NIB. This should never fail but it always pays to be careful
71 | /// In this case it gets the main Bundle but if this code is in a Framework then it might be another one,
72 | /// that's why we use that form of Bundle call
73 | if let nib = NSNib(nibNamed: myName,
74 | bundle: Bundle(for: type(of: self))) {
75 |
76 | /// You must instantiate a new view from the NIB attached to you as the owner,
77 | /// this will replace the one originally built at app start-up
78 | nib.instantiate(withOwner: self, topLevelObjects: nil)
79 |
80 | /// Now create a new array of constraints by copying the old ones.
81 | /// We replace ourself as either the first or second item as appropriate in place of topView.
82 | /// We grab these now to apply after we add our sub-views
83 | wwLog("Recreating \(topView.constraints.count) constraints")
84 |
85 | var newConstraints: [NSLayoutConstraint] = []
86 |
87 | for oldConstraint in topView.constraints {
88 | let firstItem = oldConstraint.firstItem === topView ? self : oldConstraint.firstItem
89 | let secondItem = oldConstraint.secondItem === topView ? self : oldConstraint.secondItem
90 |
91 | newConstraints.append(
92 | NSLayoutConstraint(item: firstItem as Any,
93 | attribute: oldConstraint.firstAttribute,
94 | relatedBy: oldConstraint.relation,
95 | toItem: secondItem,
96 | attribute: oldConstraint.secondAttribute,
97 | multiplier: oldConstraint.multiplier,
98 | constant: oldConstraint.constant)
99 | )
100 | }
101 |
102 | /// Steal subviews from the original NSView which will not be used.
103 | /// Adding it to the new view removes it from the older one
104 | for newView in topView.subviews {
105 | self.addSubview(newView)
106 | }
107 |
108 | /// Add the constraints
109 | /// Note that we add them to ourself. They must be added at or above the views mentioned in the constraints
110 | self.addConstraints(newConstraints)
111 |
112 |
113 | } else {
114 | /// Oops
115 | wwLog("init couldn't load nib")
116 | }
117 | }
118 |
119 | }
120 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/ClickCounter.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 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SwiftCustomControl
2 |
3 | A quick tutorial on creating and using an AppKit custom control
4 |
5 | This may apply to UIKit, at least in part, but I make no claim that it does.
6 |
7 | ## Introduction
8 |
9 | This all started with a Mac App I was playing with.
10 | It had a real purpose but I was also using it to learn more about Views and controls and stuff like that.
11 | I wanted to dig a little deeper into multiple windows and views, horizontal and vertical stacks, scroll views and tables,
12 | stuff like that.
13 |
14 | At some point in the development I had five TabView panes that were similar but showed different parts of the document
15 | I was working with.
16 | Each had a selected set of settings at the top, arranged in a loose grid.
17 | For each setting I wanted a small image, an icon really, representing the "state" of that setting, with three or four
18 | possible states.
19 | The value of the setting, a string, would also be shown.
20 | So what I wanted is very similar to an Image and Text Table Cell View.
21 | But I found that I couldn't use that outside of a table ... bummer ...
22 |
23 | So I thought that would be a great opportunity to build my own custom control to have and reuse.
24 | I figured I would need thirty or so of these so reusability would be a "Good Thing"™
25 |
26 | It turns out it's easy to do but finding out *HOW* is the hard part!
27 |
28 | #### Disclaimer
29 |
30 | While putting this project together I have made many assumptions based on observation of what works and what didn't.
31 | Some or all of these assumptions may very well be wrong.
32 | If you know that something I say below is wrong I would appreciate hearing about it.
33 | There is no warranty expressed or implied that anything I say is truth,
34 | some may be simply an Alternate Reality ...
35 |
36 | ### UIKit vs AppKit
37 |
38 | When I searched for "custom control" (several different forms of search and many different places) I found
39 | lots of references to UIKit.
40 | Most were much more advanced than what I was looking for and those that I did look at didn't seem to apply to AppKit.
41 | As I was building a Mac app I had to use AppKit.
42 |
43 | I put some help queries up in a couple of places but really didn't get much response.
44 | Did it mean that no one was doing it or that it couldn't be done or, as I suspect, I just didn't catch
45 | the interest of someone who would spend the time to lay it out for me.
46 |
47 | As it turns out it's pretty easy but getting there was hard.
48 | It was like a key in a lock, unless all the bumps are in the right place and of the right size the lock doesn't open.
49 |
50 | I ended up submitting a Technical Support Incident to Apple for help.
51 | I did get some great help.
52 | The person assigned to my ticket took my sample code and tweaked it to make it work
53 | then took one of the Objective C examples and rewrote it in Swift and sent it to me.
54 | Between the two samples I had I was able to build a new test in Swift and this
55 | project is the result.
56 |
57 | I hope this gets to someone that finds it useful.
58 |
59 | ## Framework or No Framework, That Is The Question
60 |
61 | A couple of the threads that I found during my search seemed to indicate that your custom control had
62 | to be built within a Framework.
63 | And my first attempt, [well, my second considering how messed up my really first attempt ended up,]
64 | was written in a Framework.
65 | Both examples that I got back from Apple were built within Frameworks too.
66 | But I didn't see anything obvious that appeared to require a Framework so I tried one, this one,
67 | without the Framework.
68 | Seems to work OK for me.
69 |
70 | So, at least at the XCode 8 level, a Framework is not required for this to work.
71 |
72 | There may be reasons to put your custom controls into a Framework but that should be a structure decision
73 | made because of other reasons than that it is required to make it work.
74 | This may very well be a change from earlier versions of XCode, I don't know, but as you can see
75 | here, a Framework is not required.
76 |
77 | ## Discussion
78 |
79 | A quick note on my coding style here.
80 | I have included the qualifier `self` in several places where it is not necessary.
81 | That is on purpose.
82 | What I am trying to emphasize is that our custom class is the main view now of our custom control;
83 | that NSView that you saw in Interface Builder is no longer in play, we are in charge now.
84 |
85 | What follows is a stream of conciousness dump of what goes into creating a custom control.
86 | There's not a lot here because that turns out to be not much to it
87 | but I can tell you that if you miss a bit or get it just a little wrong you won't have
88 | anything and you won't know why.
89 |
90 | 1. Create an XIB
91 |
92 | 1. Create a subclass of NSView.
93 | They probably should have the same base name but it's not strictly required.
94 | In this example they do and we take advantage of that fact.
95 | Assuming you want to see the view in Interface Builder be sure to add `@IBDesignable` to the class definition.
96 |
97 | 1. In the XIB set `File's Owner` to the class you just created.
98 |
99 | 1. The top-level view in the XIB must remain an `NSView`
100 |
101 | 1. In your XIB create how you want the control to look.
102 | This is "Normal" XIB stuff, nothing unusual.
103 | The size of the top-level view should be what size and shape it will be in your application.
104 | This is not strictly necessary but it will help make it visible within Interface Builder.
105 | More on this later.
106 |
107 | 1. Add any Actions and Outlets that you may need for you control to function.
108 | Be sure to include an Outlet connecting the top-level NSView to the File's Owner.
109 | It's labelled `topView` here.
110 |
111 | 1. Create the initializer `required override init?(coder: coder)` in your class.
112 | This is where the magic happens.
113 |
114 | 1. Within this initializer you can see the sample code.
115 | Here is what it is doing ...
116 |
117 | * Create a `NSNib` from the name of the class. Look in the Bundle that belongs to that class.
118 | Our class will "own" that `NSNib` instance.
119 | * `instantiate` that NIB. The important thing that happens here is that all the IBOutlet and IBAction references are
120 | established.
121 | I think `awakeFromNIB` is also called at that time.
122 | It's interesting to note that this will be the *second* time `awakeFromNIB` is called, the first time no bindings were established.
123 | I originally thought that was a bug but I believe it is because that at that time there was no NIB or, perhaps, an empty NIB in control.
124 | * Recreate all of the existing contraints by copying them from the old view replacing the old view where it appears with our new view.
125 | We'll use them in a bit.
126 | * Add each of the subviews that appear under the top-level `NSView` in the XIB to ourself as subviews.
127 | **This is a bit of magic.**
128 | When you do this these views (in our sample there is only one but there may be multiple if that's what you need) are detached
129 | from the NSView in the XIB and reattached to the new custom view.
130 | They are now within our view hierarchy.
131 | They have also lost any constraints that related to the old top view.
132 | We fix that next.
133 | * Re-establish the constraints in the views.
134 | This took me a while to figure out why my view wasn't laid out correctly, they had lost all of their constraints so we have to put them back.
135 | * You're Done
136 |
137 | Your custom class should now appear in Interface Builder and in your app.
138 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 0F2467771E5E7DCC0041A695 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 0F8F1DEF1E5CA63D00DC0F5B /* LICENSE */; };
11 | 0F8F1DE01E5CA5E700DC0F5B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F1DDF1E5CA5E700DC0F5B /* AppDelegate.swift */; };
12 | 0F8F1DE21E5CA5E700DC0F5B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F1DE11E5CA5E700DC0F5B /* ViewController.swift */; };
13 | 0F8F1DE41E5CA5E700DC0F5B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0F8F1DE31E5CA5E700DC0F5B /* Assets.xcassets */; };
14 | 0F8F1DE71E5CA5E700DC0F5B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F8F1DE51E5CA5E700DC0F5B /* Main.storyboard */; };
15 | 0F8F1DF21E5CA75B00DC0F5B /* wwUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F1DF11E5CA75B00DC0F5B /* wwUtils.swift */; };
16 | 0F8F1DF41E5CA98B00DC0F5B /* ClickCounter.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0F8F1DF31E5CA98B00DC0F5B /* ClickCounter.xib */; };
17 | 0F8F1DF61E5CA9AA00DC0F5B /* ClickCounter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F8F1DF51E5CA9A900DC0F5B /* ClickCounter.swift */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXBuildRule section */
21 | 0F961F3D1E5E912C008F2C10 /* PBXBuildRule */ = {
22 | isa = PBXBuildRule;
23 | compilerSpec = com.apple.compilers.proxy.script;
24 | filePatterns = "*.md";
25 | fileType = pattern.proxy;
26 | inputFiles = (
27 | );
28 | isEditable = 1;
29 | outputFiles = (
30 | );
31 | script = "cp -a \"$INPUT_FILE_DIR/$INPUT_FILE_NAME\" \"$TARGET_BUILD_DIR/$CONTENTS_FOLDER_PATH\"";
32 | };
33 | /* End PBXBuildRule section */
34 |
35 | /* Begin PBXFileReference section */
36 | 0F8F1DDC1E5CA5E700DC0F5B /* Swift Custom Control.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Swift Custom Control.app"; sourceTree = BUILT_PRODUCTS_DIR; };
37 | 0F8F1DDF1E5CA5E700DC0F5B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
38 | 0F8F1DE11E5CA5E700DC0F5B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
39 | 0F8F1DE31E5CA5E700DC0F5B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
40 | 0F8F1DE61E5CA5E700DC0F5B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
41 | 0F8F1DE81E5CA5E700DC0F5B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
42 | 0F8F1DEF1E5CA63D00DC0F5B /* LICENSE */ = {isa = PBXFileReference; explicitFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; };
43 | 0F8F1DF01E5CA63D00DC0F5B /* README.md */ = {isa = PBXFileReference; explicitFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; };
44 | 0F8F1DF11E5CA75B00DC0F5B /* wwUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = wwUtils.swift; sourceTree = ""; };
45 | 0F8F1DF31E5CA98B00DC0F5B /* ClickCounter.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ClickCounter.xib; sourceTree = ""; };
46 | 0F8F1DF51E5CA9A900DC0F5B /* ClickCounter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClickCounter.swift; sourceTree = ""; };
47 | /* End PBXFileReference section */
48 |
49 | /* Begin PBXFrameworksBuildPhase section */
50 | 0F8F1DD91E5CA5E700DC0F5B /* Frameworks */ = {
51 | isa = PBXFrameworksBuildPhase;
52 | buildActionMask = 2147483647;
53 | files = (
54 | );
55 | runOnlyForDeploymentPostprocessing = 0;
56 | };
57 | /* End PBXFrameworksBuildPhase section */
58 |
59 | /* Begin PBXGroup section */
60 | 0F8F1DD31E5CA5E700DC0F5B = {
61 | isa = PBXGroup;
62 | children = (
63 | 0F8F1DEE1E5CA60B00DC0F5B /* Docs */,
64 | 0F8F1DDE1E5CA5E700DC0F5B /* Swift Custom Control */,
65 | 0F8F1DDD1E5CA5E700DC0F5B /* Products */,
66 | );
67 | sourceTree = "";
68 | };
69 | 0F8F1DDD1E5CA5E700DC0F5B /* Products */ = {
70 | isa = PBXGroup;
71 | children = (
72 | 0F8F1DDC1E5CA5E700DC0F5B /* Swift Custom Control.app */,
73 | );
74 | name = Products;
75 | sourceTree = "";
76 | };
77 | 0F8F1DDE1E5CA5E700DC0F5B /* Swift Custom Control */ = {
78 | isa = PBXGroup;
79 | children = (
80 | 0F8F1DDF1E5CA5E700DC0F5B /* AppDelegate.swift */,
81 | 0F8F1DE11E5CA5E700DC0F5B /* ViewController.swift */,
82 | 0F8F1DE31E5CA5E700DC0F5B /* Assets.xcassets */,
83 | 0F8F1DE51E5CA5E700DC0F5B /* Main.storyboard */,
84 | 0F8F1DE81E5CA5E700DC0F5B /* Info.plist */,
85 | 0F8F1DF11E5CA75B00DC0F5B /* wwUtils.swift */,
86 | 0F8F1DF31E5CA98B00DC0F5B /* ClickCounter.xib */,
87 | 0F8F1DF51E5CA9A900DC0F5B /* ClickCounter.swift */,
88 | );
89 | path = "Swift Custom Control";
90 | sourceTree = "";
91 | };
92 | 0F8F1DEE1E5CA60B00DC0F5B /* Docs */ = {
93 | isa = PBXGroup;
94 | children = (
95 | 0F8F1DEF1E5CA63D00DC0F5B /* LICENSE */,
96 | 0F8F1DF01E5CA63D00DC0F5B /* README.md */,
97 | );
98 | name = Docs;
99 | sourceTree = "";
100 | };
101 | /* End PBXGroup section */
102 |
103 | /* Begin PBXNativeTarget section */
104 | 0F8F1DDB1E5CA5E700DC0F5B /* Swift Custom Control */ = {
105 | isa = PBXNativeTarget;
106 | buildConfigurationList = 0F8F1DEB1E5CA5E700DC0F5B /* Build configuration list for PBXNativeTarget "Swift Custom Control" */;
107 | buildPhases = (
108 | 0F961F3A1E5E8E60008F2C10 /* Log Build Settings */,
109 | 0F8F1DD81E5CA5E700DC0F5B /* Sources */,
110 | 0F8F1DD91E5CA5E700DC0F5B /* Frameworks */,
111 | 0F8F1DDA1E5CA5E700DC0F5B /* Resources */,
112 | );
113 | buildRules = (
114 | 0F961F3D1E5E912C008F2C10 /* PBXBuildRule */,
115 | );
116 | dependencies = (
117 | );
118 | name = "Swift Custom Control";
119 | productName = "Swift Custom Control";
120 | productReference = 0F8F1DDC1E5CA5E700DC0F5B /* Swift Custom Control.app */;
121 | productType = "com.apple.product-type.application";
122 | };
123 | /* End PBXNativeTarget section */
124 |
125 | /* Begin PBXProject section */
126 | 0F8F1DD41E5CA5E700DC0F5B /* Project object */ = {
127 | isa = PBXProject;
128 | attributes = {
129 | LastSwiftUpdateCheck = 0820;
130 | LastUpgradeCheck = 1240;
131 | ORGANIZATIONNAME = "William C Waggoner";
132 | TargetAttributes = {
133 | 0F8F1DDB1E5CA5E700DC0F5B = {
134 | CreatedOnToolsVersion = 8.2.1;
135 | ProvisioningStyle = Automatic;
136 | };
137 | };
138 | };
139 | buildConfigurationList = 0F8F1DD71E5CA5E700DC0F5B /* Build configuration list for PBXProject "Swift Custom Control" */;
140 | compatibilityVersion = "Xcode 3.2";
141 | developmentRegion = en;
142 | hasScannedForEncodings = 0;
143 | knownRegions = (
144 | en,
145 | Base,
146 | );
147 | mainGroup = 0F8F1DD31E5CA5E700DC0F5B;
148 | productRefGroup = 0F8F1DDD1E5CA5E700DC0F5B /* Products */;
149 | projectDirPath = "";
150 | projectRoot = "";
151 | targets = (
152 | 0F8F1DDB1E5CA5E700DC0F5B /* Swift Custom Control */,
153 | );
154 | };
155 | /* End PBXProject section */
156 |
157 | /* Begin PBXResourcesBuildPhase section */
158 | 0F8F1DDA1E5CA5E700DC0F5B /* Resources */ = {
159 | isa = PBXResourcesBuildPhase;
160 | buildActionMask = 2147483647;
161 | files = (
162 | 0F8F1DF41E5CA98B00DC0F5B /* ClickCounter.xib in Resources */,
163 | 0F8F1DE41E5CA5E700DC0F5B /* Assets.xcassets in Resources */,
164 | 0F2467771E5E7DCC0041A695 /* LICENSE in Resources */,
165 | 0F8F1DE71E5CA5E700DC0F5B /* Main.storyboard in Resources */,
166 | );
167 | runOnlyForDeploymentPostprocessing = 0;
168 | };
169 | /* End PBXResourcesBuildPhase section */
170 |
171 | /* Begin PBXShellScriptBuildPhase section */
172 | 0F961F3A1E5E8E60008F2C10 /* Log Build Settings */ = {
173 | isa = PBXShellScriptBuildPhase;
174 | buildActionMask = 2147483647;
175 | files = (
176 | );
177 | inputPaths = (
178 | );
179 | name = "Log Build Settings";
180 | outputPaths = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | shellPath = /bin/bash;
184 | shellScript = export;
185 | };
186 | /* End PBXShellScriptBuildPhase section */
187 |
188 | /* Begin PBXSourcesBuildPhase section */
189 | 0F8F1DD81E5CA5E700DC0F5B /* Sources */ = {
190 | isa = PBXSourcesBuildPhase;
191 | buildActionMask = 2147483647;
192 | files = (
193 | 0F8F1DE21E5CA5E700DC0F5B /* ViewController.swift in Sources */,
194 | 0F8F1DF21E5CA75B00DC0F5B /* wwUtils.swift in Sources */,
195 | 0F8F1DE01E5CA5E700DC0F5B /* AppDelegate.swift in Sources */,
196 | 0F8F1DF61E5CA9AA00DC0F5B /* ClickCounter.swift in Sources */,
197 | );
198 | runOnlyForDeploymentPostprocessing = 0;
199 | };
200 | /* End PBXSourcesBuildPhase section */
201 |
202 | /* Begin PBXVariantGroup section */
203 | 0F8F1DE51E5CA5E700DC0F5B /* Main.storyboard */ = {
204 | isa = PBXVariantGroup;
205 | children = (
206 | 0F8F1DE61E5CA5E700DC0F5B /* Base */,
207 | );
208 | name = Main.storyboard;
209 | sourceTree = "";
210 | };
211 | /* End PBXVariantGroup section */
212 |
213 | /* Begin XCBuildConfiguration section */
214 | 0F8F1DE91E5CA5E700DC0F5B /* Debug */ = {
215 | isa = XCBuildConfiguration;
216 | buildSettings = {
217 | ALWAYS_SEARCH_USER_PATHS = NO;
218 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
219 | CLANG_ANALYZER_NONNULL = YES;
220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
221 | CLANG_CXX_LIBRARY = "libc++";
222 | CLANG_ENABLE_MODULES = YES;
223 | CLANG_ENABLE_OBJC_ARC = YES;
224 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
225 | CLANG_WARN_BOOL_CONVERSION = YES;
226 | CLANG_WARN_COMMA = YES;
227 | CLANG_WARN_CONSTANT_CONVERSION = YES;
228 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
231 | CLANG_WARN_EMPTY_BODY = YES;
232 | CLANG_WARN_ENUM_CONVERSION = YES;
233 | CLANG_WARN_INFINITE_RECURSION = YES;
234 | CLANG_WARN_INT_CONVERSION = YES;
235 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
236 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
237 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
238 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
239 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
240 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
241 | CLANG_WARN_STRICT_PROTOTYPES = YES;
242 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
243 | CLANG_WARN_UNREACHABLE_CODE = YES;
244 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
245 | CODE_SIGN_IDENTITY = "-";
246 | COPY_PHASE_STRIP = NO;
247 | DEBUG_INFORMATION_FORMAT = dwarf;
248 | ENABLE_STRICT_OBJC_MSGSEND = YES;
249 | ENABLE_TESTABILITY = YES;
250 | GCC_C_LANGUAGE_STANDARD = gnu99;
251 | GCC_DYNAMIC_NO_PIC = NO;
252 | GCC_NO_COMMON_BLOCKS = YES;
253 | GCC_OPTIMIZATION_LEVEL = 0;
254 | GCC_PREPROCESSOR_DEFINITIONS = (
255 | "DEBUG=1",
256 | "$(inherited)",
257 | );
258 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
259 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
260 | GCC_WARN_UNDECLARED_SELECTOR = YES;
261 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
262 | GCC_WARN_UNUSED_FUNCTION = YES;
263 | GCC_WARN_UNUSED_VARIABLE = YES;
264 | MACOSX_DEPLOYMENT_TARGET = 10.12;
265 | MTL_ENABLE_DEBUG_INFO = YES;
266 | ONLY_ACTIVE_ARCH = YES;
267 | SDKROOT = macosx;
268 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
269 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
270 | SWIFT_VERSION = 5.0;
271 | };
272 | name = Debug;
273 | };
274 | 0F8F1DEA1E5CA5E700DC0F5B /* Release */ = {
275 | isa = XCBuildConfiguration;
276 | buildSettings = {
277 | ALWAYS_SEARCH_USER_PATHS = NO;
278 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
279 | CLANG_ANALYZER_NONNULL = YES;
280 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
281 | CLANG_CXX_LIBRARY = "libc++";
282 | CLANG_ENABLE_MODULES = YES;
283 | CLANG_ENABLE_OBJC_ARC = YES;
284 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
285 | CLANG_WARN_BOOL_CONVERSION = YES;
286 | CLANG_WARN_COMMA = YES;
287 | CLANG_WARN_CONSTANT_CONVERSION = YES;
288 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
289 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
290 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
291 | CLANG_WARN_EMPTY_BODY = YES;
292 | CLANG_WARN_ENUM_CONVERSION = YES;
293 | CLANG_WARN_INFINITE_RECURSION = YES;
294 | CLANG_WARN_INT_CONVERSION = YES;
295 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
296 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
297 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
299 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
300 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
301 | CLANG_WARN_STRICT_PROTOTYPES = YES;
302 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
303 | CLANG_WARN_UNREACHABLE_CODE = YES;
304 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
305 | CODE_SIGN_IDENTITY = "-";
306 | COPY_PHASE_STRIP = NO;
307 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
308 | ENABLE_NS_ASSERTIONS = NO;
309 | ENABLE_STRICT_OBJC_MSGSEND = YES;
310 | GCC_C_LANGUAGE_STANDARD = gnu99;
311 | GCC_NO_COMMON_BLOCKS = YES;
312 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
313 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
314 | GCC_WARN_UNDECLARED_SELECTOR = YES;
315 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
316 | GCC_WARN_UNUSED_FUNCTION = YES;
317 | GCC_WARN_UNUSED_VARIABLE = YES;
318 | MACOSX_DEPLOYMENT_TARGET = 10.12;
319 | MTL_ENABLE_DEBUG_INFO = NO;
320 | SDKROOT = macosx;
321 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
322 | SWIFT_VERSION = 5.0;
323 | };
324 | name = Release;
325 | };
326 | 0F8F1DEC1E5CA5E700DC0F5B /* Debug */ = {
327 | isa = XCBuildConfiguration;
328 | buildSettings = {
329 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
330 | CODE_SIGN_IDENTITY = "-";
331 | COMBINE_HIDPI_IMAGES = YES;
332 | INFOPLIST_FILE = "Swift Custom Control/Info.plist";
333 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
334 | PRODUCT_BUNDLE_IDENTIFIER = "org.greybeard.Swift-Custom-Control";
335 | PRODUCT_NAME = "$(TARGET_NAME)";
336 | };
337 | name = Debug;
338 | };
339 | 0F8F1DED1E5CA5E700DC0F5B /* Release */ = {
340 | isa = XCBuildConfiguration;
341 | buildSettings = {
342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
343 | CODE_SIGN_IDENTITY = "-";
344 | COMBINE_HIDPI_IMAGES = YES;
345 | INFOPLIST_FILE = "Swift Custom Control/Info.plist";
346 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
347 | PRODUCT_BUNDLE_IDENTIFIER = "org.greybeard.Swift-Custom-Control";
348 | PRODUCT_NAME = "$(TARGET_NAME)";
349 | };
350 | name = Release;
351 | };
352 | /* End XCBuildConfiguration section */
353 |
354 | /* Begin XCConfigurationList section */
355 | 0F8F1DD71E5CA5E700DC0F5B /* Build configuration list for PBXProject "Swift Custom Control" */ = {
356 | isa = XCConfigurationList;
357 | buildConfigurations = (
358 | 0F8F1DE91E5CA5E700DC0F5B /* Debug */,
359 | 0F8F1DEA1E5CA5E700DC0F5B /* Release */,
360 | );
361 | defaultConfigurationIsVisible = 0;
362 | defaultConfigurationName = Release;
363 | };
364 | 0F8F1DEB1E5CA5E700DC0F5B /* Build configuration list for PBXNativeTarget "Swift Custom Control" */ = {
365 | isa = XCConfigurationList;
366 | buildConfigurations = (
367 | 0F8F1DEC1E5CA5E700DC0F5B /* Debug */,
368 | 0F8F1DED1E5CA5E700DC0F5B /* Release */,
369 | );
370 | defaultConfigurationIsVisible = 0;
371 | defaultConfigurationName = Release;
372 | };
373 | /* End XCConfigurationList section */
374 | };
375 | rootObject = 0F8F1DD41E5CA5E700DC0F5B /* Project object */;
376 | }
377 |
--------------------------------------------------------------------------------
/Swift Custom Control/Swift Custom Control/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
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 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
--------------------------------------------------------------------------------