├── .gitignore
├── docs
├── resources
│ ├── trees.png
│ ├── views.png
│ ├── outlines.png
│ └── StackGrid-demo.gif
└── IMPLEMENTATION.md
├── StackGrid.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── xcshareddata
│ └── xcschemes
│ │ └── StackGrid-iOS.xcscheme
└── project.pbxproj
├── StackGrid
├── AppDelegate.swift
├── StackGrid-Extensions.swift
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── ViewController.swift
└── StackGrid.swift
├── StackGrid-iOS
├── StackGrid_iOS.h
└── Info.plist
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | xcuserdata
2 |
--------------------------------------------------------------------------------
/docs/resources/trees.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VFUC/StackGrid/HEAD/docs/resources/trees.png
--------------------------------------------------------------------------------
/docs/resources/views.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VFUC/StackGrid/HEAD/docs/resources/views.png
--------------------------------------------------------------------------------
/docs/resources/outlines.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VFUC/StackGrid/HEAD/docs/resources/outlines.png
--------------------------------------------------------------------------------
/docs/resources/StackGrid-demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VFUC/StackGrid/HEAD/docs/resources/StackGrid-demo.gif
--------------------------------------------------------------------------------
/StackGrid.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/StackGrid.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/StackGrid/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // StackGrid
4 | //
5 | // Created by Jonas on 12/09/15.
6 | // Copyright © 2015 VFUC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
16 | return true
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/StackGrid/StackGrid-Extensions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StackGrid-Extensions.swift
3 | // StackGrid
4 | //
5 | // Created by Jonas on 12/09/15.
6 | // Copyright © 2015 VFUC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | extension NSLayoutConstraint.Axis {
12 |
13 | // Returns the (logical) opposite of an axis
14 | func inverse() -> NSLayoutConstraint.Axis {
15 | switch self {
16 | case .horizontal:
17 | return .vertical
18 |
19 | case .vertical:
20 | return .horizontal
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/StackGrid-iOS/StackGrid_iOS.h:
--------------------------------------------------------------------------------
1 | //
2 | // StackGrid_iOS.h
3 | // StackGrid-iOS
4 | //
5 | // Created by Jonas on 20.11.17.
6 | // Copyright © 2017 VFUC. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for StackGrid_iOS.
12 | FOUNDATION_EXPORT double StackGrid_iOSVersionNumber;
13 |
14 | //! Project version string for StackGrid_iOS.
15 | FOUNDATION_EXPORT const unsigned char StackGrid_iOSVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/StackGrid-iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Jonas Wippermann
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 |
--------------------------------------------------------------------------------
/StackGrid/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/StackGrid/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 | UIInterfaceOrientationLandscapeLeft
37 | UIInterfaceOrientationLandscapeRight
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/StackGrid/Base.lproj/LaunchScreen.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 |
--------------------------------------------------------------------------------
/StackGrid/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // StackGrid
4 | //
5 | // Created by Jonas on 12/09/15.
6 | // Copyright © 2015 VFUC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ViewController: UIViewController {
12 |
13 | @IBOutlet weak var grid: StackGrid!
14 |
15 | var viewCount = 5
16 | let purple = UIColor(red:0.35, green:0.24, blue:0.76, alpha:1)
17 |
18 | override func viewDidLoad() {
19 | super.viewDidLoad()
20 |
21 | navigationItem.rightBarButtonItem = UIBarButtonItem(title: "+", style: .plain, target: self, action: #selector(ViewController.addButton))
22 | navigationItem.leftBarButtonItem = UIBarButtonItem(title: "-", style: .plain, target: self, action: #selector(ViewController.removeButton))
23 |
24 | grid.setGridViews(createGradientViews(numOfViews: viewCount, color: purple))
25 | }
26 |
27 | override func didReceiveMemoryWarning() {
28 | super.didReceiveMemoryWarning()
29 | // Dispose of any resources that can be recreated.
30 | }
31 |
32 |
33 | func createGradientViews(numOfViews num: Int, color: UIColor) -> [UIView]{
34 | var views = [UIView]()
35 |
36 | let interval : Float = Float(1) / Float(num)
37 | for i in 0..
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/docs/IMPLEMENTATION.md:
--------------------------------------------------------------------------------
1 | #Implementation
2 | If you try to take a look and understand the code, you'll stumble across weird "trees", "nodes" and "leaves".
3 | *What's up with that?* Let me try to explain:
4 |
5 | ##Concept
6 | I started by laying out my idea of the final outcome, which looked something like this:
7 |
8 | 
9 |
10 | The available space would be more or less evenly distributed across all the views.
11 |
12 | Whenever one view is "sliced" into half to make room for the next, it must change its orientation from horizontal to vertical (or the other way around). That is why it is necessary to nest the (Stack)views into each other, outlined here:
13 |
14 | 
15 |
16 | Visualizing this hierarchy (with my mediocre Sketch skills) shows that we're effectively building binary trees:
17 |
18 | 
19 |
20 | The s-prefixed boxes are the UIStackViews, the other ones the actual views to be displayed.
21 |
22 |
23 | ##Implementation
24 | After prototyping and testing different approaches, the best Implementation I came up with was building the tree in code on every desired change, then updating the views accordingly.
25 |
26 | Therefore we need some basic structures:
27 |
28 | struct TreeElement {
29 | var type: TreeElementType
30 | var child1ViewIndex, child2ViewIndex : Int?
31 | var set = false
32 |
33 | init(type: TreeElementType){
34 | self.type = type
35 | }
36 | }
37 |
38 | enum TreeElementType{
39 | case Node
40 | case Leaf
41 | }
42 |
43 | So a TreeElement can either be a "node" or a "leaf", renamed from "UIStackView" and "regular non-StackView-View", respectively, for convenience reasons. It can have childs if it is a node (referenced by their spot in the tree-array) and it can be "set" ( == "placed in the tree") or not.
44 |
45 | With this we can provide a "tree"-property, which will then be modified by the "buildTreeForNodeCount(count: Int)" method.
46 |
47 | ###buildTreeForNodeCount(count: Int)
48 | There are comments in the code, but here's another rough outline:
49 | - Reset the tree
50 | - Append nodes and leaves: for n views we need n nodes and n leaves. The tree-array stores nodes first, then leaves
51 | - Attach the nodes to each other: Rather simple, each node looks for a free spot ( == unset child view ) on the previous nodes until all nodes are attached
52 | - Attach leaves: A bit trickier. When you lay out the binary trees, the leaves can all end up on the same layer ( or "depth" of tree ), or on two different ones. We could just attach the leaves like the nodes before, but the distribution would end up less evenly. *Think about the tree graphic above. In the last two trees, if we'd attach all leaves sequentially, we'd have many small-sized views, and a few much bigger views taking up the leftover space. Preferably we'd offer everyone the same amount of space, unless we absolutely have to slice to create space.* So to get the desired results we're filling up the first leaf layer forwards and the second one backwards.
53 |
54 | ###updateViews()
55 | So far, so good. The "updateViews()" method now uses the tree we just built to create the correlating StackView-nesting-mania:
56 | - First a quick 0-check
57 | - Compare amount of nodes already present with amount of "nodeViews", the actual non-stackView-views we're adding to the view tree. Add or remove accordingly.
58 | - Iterate over all nodeViews and set their axis' orientation (they're alternating, starting from the root node)
59 | - Compare and add/remove leaves, similar to the nodes previously
60 | - The views are now in place and need to be attached to each other. We iterate over all nodes and check the child indices stored in our tree information. If they are present, the matching view is retrieved, compared with the current nodes' childs and added/removed as needed.
61 | - Finally we check and (if necessary) fix the order of the childs we just modified.
62 |
63 |
64 |
65 |
66 |
67 | **That**'s it. This procedure gets called on every change to the "viewsToDisplay"-array, so whenever one of the public methods to adjust the grid is called.
68 |
69 | I do have to admit that these two functions are a tiny bit humongous, but attempts at further refactoring so far resulted in reducing the overall ability to grasp what in the world is going on.
70 |
71 | BUT if you do see room for improvement, please feel free to create a pull request! For any further questions, you may reach me via [mail](mailto:jonas@vfuc.co) or [twitter](https://twitter.com/VFUC42).
72 |
73 |
74 |
--------------------------------------------------------------------------------
/StackGrid/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 |
--------------------------------------------------------------------------------
/StackGrid/StackGrid.swift:
--------------------------------------------------------------------------------
1 | //
2 | // StackGrid.swift
3 | // StackGrid
4 | //
5 | // Created by Jonas on 12/09/15.
6 | // Copyright © 2015 VFUC. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | struct TreeElement {
12 | var type: TreeElementType
13 | var child1ViewIndex, child2ViewIndex : Int?
14 | var set = false
15 |
16 | init(type: TreeElementType){
17 | self.type = type
18 | }
19 | }
20 |
21 | enum TreeElementType {
22 | case node
23 | case leaf
24 | }
25 |
26 | public class StackGrid: UIView {
27 |
28 | // MARK: Properties
29 |
30 | private let rootNode: UIStackView = {
31 | let stackView = UIStackView()
32 | stackView.axis = .vertical
33 | stackView.distribution = .fillEqually
34 | stackView.translatesAutoresizingMaskIntoConstraints = false
35 | return stackView
36 | }()
37 |
38 | private var tree = [TreeElement]()
39 | private var views = [UIView]()
40 | private var viewsToDisplay = [UIView]() {
41 | didSet {
42 | if viewsToDisplay.count >= 0 {
43 | buildTree(forNodeCount: viewsToDisplay.count)
44 | updateViews()
45 | }
46 | }
47 | }
48 |
49 |
50 | // MARK: Methods
51 | public override func draw(_ rect: CGRect) {
52 | super.draw(rect)
53 | self.addSubview(rootNode)
54 | pinToEdges(view: rootNode)
55 | }
56 |
57 | /**
58 | Set orientation of the root node's axis
59 | - parameter axis The axis to apply to the root node
60 | */
61 | public func setRootAxis(axis: NSLayoutConstraint.Axis){
62 | rootNode.axis = axis
63 | if viewsToDisplay.count >= 0 {
64 | buildTree(forNodeCount: viewsToDisplay.count)
65 | updateViews()
66 | }
67 | }
68 |
69 | /**
70 | Set views to be displayed in grid.
71 | This overwrites all current views.
72 | - parameter views The views to be displayed
73 | */
74 | public func setGridViews(_ views: [UIView]) {
75 | viewsToDisplay = views
76 | }
77 |
78 | /**
79 | Add view to grid.
80 | This appends a view to the end of the current views
81 | - parameter view The view to be added
82 | */
83 | public func addGridView(_ view: UIView){
84 | viewsToDisplay.append(view)
85 | }
86 |
87 | /**
88 | Add views to grid
89 | This appends multiple views to the end of the current views
90 | - parameter views The views to be added
91 | */
92 | public func addGridViews(_ views: [UIView]) {
93 | for view in views {
94 | addGridView(view)
95 | }
96 | }
97 |
98 | /**
99 | Remove view from grid
100 | - index Specify which view should be removed
101 | */
102 | public func removeGridView(at index: Int) {
103 | guard index >= 0 && index 0 else {
113 | print("Error: removeLastGridView called on empty grid")
114 | return
115 | }
116 | viewsToDisplay.removeLast()
117 | }
118 |
119 | private func pinToEdges(view: UIView) {
120 | view.translatesAutoresizingMaskIntoConstraints = false
121 |
122 | self.addConstraint(NSLayoutConstraint(
123 | item: view,
124 | attribute: .left,
125 | relatedBy: .equal,
126 | toItem: self,
127 | attribute: .left,
128 | multiplier: 1,
129 | constant: 0))
130 |
131 | self.addConstraint(NSLayoutConstraint(
132 | item: view,
133 | attribute: .right,
134 | relatedBy: .equal,
135 | toItem: self,
136 | attribute: .right,
137 | multiplier: 1,
138 | constant: 0))
139 |
140 | self.addConstraint(NSLayoutConstraint(
141 | item: view,
142 | attribute: .top,
143 | relatedBy: .equal,
144 | toItem: self,
145 | attribute: .top,
146 | multiplier: 1,
147 | constant: 0))
148 |
149 | self.addConstraint(NSLayoutConstraint(
150 | item: view,
151 | attribute: .bottom,
152 | relatedBy: .equal,
153 | toItem: self,
154 | attribute: .bottom,
155 | multiplier: 1,
156 | constant: 0))
157 | }
158 |
159 | /*
160 | //MARK: Layout Construction
161 | */
162 |
163 | private func buildTree(forNodeCount count: Int) {
164 |
165 | guard count >= 0 else {
166 | print("ERROR - Can't build tree for node count <= 0")
167 | return
168 | }
169 |
170 | //reset tree
171 | tree = [TreeElement]()
172 |
173 | if count == 0 { //return with empty tree
174 | return
175 | }
176 |
177 |
178 | // add nodes to tree
179 | for _ in 0.. 0 {
195 |
196 | //look for a node to attach to
197 | for (j, subElement) in tree.enumerated() where subElement.type == .node && i != j {
198 |
199 | //if inspected node has no child index yet, attach and stop looking
200 | if tree[j].child1ViewIndex == nil {
201 | tree[j].child1ViewIndex = i
202 | tree[i].set = true
203 | break
204 | }
205 |
206 | if tree[j].child2ViewIndex == nil {
207 | tree[j].child2ViewIndex = i
208 | tree[i].set = true
209 | break
210 | }
211 | }
212 |
213 | guard tree[i].set else {
214 | print("ERROR - Couldn't attach node with index \(i) to other nodes")
215 | return
216 | }
217 | }
218 |
219 |
220 | //attach leaves
221 | let firstLeafLayer = getLayer(for: count) //count = first leaf
222 | let secondLeafLayer = allLeavesSameLayer() ? firstLeafLayer : firstLeafLayer + 1 //if all leaves same layer then both layers are same
223 |
224 | let firstNodeLayer = firstLeafLayer - 1
225 | let secondNodeLayer = secondLeafLayer - 1
226 |
227 |
228 | //Fill up first leaf Layer backwards
229 | //iterate over all leaves, backwards
230 | if firstLeafLayer != secondLeafLayer {//only if layers are different, else skip right to forwards fill up!
231 |
232 | for i in tree.indices.reversed() where tree[i].type == .leaf {
233 | //iterate over nodes on the correct layer, backwards
234 | for j in tree.indices.reversed() where tree[j].type == .node && getLayer(for: j) == firstNodeLayer {
235 | //attach if no child yet, do child2 first because we're filling up backwards
236 | if tree[j].child2ViewIndex == nil {
237 | tree[j].child2ViewIndex = i
238 | tree[i].set = true
239 | break
240 | }
241 |
242 | if tree[j].child1ViewIndex == nil {
243 | tree[j].child1ViewIndex = i
244 | tree[i].set = true
245 | break
246 | }
247 | }
248 | }
249 | }
250 |
251 | //Fill up second leaf layer forwards
252 | //iterate over leaves which have not been set yet, forward
253 | for i in 0.. getNodeViewCount() { //nodes have been added to tree
296 | views.insert(getNewNodeView(), at: getEndOfNodeViewsIndex()) //add node view to end
297 | }
298 |
299 | while getNodeViewCount() > getNodeCount() { //nodes have been removed from tree
300 | views.remove(at: getEndOfNodeViewsIndex() - 1) //remove node view from end
301 | }
302 |
303 | if views[0] != rootNode { //make sure root node is in place
304 | views[0] = rootNode
305 | }
306 |
307 |
308 | for i in 0.. getLeafCount() {
326 | views.removeLast()
327 | }
328 |
329 | for i in viewsToDisplay.indices {
330 | let nodeViewCount = getNodeViewCount()
331 |
332 | if (nodeViewCount + i ) > views.count - 1 { // check if view at that index exists already, if not nodeViewCount + i would be > views.count - 1 and therefore out of bounds
333 | views.insert(viewsToDisplay[i], at: nodeViewCount + i) // if not append
334 | } else {
335 | if views[nodeViewCount + i] != viewsToDisplay[i] { // overwrite if different
336 | views[nodeViewCount + i] = viewsToDisplay[i]
337 | }
338 | }
339 | }
340 |
341 |
342 | // views are now in place, need to be attached to each other
343 | for (i, element) in tree.enumerated() where element.type == .node{
344 | guard views[i].isKind(of: UIStackView.self) else {
345 | print("ERROR - View with index \(i) should be a Node/StackView!")
346 | return
347 | }
348 |
349 | let nodeView = views[i] as! UIStackView
350 |
351 | var childViews = [UIView]()
352 |
353 | if let child1 = tree[i].child1ViewIndex {
354 | childViews.append(views[child1])
355 | }
356 |
357 | if let child2 = tree[i].child2ViewIndex {
358 | childViews.append(views[child2])
359 | }
360 |
361 | //if subview is not supposed to be subview, remove
362 | for subView in nodeView.arrangedSubviews {
363 | if !childViews.contains(subView) {
364 | subView.removeFromSuperview()
365 | }
366 | }
367 |
368 | //if childview is supposed to be attached, attach
369 | for childView in childViews {
370 | if !nodeView.arrangedSubviews.contains(childView) {
371 | childView.removeFromSuperview() //remove in case it is still attached to another stackview
372 | nodeView.addArrangedSubview(childView)
373 | }
374 | }
375 |
376 | guard childViews.count == nodeView.arrangedSubviews.count else {
377 | print("ERROR: ChildViews should contain same number of elements as arrangedSubviews")
378 | return
379 | }
380 |
381 | guard childViews.count <= 2 else {
382 | print("ERROR: Node should not have more than 2 child views!")
383 | return
384 | }
385 |
386 | //check order of childViews
387 | if childViews.count == 2 { //doesn't make sense with 1 view
388 | let childView = childViews[0]
389 | let subViewIndex = nodeView.arrangedSubviews.firstIndex(of: childView) //if the two indices are equal, the views are in order
390 |
391 | if subViewIndex != 0 { //not in order => swap
392 | let view0 = nodeView.arrangedSubviews[0]
393 | nodeView.removeArrangedSubview(view0) //swap by removing and appending
394 | nodeView.addArrangedSubview(view0)
395 | }
396 | }
397 |
398 | }
399 | }
400 |
401 | private func getLayer(for index: Int) -> Int{
402 | var layer = 0
403 | var i = 0
404 |
405 | while i < index {
406 | i = i + Int(2 * pow(Double(2), Double(layer)))
407 | layer = layer + 1
408 | }
409 | return layer
410 | }
411 |
412 | //determines whether all leaves are same layer
413 | private func allLeavesSameLayer() -> Bool {
414 | var set = false
415 | var layer = -1
416 |
417 | for (index, element) in tree.enumerated() where element.type == .leaf {
418 | if !set {
419 | layer = getLayer(for: index)
420 | set = true
421 | } else {
422 | if getLayer(for: index) != layer {
423 | return false
424 | }
425 | }
426 | }
427 |
428 | return true
429 | }
430 |
431 |
432 | private func getNodeCount() -> Int {
433 | return tree.filter({ $0.type == .node }).count
434 | }
435 |
436 | private func getLeafCount() -> Int {
437 | return tree.filter({ $0.type == .leaf }).count
438 | }
439 |
440 |
441 | private func getNodeViewCount() -> Int {
442 | return views.filter({ $0 is UIStackView }).count
443 | }
444 |
445 | private func getLeafViewCount() -> Int {
446 | return views.filter({ !($0 is UIStackView) }).count
447 | }
448 |
449 | // returns index of first non-node view in views
450 | private func getEndOfNodeViewsIndex() -> Int {
451 | return views.indices.first(where: { !views[$0].isKind(of: UIStackView.self) }) ?? views.count
452 | // if no leaves => end of array is end of views
453 | }
454 |
455 | private func getNewNodeView() -> UIStackView {
456 | let stackView = UIStackView()
457 | stackView.translatesAutoresizingMaskIntoConstraints = false
458 | stackView.distribution = .fillEqually
459 | return stackView
460 | }
461 |
462 | //MARK: Debug Helpers
463 |
464 | private func printTree(){
465 | for i in tree.indices {
466 |
467 | print("\(getIDString(for: i)), index: \(i), type: \(tree[i].type)")
468 |
469 | if let child1 = tree[i].child1ViewIndex {
470 | print(" Child 1: \(getIDString(for: child1)), index: \(child1)")
471 | }
472 |
473 | if let child2 = tree[i].child2ViewIndex {
474 | print(" Child 2: \(getIDString(for: child2)), index: \(child2)")
475 | }
476 | }
477 | }
478 |
479 | private func getIDString(for index: Int) -> String {
480 |
481 | switch tree[index].type {
482 | case .leaf:
483 | return "v\(index - (tree.count / 2))"
484 | case .node:
485 | return "s\(index)"
486 | }
487 | }
488 | private func printStackViewStructure(prefix: String = "", views: [UIView]){
489 | for view in views{
490 | if view.isKind(of: UIStackView.self){
491 | let subContainer = (view as! UIStackView)
492 | print("\(prefix)UIStackView - \(subContainer.hashValue)")
493 | printStackViewStructure(prefix: prefix + "-", views: subContainer.arrangedSubviews)
494 | }else{
495 | print("\(prefix)UIView - \(view.hashValue) - tag: \(view.tag)")
496 | }
497 | }
498 | }
499 | }
500 |
--------------------------------------------------------------------------------
/StackGrid.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 722B1E4F1BA3F6CA0072E4B6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E4E1BA3F6CA0072E4B6 /* AppDelegate.swift */; };
11 | 722B1E511BA3F6CA0072E4B6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E501BA3F6CA0072E4B6 /* ViewController.swift */; };
12 | 722B1E541BA3F6CA0072E4B6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 722B1E521BA3F6CA0072E4B6 /* Main.storyboard */; };
13 | 722B1E561BA3F6CA0072E4B6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 722B1E551BA3F6CA0072E4B6 /* Assets.xcassets */; };
14 | 722B1E591BA3F6CA0072E4B6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 722B1E571BA3F6CA0072E4B6 /* LaunchScreen.storyboard */; };
15 | 722B1E7D1BA3F7840072E4B6 /* StackGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E7C1BA3F7840072E4B6 /* StackGrid.swift */; };
16 | 722B1E7F1BA3F8670072E4B6 /* StackGrid-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E7E1BA3F8670072E4B6 /* StackGrid-Extensions.swift */; };
17 | 72DA11381FC362260070FD93 /* StackGrid_iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 72DA112A1FC362260070FD93 /* StackGrid_iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
18 | 72DA113F1FC362310070FD93 /* StackGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E7C1BA3F7840072E4B6 /* StackGrid.swift */; };
19 | 72DA11401FC362970070FD93 /* StackGrid-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 722B1E7E1BA3F8670072E4B6 /* StackGrid-Extensions.swift */; };
20 | /* End PBXBuildFile section */
21 |
22 | /* Begin PBXFileReference section */
23 | 722B1E4B1BA3F6CA0072E4B6 /* StackGrid.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StackGrid.app; sourceTree = BUILT_PRODUCTS_DIR; };
24 | 722B1E4E1BA3F6CA0072E4B6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
25 | 722B1E501BA3F6CA0072E4B6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
26 | 722B1E531BA3F6CA0072E4B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
27 | 722B1E551BA3F6CA0072E4B6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
28 | 722B1E581BA3F6CA0072E4B6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
29 | 722B1E5A1BA3F6CA0072E4B6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
30 | 722B1E7C1BA3F7840072E4B6 /* StackGrid.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StackGrid.swift; sourceTree = ""; };
31 | 722B1E7E1BA3F8670072E4B6 /* StackGrid-Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StackGrid-Extensions.swift"; sourceTree = ""; };
32 | 72DA11281FC362250070FD93 /* StackGrid_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StackGrid_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
33 | 72DA112A1FC362260070FD93 /* StackGrid_iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StackGrid_iOS.h; sourceTree = ""; };
34 | 72DA112B1FC362260070FD93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
35 | /* End PBXFileReference section */
36 |
37 | /* Begin PBXFrameworksBuildPhase section */
38 | 722B1E481BA3F6CA0072E4B6 /* Frameworks */ = {
39 | isa = PBXFrameworksBuildPhase;
40 | buildActionMask = 2147483647;
41 | files = (
42 | );
43 | runOnlyForDeploymentPostprocessing = 0;
44 | };
45 | 72DA11241FC362250070FD93 /* Frameworks */ = {
46 | isa = PBXFrameworksBuildPhase;
47 | buildActionMask = 2147483647;
48 | files = (
49 | );
50 | runOnlyForDeploymentPostprocessing = 0;
51 | };
52 | /* End PBXFrameworksBuildPhase section */
53 |
54 | /* Begin PBXGroup section */
55 | 722B1E421BA3F6CA0072E4B6 = {
56 | isa = PBXGroup;
57 | children = (
58 | 722B1E4D1BA3F6CA0072E4B6 /* StackGrid */,
59 | 72DA11291FC362250070FD93 /* StackGrid-iOS */,
60 | 722B1E4C1BA3F6CA0072E4B6 /* Products */,
61 | );
62 | sourceTree = "";
63 | };
64 | 722B1E4C1BA3F6CA0072E4B6 /* Products */ = {
65 | isa = PBXGroup;
66 | children = (
67 | 722B1E4B1BA3F6CA0072E4B6 /* StackGrid.app */,
68 | 72DA11281FC362250070FD93 /* StackGrid_iOS.framework */,
69 | );
70 | name = Products;
71 | sourceTree = "";
72 | };
73 | 722B1E4D1BA3F6CA0072E4B6 /* StackGrid */ = {
74 | isa = PBXGroup;
75 | children = (
76 | 722B1E4E1BA3F6CA0072E4B6 /* AppDelegate.swift */,
77 | 722B1E501BA3F6CA0072E4B6 /* ViewController.swift */,
78 | 722B1E7C1BA3F7840072E4B6 /* StackGrid.swift */,
79 | 722B1E7E1BA3F8670072E4B6 /* StackGrid-Extensions.swift */,
80 | 722B1E521BA3F6CA0072E4B6 /* Main.storyboard */,
81 | 722B1E551BA3F6CA0072E4B6 /* Assets.xcassets */,
82 | 722B1E571BA3F6CA0072E4B6 /* LaunchScreen.storyboard */,
83 | 722B1E5A1BA3F6CA0072E4B6 /* Info.plist */,
84 | );
85 | path = StackGrid;
86 | sourceTree = "";
87 | };
88 | 72DA11291FC362250070FD93 /* StackGrid-iOS */ = {
89 | isa = PBXGroup;
90 | children = (
91 | 72DA112A1FC362260070FD93 /* StackGrid_iOS.h */,
92 | 72DA112B1FC362260070FD93 /* Info.plist */,
93 | );
94 | path = "StackGrid-iOS";
95 | sourceTree = "";
96 | };
97 | /* End PBXGroup section */
98 |
99 | /* Begin PBXHeadersBuildPhase section */
100 | 72DA11251FC362250070FD93 /* Headers */ = {
101 | isa = PBXHeadersBuildPhase;
102 | buildActionMask = 2147483647;
103 | files = (
104 | 72DA11381FC362260070FD93 /* StackGrid_iOS.h in Headers */,
105 | );
106 | runOnlyForDeploymentPostprocessing = 0;
107 | };
108 | /* End PBXHeadersBuildPhase section */
109 |
110 | /* Begin PBXNativeTarget section */
111 | 722B1E4A1BA3F6CA0072E4B6 /* StackGrid */ = {
112 | isa = PBXNativeTarget;
113 | buildConfigurationList = 722B1E731BA3F6CA0072E4B6 /* Build configuration list for PBXNativeTarget "StackGrid" */;
114 | buildPhases = (
115 | 722B1E471BA3F6CA0072E4B6 /* Sources */,
116 | 722B1E481BA3F6CA0072E4B6 /* Frameworks */,
117 | 722B1E491BA3F6CA0072E4B6 /* Resources */,
118 | );
119 | buildRules = (
120 | );
121 | dependencies = (
122 | );
123 | name = StackGrid;
124 | productName = StackGrid;
125 | productReference = 722B1E4B1BA3F6CA0072E4B6 /* StackGrid.app */;
126 | productType = "com.apple.product-type.application";
127 | };
128 | 72DA11271FC362250070FD93 /* StackGrid-iOS */ = {
129 | isa = PBXNativeTarget;
130 | buildConfigurationList = 72DA113D1FC362260070FD93 /* Build configuration list for PBXNativeTarget "StackGrid-iOS" */;
131 | buildPhases = (
132 | 72DA11231FC362250070FD93 /* Sources */,
133 | 72DA11241FC362250070FD93 /* Frameworks */,
134 | 72DA11251FC362250070FD93 /* Headers */,
135 | 72DA11261FC362250070FD93 /* Resources */,
136 | );
137 | buildRules = (
138 | );
139 | dependencies = (
140 | );
141 | name = "StackGrid-iOS";
142 | productName = "StackGrid-iOS";
143 | productReference = 72DA11281FC362250070FD93 /* StackGrid_iOS.framework */;
144 | productType = "com.apple.product-type.framework";
145 | };
146 | /* End PBXNativeTarget section */
147 |
148 | /* Begin PBXProject section */
149 | 722B1E431BA3F6CA0072E4B6 /* Project object */ = {
150 | isa = PBXProject;
151 | attributes = {
152 | LastSwiftUpdateCheck = 0900;
153 | LastUpgradeCheck = 1020;
154 | ORGANIZATIONNAME = VFUC;
155 | TargetAttributes = {
156 | 722B1E4A1BA3F6CA0072E4B6 = {
157 | CreatedOnToolsVersion = 7.0;
158 | LastSwiftMigration = 1020;
159 | ProvisioningStyle = Manual;
160 | };
161 | 72DA11271FC362250070FD93 = {
162 | CreatedOnToolsVersion = 9.0.1;
163 | ProvisioningStyle = Automatic;
164 | };
165 | };
166 | };
167 | buildConfigurationList = 722B1E461BA3F6CA0072E4B6 /* Build configuration list for PBXProject "StackGrid" */;
168 | compatibilityVersion = "Xcode 3.2";
169 | developmentRegion = en;
170 | hasScannedForEncodings = 0;
171 | knownRegions = (
172 | en,
173 | Base,
174 | );
175 | mainGroup = 722B1E421BA3F6CA0072E4B6;
176 | productRefGroup = 722B1E4C1BA3F6CA0072E4B6 /* Products */;
177 | projectDirPath = "";
178 | projectRoot = "";
179 | targets = (
180 | 722B1E4A1BA3F6CA0072E4B6 /* StackGrid */,
181 | 72DA11271FC362250070FD93 /* StackGrid-iOS */,
182 | );
183 | };
184 | /* End PBXProject section */
185 |
186 | /* Begin PBXResourcesBuildPhase section */
187 | 722B1E491BA3F6CA0072E4B6 /* Resources */ = {
188 | isa = PBXResourcesBuildPhase;
189 | buildActionMask = 2147483647;
190 | files = (
191 | 722B1E591BA3F6CA0072E4B6 /* LaunchScreen.storyboard in Resources */,
192 | 722B1E561BA3F6CA0072E4B6 /* Assets.xcassets in Resources */,
193 | 722B1E541BA3F6CA0072E4B6 /* Main.storyboard in Resources */,
194 | );
195 | runOnlyForDeploymentPostprocessing = 0;
196 | };
197 | 72DA11261FC362250070FD93 /* Resources */ = {
198 | isa = PBXResourcesBuildPhase;
199 | buildActionMask = 2147483647;
200 | files = (
201 | );
202 | runOnlyForDeploymentPostprocessing = 0;
203 | };
204 | /* End PBXResourcesBuildPhase section */
205 |
206 | /* Begin PBXSourcesBuildPhase section */
207 | 722B1E471BA3F6CA0072E4B6 /* Sources */ = {
208 | isa = PBXSourcesBuildPhase;
209 | buildActionMask = 2147483647;
210 | files = (
211 | 722B1E511BA3F6CA0072E4B6 /* ViewController.swift in Sources */,
212 | 722B1E7D1BA3F7840072E4B6 /* StackGrid.swift in Sources */,
213 | 722B1E7F1BA3F8670072E4B6 /* StackGrid-Extensions.swift in Sources */,
214 | 722B1E4F1BA3F6CA0072E4B6 /* AppDelegate.swift in Sources */,
215 | );
216 | runOnlyForDeploymentPostprocessing = 0;
217 | };
218 | 72DA11231FC362250070FD93 /* Sources */ = {
219 | isa = PBXSourcesBuildPhase;
220 | buildActionMask = 2147483647;
221 | files = (
222 | 72DA11401FC362970070FD93 /* StackGrid-Extensions.swift in Sources */,
223 | 72DA113F1FC362310070FD93 /* StackGrid.swift in Sources */,
224 | );
225 | runOnlyForDeploymentPostprocessing = 0;
226 | };
227 | /* End PBXSourcesBuildPhase section */
228 |
229 | /* Begin PBXVariantGroup section */
230 | 722B1E521BA3F6CA0072E4B6 /* Main.storyboard */ = {
231 | isa = PBXVariantGroup;
232 | children = (
233 | 722B1E531BA3F6CA0072E4B6 /* Base */,
234 | );
235 | name = Main.storyboard;
236 | sourceTree = "";
237 | };
238 | 722B1E571BA3F6CA0072E4B6 /* LaunchScreen.storyboard */ = {
239 | isa = PBXVariantGroup;
240 | children = (
241 | 722B1E581BA3F6CA0072E4B6 /* Base */,
242 | );
243 | name = LaunchScreen.storyboard;
244 | sourceTree = "";
245 | };
246 | /* End PBXVariantGroup section */
247 |
248 | /* Begin XCBuildConfiguration section */
249 | 722B1E711BA3F6CA0072E4B6 /* Debug */ = {
250 | isa = XCBuildConfiguration;
251 | buildSettings = {
252 | ALWAYS_SEARCH_USER_PATHS = NO;
253 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
254 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
255 | CLANG_CXX_LIBRARY = "libc++";
256 | CLANG_ENABLE_MODULES = YES;
257 | CLANG_ENABLE_OBJC_ARC = YES;
258 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
259 | CLANG_WARN_BOOL_CONVERSION = YES;
260 | CLANG_WARN_COMMA = YES;
261 | CLANG_WARN_CONSTANT_CONVERSION = YES;
262 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
263 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
264 | CLANG_WARN_EMPTY_BODY = YES;
265 | CLANG_WARN_ENUM_CONVERSION = YES;
266 | CLANG_WARN_INFINITE_RECURSION = YES;
267 | CLANG_WARN_INT_CONVERSION = YES;
268 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
269 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
270 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
272 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
273 | CLANG_WARN_STRICT_PROTOTYPES = YES;
274 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
275 | CLANG_WARN_UNREACHABLE_CODE = YES;
276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
278 | COPY_PHASE_STRIP = NO;
279 | DEBUG_INFORMATION_FORMAT = dwarf;
280 | ENABLE_STRICT_OBJC_MSGSEND = YES;
281 | ENABLE_TESTABILITY = YES;
282 | GCC_C_LANGUAGE_STANDARD = gnu99;
283 | GCC_DYNAMIC_NO_PIC = NO;
284 | GCC_NO_COMMON_BLOCKS = YES;
285 | GCC_OPTIMIZATION_LEVEL = 0;
286 | GCC_PREPROCESSOR_DEFINITIONS = (
287 | "DEBUG=1",
288 | "$(inherited)",
289 | );
290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292 | GCC_WARN_UNDECLARED_SELECTOR = YES;
293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294 | GCC_WARN_UNUSED_FUNCTION = YES;
295 | GCC_WARN_UNUSED_VARIABLE = YES;
296 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
297 | MTL_ENABLE_DEBUG_INFO = YES;
298 | ONLY_ACTIVE_ARCH = YES;
299 | SDKROOT = iphoneos;
300 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
301 | TARGETED_DEVICE_FAMILY = "1,2";
302 | };
303 | name = Debug;
304 | };
305 | 722B1E721BA3F6CA0072E4B6 /* Release */ = {
306 | isa = XCBuildConfiguration;
307 | buildSettings = {
308 | ALWAYS_SEARCH_USER_PATHS = NO;
309 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
311 | CLANG_CXX_LIBRARY = "libc++";
312 | CLANG_ENABLE_MODULES = YES;
313 | CLANG_ENABLE_OBJC_ARC = YES;
314 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
315 | CLANG_WARN_BOOL_CONVERSION = YES;
316 | CLANG_WARN_COMMA = YES;
317 | CLANG_WARN_CONSTANT_CONVERSION = YES;
318 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
320 | CLANG_WARN_EMPTY_BODY = YES;
321 | CLANG_WARN_ENUM_CONVERSION = YES;
322 | CLANG_WARN_INFINITE_RECURSION = YES;
323 | CLANG_WARN_INT_CONVERSION = YES;
324 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
325 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
326 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
328 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
329 | CLANG_WARN_STRICT_PROTOTYPES = YES;
330 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
331 | CLANG_WARN_UNREACHABLE_CODE = YES;
332 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
333 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
334 | COPY_PHASE_STRIP = NO;
335 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
336 | ENABLE_NS_ASSERTIONS = NO;
337 | ENABLE_STRICT_OBJC_MSGSEND = YES;
338 | GCC_C_LANGUAGE_STANDARD = gnu99;
339 | GCC_NO_COMMON_BLOCKS = YES;
340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
342 | GCC_WARN_UNDECLARED_SELECTOR = YES;
343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
344 | GCC_WARN_UNUSED_FUNCTION = YES;
345 | GCC_WARN_UNUSED_VARIABLE = YES;
346 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
347 | MTL_ENABLE_DEBUG_INFO = NO;
348 | SDKROOT = iphoneos;
349 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
350 | TARGETED_DEVICE_FAMILY = "1,2";
351 | VALIDATE_PRODUCT = YES;
352 | };
353 | name = Release;
354 | };
355 | 722B1E741BA3F6CA0072E4B6 /* Debug */ = {
356 | isa = XCBuildConfiguration;
357 | buildSettings = {
358 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
359 | CODE_SIGN_STYLE = Manual;
360 | DEVELOPMENT_TEAM = "";
361 | INFOPLIST_FILE = StackGrid/Info.plist;
362 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
363 | PRODUCT_BUNDLE_IDENTIFIER = vfuc.StackGrid;
364 | PRODUCT_NAME = "$(TARGET_NAME)";
365 | PROVISIONING_PROFILE_SPECIFIER = "";
366 | SWIFT_VERSION = 5.0;
367 | };
368 | name = Debug;
369 | };
370 | 722B1E751BA3F6CA0072E4B6 /* Release */ = {
371 | isa = XCBuildConfiguration;
372 | buildSettings = {
373 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
374 | CODE_SIGN_STYLE = Manual;
375 | DEVELOPMENT_TEAM = "";
376 | INFOPLIST_FILE = StackGrid/Info.plist;
377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
378 | PRODUCT_BUNDLE_IDENTIFIER = vfuc.StackGrid;
379 | PRODUCT_NAME = "$(TARGET_NAME)";
380 | PROVISIONING_PROFILE_SPECIFIER = "";
381 | SWIFT_VERSION = 5.0;
382 | };
383 | name = Release;
384 | };
385 | 72DA11391FC362260070FD93 /* Debug */ = {
386 | isa = XCBuildConfiguration;
387 | buildSettings = {
388 | CLANG_ANALYZER_NONNULL = YES;
389 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
390 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
391 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
392 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
393 | CODE_SIGN_IDENTITY = "";
394 | CODE_SIGN_STYLE = Automatic;
395 | CURRENT_PROJECT_VERSION = 1;
396 | DEFINES_MODULE = YES;
397 | DYLIB_COMPATIBILITY_VERSION = 1;
398 | DYLIB_CURRENT_VERSION = 1;
399 | DYLIB_INSTALL_NAME_BASE = "@rpath";
400 | GCC_C_LANGUAGE_STANDARD = gnu11;
401 | INFOPLIST_FILE = "StackGrid-iOS/Info.plist";
402 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
403 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
404 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
405 | PRODUCT_BUNDLE_IDENTIFIER = "lol.jonas.StackGrid-iOS";
406 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
407 | SKIP_INSTALL = YES;
408 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
409 | SWIFT_VERSION = 4.0;
410 | TARGETED_DEVICE_FAMILY = "1,2";
411 | VERSIONING_SYSTEM = "apple-generic";
412 | VERSION_INFO_PREFIX = "";
413 | };
414 | name = Debug;
415 | };
416 | 72DA113A1FC362260070FD93 /* Release */ = {
417 | isa = XCBuildConfiguration;
418 | buildSettings = {
419 | CLANG_ANALYZER_NONNULL = YES;
420 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
421 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
422 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
423 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
424 | CODE_SIGN_IDENTITY = "";
425 | CODE_SIGN_STYLE = Automatic;
426 | CURRENT_PROJECT_VERSION = 1;
427 | DEFINES_MODULE = YES;
428 | DYLIB_COMPATIBILITY_VERSION = 1;
429 | DYLIB_CURRENT_VERSION = 1;
430 | DYLIB_INSTALL_NAME_BASE = "@rpath";
431 | GCC_C_LANGUAGE_STANDARD = gnu11;
432 | INFOPLIST_FILE = "StackGrid-iOS/Info.plist";
433 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
434 | IPHONEOS_DEPLOYMENT_TARGET = 11.0;
435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
436 | PRODUCT_BUNDLE_IDENTIFIER = "lol.jonas.StackGrid-iOS";
437 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
438 | SKIP_INSTALL = YES;
439 | SWIFT_VERSION = 4.0;
440 | TARGETED_DEVICE_FAMILY = "1,2";
441 | VERSIONING_SYSTEM = "apple-generic";
442 | VERSION_INFO_PREFIX = "";
443 | };
444 | name = Release;
445 | };
446 | /* End XCBuildConfiguration section */
447 |
448 | /* Begin XCConfigurationList section */
449 | 722B1E461BA3F6CA0072E4B6 /* Build configuration list for PBXProject "StackGrid" */ = {
450 | isa = XCConfigurationList;
451 | buildConfigurations = (
452 | 722B1E711BA3F6CA0072E4B6 /* Debug */,
453 | 722B1E721BA3F6CA0072E4B6 /* Release */,
454 | );
455 | defaultConfigurationIsVisible = 0;
456 | defaultConfigurationName = Release;
457 | };
458 | 722B1E731BA3F6CA0072E4B6 /* Build configuration list for PBXNativeTarget "StackGrid" */ = {
459 | isa = XCConfigurationList;
460 | buildConfigurations = (
461 | 722B1E741BA3F6CA0072E4B6 /* Debug */,
462 | 722B1E751BA3F6CA0072E4B6 /* Release */,
463 | );
464 | defaultConfigurationIsVisible = 0;
465 | defaultConfigurationName = Release;
466 | };
467 | 72DA113D1FC362260070FD93 /* Build configuration list for PBXNativeTarget "StackGrid-iOS" */ = {
468 | isa = XCConfigurationList;
469 | buildConfigurations = (
470 | 72DA11391FC362260070FD93 /* Debug */,
471 | 72DA113A1FC362260070FD93 /* Release */,
472 | );
473 | defaultConfigurationIsVisible = 0;
474 | defaultConfigurationName = Release;
475 | };
476 | /* End XCConfigurationList section */
477 | };
478 | rootObject = 722B1E431BA3F6CA0072E4B6 /* Project object */;
479 | }
480 |
--------------------------------------------------------------------------------