Skip to content

Commit 229dcbd

Browse files
author
pkh0225
committed
폴더 네이밍 변경
폴더 네이밍 변경
1 parent 6a85e33 commit 229dcbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+398
-96
lines changed

Example-iOS/TestSwiftHelper.xcodeproj/project.pbxproj

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
200019CB2C9D0B9D00E2094A /* MemoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 200019CA2C9D0B9D00E2094A /* MemoryViewController.swift */; };
1111
200019CF2C9D2CAC00E2094A /* ScopeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 200019CE2C9D2CAC00E2094A /* ScopeViewController.swift */; };
1212
200EB4BD2CEDC0BD0011BD7B /* SwiftHelper in Frameworks */ = {isa = PBXBuildFile; productRef = 200EB4BC2CEDC0BD0011BD7B /* SwiftHelper */; };
13+
2058367A2D226AD50069323D /* DeinitChecker in Frameworks */ = {isa = PBXBuildFile; productRef = 205836792D226AD50069323D /* DeinitChecker */; };
1314
520F389721229A890081B956 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520F389621229A890081B956 /* AppDelegate.swift */; };
1415
520F389921229A890081B956 /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 520F389821229A890081B956 /* TestViewController.swift */; };
1516
520F389C21229A890081B956 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 520F389A21229A890081B956 /* Main.storyboard */; };
@@ -39,6 +40,7 @@
3940
buildActionMask = 2147483647;
4041
files = (
4142
200EB4BD2CEDC0BD0011BD7B /* SwiftHelper in Frameworks */,
43+
2058367A2D226AD50069323D /* DeinitChecker in Frameworks */,
4244
);
4345
runOnlyForDeploymentPostprocessing = 0;
4446
};
@@ -112,6 +114,7 @@
112114
name = TestSwiftHelper;
113115
packageProductDependencies = (
114116
200EB4BC2CEDC0BD0011BD7B /* SwiftHelper */,
117+
205836792D226AD50069323D /* DeinitChecker */,
115118
);
116119
productName = Test;
117120
productReference = 520F389321229A890081B956 /* TestSwiftHelper.app */;
@@ -123,8 +126,9 @@
123126
520F388B21229A890081B956 /* Project object */ = {
124127
isa = PBXProject;
125128
attributes = {
129+
BuildIndependentTargetsInParallel = YES;
126130
LastSwiftUpdateCheck = 0940;
127-
LastUpgradeCheck = 1410;
131+
LastUpgradeCheck = 1610;
128132
ORGANIZATIONNAME = pkh;
129133
TargetAttributes = {
130134
520F389221229A890081B956 = {
@@ -144,6 +148,7 @@
144148
mainGroup = 520F388A21229A890081B956;
145149
packageReferences = (
146150
200EB4BB2CEDC0BD0011BD7B /* XCLocalSwiftPackageReference "../../SwiftHelper" */,
151+
205836782D226AAA0069323D /* XCRemoteSwiftPackageReference "DeinitChecker" */,
147152
);
148153
productRefGroup = 520F389421229A890081B956 /* Products */;
149154
projectDirPath = "";
@@ -241,6 +246,7 @@
241246
DEBUG_INFORMATION_FORMAT = dwarf;
242247
ENABLE_STRICT_OBJC_MSGSEND = YES;
243248
ENABLE_TESTABILITY = YES;
249+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
244250
GCC_C_LANGUAGE_STANDARD = gnu11;
245251
GCC_DYNAMIC_NO_PIC = NO;
246252
GCC_NO_COMMON_BLOCKS = YES;
@@ -304,6 +310,7 @@
304310
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
305311
ENABLE_NS_ASSERTIONS = NO;
306312
ENABLE_STRICT_OBJC_MSGSEND = YES;
313+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
307314
GCC_C_LANGUAGE_STANDARD = gnu11;
308315
GCC_NO_COMMON_BLOCKS = YES;
309316
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -343,7 +350,7 @@
343350
PROVISIONING_PROFILE_SPECIFIER = "";
344351
SWIFT_OBJC_BRIDGING_HEADER = "";
345352
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
346-
SWIFT_VERSION = 6.0;
353+
SWIFT_VERSION = 5.0;
347354
TARGETED_DEVICE_FAMILY = "1,2";
348355
_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES;
349356
};
@@ -368,7 +375,7 @@
368375
PRODUCT_NAME = "$(TARGET_NAME)";
369376
PROVISIONING_PROFILE_SPECIFIER = "";
370377
SWIFT_OBJC_BRIDGING_HEADER = "";
371-
SWIFT_VERSION = 6.0;
378+
SWIFT_VERSION = 5.0;
372379
TARGETED_DEVICE_FAMILY = "1,2";
373380
_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES;
374381
};
@@ -404,11 +411,27 @@
404411
};
405412
/* End XCLocalSwiftPackageReference section */
406413

414+
/* Begin XCRemoteSwiftPackageReference section */
415+
205836782D226AAA0069323D /* XCRemoteSwiftPackageReference "DeinitChecker" */ = {
416+
isa = XCRemoteSwiftPackageReference;
417+
repositoryURL = "https://github.com/pkh0225/DeinitChecker.git";
418+
requirement = {
419+
kind = upToNextMajorVersion;
420+
minimumVersion = 1.0.0;
421+
};
422+
};
423+
/* End XCRemoteSwiftPackageReference section */
424+
407425
/* Begin XCSwiftPackageProductDependency section */
408426
200EB4BC2CEDC0BD0011BD7B /* SwiftHelper */ = {
409427
isa = XCSwiftPackageProductDependency;
410428
productName = SwiftHelper;
411429
};
430+
205836792D226AD50069323D /* DeinitChecker */ = {
431+
isa = XCSwiftPackageProductDependency;
432+
package = 205836782D226AAA0069323D /* XCRemoteSwiftPackageReference "DeinitChecker" */;
433+
productName = DeinitChecker;
434+
};
412435
/* End XCSwiftPackageProductDependency section */
413436
};
414437
rootObject = 520F388B21229A890081B956 /* Project object */;

Example-iOS/TestSwiftHelper.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example-iOS/TestSwiftHelper/AppDelegate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import UIKit
10+
import SwiftHelper
1011

1112
@main
1213
class AppDelegate: UIResponder, UIApplicationDelegate {
@@ -15,8 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1516

1617

1718
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
18-
UIViewController.swizzleMethodForDealloc()
19-
UIView.enableBorderLayerSwizzling()
19+
// UIView.enableBorderLayerSwizzling()
2020
return true
2121
}
2222

Example-iOS/TestSwiftHelper/VC/MemoryViewController.swift

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,46 @@
88

99
import UIKit
1010
import SwiftHelper
11+
import DeinitChecker
1112

12-
class MemoryViewController: UIViewController, RouterProtocol {
13+
class MemoryViewController: UIViewController, RouterProtocol, DeinitChecker {
14+
var deinitNotifier: DeinitNotifier?
15+
1316
static var storyboardName: String = ""
1417

15-
class AAA {
18+
class AAA: DeinitChecker {
19+
var deinitNotifier: DeinitNotifier?
1620

1721
var bbb: BBB?
1822

19-
deinit {
20-
print("\(#function) \(Self.self)")
23+
init () {
24+
setDeinitNotifier()
2125
}
2226
}
23-
class BBB {
27+
class BBB: DeinitChecker {
28+
var deinitNotifier: DeinitNotifier?
2429

2530
var array = [WeakWrapper<AAA>]()
2631
// var array = [AAA]()
27-
28-
deinit {
29-
print("\(#function) \(Self.self)")
32+
init () {
33+
setDeinitNotifier()
3034
}
3135
}
3236

3337
var testDataa: AAA?
34-
38+
var test2VC: Test2ViewController!
3539

3640
override func viewDidLoad() {
3741
super.viewDidLoad()
3842
self.title = "Memory"
3943
self.view.backgroundColor = .white
44+
DeinitManager.shared.isRun = true
45+
46+
setDeinitNotifier()
4047

41-
let btn = TestButton(frame: CGRect(x: 100, y: 100, width: 100, height: 100)).apply { obj in
42-
obj.setTitle("click", for: .normal)
48+
let btn = TestButton(frame: CGRect(x: 100, y: 100, width: 200, height: 100)).apply { [weak self] obj in
49+
guard let self else { return }
50+
obj.setTitle("WeakWrapper test", for: .normal)
4351
obj.backgroundColor = .green
4452
obj.addAction(for: .touchUpInside) { [weak self] btn in
4553
guard let self else { return }
@@ -56,33 +64,87 @@ class MemoryViewController: UIViewController, RouterProtocol {
5664

5765

5866
self.testDataa = a
67+
68+
69+
let v = TestView(frame: CGRect(x: 10, y: 210, w: 250, h: 100))
70+
v.backgroundColor = .red
71+
self.view.addSubview(v)
72+
73+
let btn2 = TestButton(frame: v.bounds).apply {
74+
$0.setTitle("push New ViewController", for: .normal)
75+
$0.addAction(for: .touchUpInside) { _ in
76+
Self.pushViewController()
77+
// print(self)
78+
// print(v)
79+
}
80+
}
81+
v.addSubview(btn2)
82+
83+
test2VC = Test2ViewController()
84+
self.addChild(test2VC)
85+
self.view.addSubview(test2VC.view)
86+
test2VC.view.frame = CGRect(x: 100, y: 350, width: 200, height: 100)
87+
5988
}
89+
90+
// override func viewWillDisappear(_ animated: Bool) {
91+
// super.viewWillDisappear(animated)
92+
//
93+
// if self.isMovingFromParent {
94+
// print("------- is being popped")
95+
// // 여기서 pop 이벤트 처리
96+
//
97+
//
98+
// }
99+
// }
60100
}
61101

62-
extension UIViewController {
63-
private struct AssociatedKeys {
64-
nonisolated(unsafe) static var deallocator: UInt8 = 0
102+
class Test2ViewController: UIViewController, DeinitChecker {
103+
var deinitNotifier: DeinitNotifier?
104+
105+
override func viewDidLoad() {
106+
super.viewDidLoad()
107+
setDeinitNotifier()
108+
view.backgroundColor = .blue
109+
110+
let button = TestButton()
111+
button.frame = self.view.bounds
112+
button.autoresizingMask = [.flexibleWidth, .flexibleHeight]
113+
button.setTitle("Test2ViewController", for: .normal)
114+
button.addAction(for: .touchUpInside) { _ in
115+
alert(title: "", message: "Test2ViewController")
116+
// print(self)
117+
}
118+
view.addSubview(button)
65119
}
120+
}
121+
122+
class TestButton: UIButton, DeinitChecker {
123+
var deinitNotifier: DeinitNotifier?
66124

67-
class func swizzleMethodForDealloc() {
68-
let originalSelector = #selector(viewDidLoad)
69-
let swizzledSelector = #selector(swizzled_viewDidLoad)
70-
guard
71-
let originalMethod = class_getInstanceMethod(Self.self, originalSelector),
72-
let swizzledMethod = class_getInstanceMethod(Self.self, swizzledSelector)
73-
else { return }
74-
method_exchangeImplementations(originalMethod, swizzledMethod)
125+
override init(frame: CGRect) {
126+
super.init(frame: frame)
127+
setDeinitNotifier()
75128
}
76129

77-
@objc private func swizzled_viewDidLoad() {
78-
let deallocator = Deallocator { print("swizzled deinit: \(Self.self)") }
79-
objc_setAssociatedObject(self, &AssociatedKeys.deallocator, deallocator, .OBJC_ASSOCIATION_RETAIN)
130+
required init?(coder: NSCoder) {
131+
super.init(coder: coder)
132+
setDeinitNotifier()
80133
}
81134
}
82135

136+
class TestView: UIView , DeinitChecker {
137+
var deinitNotifier: DeinitNotifier?
138+
139+
override init(frame: CGRect) {
140+
super.init(frame: frame)
141+
setDeinitNotifier()
142+
}
83143

84-
class TestButton: UIButton {
85-
deinit {
86-
print("\(#function) \(Self.self)")
144+
required init?(coder: NSCoder) {
145+
super.init(coder: coder)
146+
setDeinitNotifier()
87147
}
88148
}
149+
150+

0 commit comments

Comments
 (0)