@leejungkiin/awkit 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,248 @@
1
+ ---
2
+ description: 🏗️ RE iOS Phase 2 — Data Layer, Utils, UI, SDK Integration & Parity Check
3
+ parent: reverse-ios
4
+ ---
5
+
6
+ # /re-ios-build — Build & Verify
7
+
8
+ > **Parent:** [`/reverse-ios`](reverse-ios.md) → Step 2-6
9
+ > **Prerequisite:** Hoàn thành [`/re-ios-scan`](reverse-ios-scan.md)
10
+ > **Skill:** `smali-to-swift` | **ObjC Guide:** `skills/smali-to-swift/objc-reading-guide.md`
11
+
12
+ ---
13
+
14
+ ## 💾 Step 2: Data Layer Reconstruction
15
+
16
+ > **Input:** Class-dump headers cho network, models, storage
17
+
18
+ ### 2.1: Models (ObjC → Swift Codable)
19
+
20
+ ```objc
21
+ // From class-dump
22
+ @interface UserModel : NSObject
23
+ @property (nonatomic, copy) NSString *userId;
24
+ @property (nonatomic, copy) NSString *fullName;
25
+ @end
26
+ ```
27
+
28
+ ```swift
29
+ struct User: Codable, Identifiable, Sendable {
30
+ let id: String
31
+ let fullName: String
32
+ enum CodingKeys: String, CodingKey {
33
+ case id = "user_id"
34
+ case fullName = "full_name"
35
+ }
36
+ }
37
+ ```
38
+
39
+ ### 2.2: API Client (URLSession async/await)
40
+
41
+ ```swift
42
+ actor APIClient {
43
+ func request<T: Decodable>(_ endpoint: Endpoint) async throws -> T {
44
+ var request = URLRequest(url: baseURL.appending(path: endpoint.path))
45
+ request.httpMethod = endpoint.method.rawValue
46
+ let (data, response) = try await session.data(for: request)
47
+ guard let http = response as? HTTPURLResponse,
48
+ (200...299).contains(http.statusCode) else {
49
+ throw APIError.invalidResponse
50
+ }
51
+ return try decoder.decode(T.self, from: data)
52
+ }
53
+ }
54
+ ```
55
+
56
+ ### 2.3: SwiftData (nếu app dùng Core Data / SQLite)
57
+
58
+ - `@Model` classes thay Core Data entities
59
+ - `@Attribute(.unique)` cho primary keys
60
+ - `ModelContext` cho CRUD operations
61
+
62
+ ### 2.4: Repository Pattern
63
+
64
+ - Protocol: `protocol UserRepository: Sendable`
65
+ - Implementation: offline-first (local → remote → cache)
66
+
67
+ ### ✅ Checkpoint Step 2
68
+
69
+ ---
70
+
71
+ ## 🧮 Step 3: Core Logic & Utils
72
+
73
+ > **CRITICAL:** Crypto output MUST match original
74
+
75
+ ### 3.1: Crypto utils → Swift
76
+
77
+ ```swift
78
+ import CryptoKit
79
+ import CommonCrypto
80
+
81
+ enum CryptoUtils {
82
+ static func md5(_ input: String) -> String {
83
+ let data = Data(input.utf8)
84
+ var digest = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH))
85
+ data.withUnsafeBytes { CC_MD5($0.baseAddress, CC_LONG(data.count), &digest) }
86
+ return digest.map { String(format: "%02x", $0) }.joined()
87
+ }
88
+ static func sha256(_ input: String) -> String {
89
+ SHA256.hash(data: Data(input.utf8))
90
+ .compactMap { String(format: "%02x", $0) }.joined()
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### 3.2: XCTest verification (BẮT BUỘC cho crypto)
96
+
97
+ ```swift
98
+ final class CryptoUtilsTests: XCTestCase {
99
+ func testMD5MatchesOriginal() {
100
+ XCTAssertEqual(CryptoUtils.md5("test"), "098f6bcd4621d373cade4e832627b4f6")
101
+ }
102
+ }
103
+ ```
104
+
105
+ ### ✅ Checkpoint Step 3
106
+
107
+ ---
108
+
109
+ ## 🎨 Step 4: UI & ViewModel (Per Screen — Loop)
110
+
111
+ > **Input:** Storyboard + VC headers + disassembly
112
+ > **Lặp lại** cho MỌI screen từ Step 1
113
+
114
+ ### 4.0: Thứ tự ưu tiên
115
+
116
+ 1. LaunchScreen → 2. Auth → 3. Main TabView → 4. Detail → 5. Settings
117
+
118
+ ### 4.1: Resource extraction (on-demand only)
119
+
120
+ Images, colors, strings, fonts — chỉ cho screen hiện tại.
121
+
122
+ ### 4.2: UIKit → SwiftUI
123
+
124
+ ```swift
125
+ struct LoginScreen: View {
126
+ @State private var viewModel: LoginViewModel
127
+ var body: some View {
128
+ NavigationStack {
129
+ ScrollView {
130
+ VStack(spacing: 24) {
131
+ TextField("Email", text: $viewModel.email)
132
+ SecureField("Password", text: $viewModel.password)
133
+ Button("Login") { Task { await viewModel.login() } }
134
+ .buttonStyle(.borderedProminent)
135
+ .disabled(viewModel.isLoading)
136
+ }
137
+ .padding()
138
+ }
139
+ .overlay { if viewModel.isLoading { ProgressView() } }
140
+ .alert("Error", isPresented: $viewModel.showError) { Button("OK") {} }
141
+ message: { Text(viewModel.errorMessage) }
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ ### 4.3: @Observable ViewModel
148
+
149
+ ```swift
150
+ @Observable
151
+ final class LoginViewModel {
152
+ var email = "", password = ""
153
+ var isLoading = false, showError = false, errorMessage = ""
154
+
155
+ private let authRepository: AuthRepository
156
+
157
+ func login() async {
158
+ isLoading = true
159
+ defer { isLoading = false }
160
+ do { try await authRepository.login(email: email, password: password) }
161
+ catch { errorMessage = error.localizedDescription; showError = true }
162
+ }
163
+ }
164
+ ```
165
+
166
+ ### ✅ Checkpoint Step 4 (Per Screen)
167
+
168
+ > **Loop:** Lặp 4.0 cho screen tiếp. Hết screen → Step 5.
169
+
170
+ ---
171
+
172
+ ## 📦 Step 5: SDK & Native Library Integration
173
+
174
+ ### 5.1: App entry point
175
+
176
+ ```swift
177
+ @main
178
+ struct MyApp: App {
179
+ @UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
180
+ var body: some Scene {
181
+ WindowGroup { ContentView() }
182
+ .modelContainer(for: [UserEntity.self])
183
+ }
184
+ }
185
+ ```
186
+
187
+ ### 5.2: AppDelegate (Firebase, Push)
188
+
189
+ ```swift
190
+ class AppDelegate: NSObject, UIApplicationDelegate {
191
+ func application(_ app: UIApplication,
192
+ didFinishLaunchingWithOptions opt: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
193
+ FirebaseApp.configure(); return true
194
+ }
195
+ }
196
+ ```
197
+
198
+ ### 5.3: Native C/C++ → Bridging Header
199
+
200
+ ```c
201
+ // App-Bridging-Header.h
202
+ #include "native_lib.h"
203
+ ```
204
+
205
+ ### ✅ Checkpoint Step 5
206
+
207
+ ---
208
+
209
+ ## ✅ Step 6: Parity Check & Quality Gate
210
+
211
+ ### 6.1: Edge Case checklist
212
+
213
+ ```markdown
214
+ - [ ] Login empty/invalid input
215
+ - [ ] Network offline → cached data?
216
+ - [ ] App background during API call
217
+ - [ ] Deep link handling
218
+ - [ ] Push notification → correct screen
219
+ ```
220
+
221
+ ### 6.2: Build & Test
222
+
223
+ ```bash
224
+ xcodebuild -scheme App -destination 'generic/platform=iOS' build
225
+ xcodebuild -scheme App -destination 'platform=iOS Simulator,name=iPhone 16' test
226
+ swiftlint lint
227
+ ```
228
+
229
+ ### 🎉 Final Summary
230
+
231
+ ```markdown
232
+ ## Complete!
233
+ - Screens: [count] | Frameworks reused: [count] | Replaced: [count]
234
+
235
+ ⏭️ Next: /test → /deploy → /code-janitor
236
+ ```
237
+
238
+ ---
239
+
240
+ ## 🔗 Related
241
+
242
+ - **Parent:** [`/reverse-ios`](reverse-ios.md)
243
+ - **Previous:** [`/re-ios-scan`](reverse-ios-scan.md) (Step 0-1)
244
+ - **ObjC Guide:** `skills/smali-to-swift/objc-reading-guide.md`
245
+
246
+ ---
247
+
248
+ *re-ios-build v2.0.0 — Phase 2: Build & Verify*
@@ -0,0 +1,155 @@
1
+ ---
2
+ description: 📦 RE iOS Phase 1 — Framework Scanner + Info.plist Analysis + Project Bootstrap
3
+ parent: reverse-ios
4
+ ---
5
+
6
+ # /re-ios-scan — Framework Scanner & Plist Analysis
7
+
8
+ > **Parent:** [`/reverse-ios`](reverse-ios.md) → Step 0 + Step 1
9
+ > **Skill:** `smali-to-swift` | **Reference:** `skills/smali-to-swift/framework-patterns.md`
10
+
11
+ ---
12
+
13
+ ## 📦 Step 0: Framework Scanner (BẮT BUỘC)
14
+
15
+ > Nhận diện toàn bộ frameworks **trước khi code bất kỳ thứ gì**.
16
+
17
+ ### 0.3: Quét IPA structure
18
+
19
+ ```bash
20
+ # Embedded frameworks
21
+ ls [app_bundle]/Frameworks/
22
+
23
+ # Linked libraries (Mach-O)
24
+ otool -L [app_bundle]/App | grep -v /System | grep -v /usr/lib
25
+
26
+ # Header imports
27
+ grep -rh "#import <" [headers_dir]/ | sort -u
28
+ grep -rh "@import " [headers_dir]/ | sort -u
29
+
30
+ # SDK identifiers
31
+ strings [app_bundle]/App | grep -i "cocoapods\|carthage\|firebase\|facebook\|google"
32
+
33
+ # Assets & resources
34
+ ls [app_bundle]/*.car [app_bundle]/*.momd [app_bundle]/*.storyboardc 2>/dev/null
35
+ find [app_bundle] -name "*.json" -o -name "*.plist" | grep -v Info.plist | sort
36
+ ```
37
+
38
+ ### 0.4: Tạo Framework Detection Report
39
+
40
+ Dùng patterns từ `framework-patterns.md`:
41
+
42
+ ```markdown
43
+ ## 📦 Framework Detection Report — [App Name]
44
+
45
+ ### ✅ Reuse (Add via SPM)
46
+ | Framework | Detected | Version | Notes |
47
+ |-----------|----------|---------|-------|
48
+
49
+ ### 🔄 Replace (Legacy → Modern Swift)
50
+ | Old Framework | Detected | Replacement |
51
+ |---------------|----------|-------------|
52
+ | AFNetworking | Frameworks/ | URLSession async/await |
53
+ | SDWebImage | imports | AsyncImage + Kingfisher |
54
+ | SnapKit | imports | SwiftUI layout |
55
+
56
+ ### 🍏 Apple Frameworks
57
+ | Framework | Purpose | SwiftUI Equivalent |
58
+ |-----------|---------|-------------------|
59
+ | MapKit | Maps | Map (SwiftUI) |
60
+ | CoreData | Database | SwiftData |
61
+
62
+ ### 📱 Native Libraries
63
+ | File | Notes |
64
+ |------|-------|
65
+
66
+ ### 🏷️ App Code (Rewrite in Swift)
67
+ | Class Prefix | Module |
68
+ |-------------|--------|
69
+
70
+ ### ❓ Unknown
71
+ | Framework | Notes |
72
+ |-----------|-------|
73
+ ```
74
+
75
+ ### 0.5: User approval
76
+
77
+ > **GATE:** Không tiếp tục khi chưa có user approval.
78
+
79
+ ---
80
+
81
+ ## 📄 Step 1: Info.plist & Entitlements + Project Bootstrap
82
+
83
+ > **Input:** `[app_bundle]/Info.plist` + entitlements
84
+
85
+ ### 1.1: Đọc Info.plist
86
+
87
+ ```bash
88
+ plutil -p [app_bundle]/Info.plist
89
+ codesign -d --entitlements :- [app_bundle]/App 2>/dev/null
90
+ ```
91
+
92
+ Trích xuất:
93
+
94
+ ```yaml
95
+ extract:
96
+ - bundle_id, display_name, min_ios_version
97
+ - permissions: [camera, photos, location, microphone, notifications, tracking]
98
+ - url_schemes, universal_links
99
+ - capabilities: [push, apple_pay, sign_in_apple, app_groups]
100
+ - supported_orientations
101
+ ```
102
+
103
+ ### 1.2: Phân tích class hierarchy
104
+
105
+ ```bash
106
+ grep -rl "UIViewController" [headers_dir]/ | sort
107
+ grep -rl "UITabBarController" [headers_dir]/
108
+ grep -rl "UINavigationController" [headers_dir]/
109
+ ```
110
+
111
+ Mapping VCs → SwiftUI:
112
+ ```
113
+ SplashViewController → SplashScreen.swift
114
+ LoginViewController → Auth/LoginScreen.swift
115
+ MainTabBarController → TabView in ContentView.swift
116
+ HomeViewController → Home/HomeScreen.swift
117
+ ```
118
+
119
+ ### 1.3: Xcode project structure
120
+
121
+ Đề xuất Clean Architecture structure (xem SKILL.md Step 1).
122
+
123
+ ### 1.4: SPM Dependencies (từ Framework Report)
124
+
125
+ ```swift
126
+ // Firebase: firebase/firebase-ios-sdk 11.0+
127
+ // Kingfisher: onevcat/Kingfisher 7.12+
128
+ // KeychainAccess: kishikawakatsumi/KeychainAccess 4.2+
129
+ // Lottie: airbnb/lottie-ios 4.4+
130
+ ```
131
+
132
+ ### ✅ Checkpoint Step 1
133
+
134
+ ```markdown
135
+ ## ✅ Step 1 Complete
136
+
137
+ - Bundle ID: [bundle_id]
138
+ - Permissions: [count] | Screens: [count]
139
+ - URL Schemes: [list]
140
+
141
+ ⏭️ Next: `/re-ios-build` — Step 2 (Data Layer)
142
+ Cung cấp headers: *Service, *Manager, *Client, *API, *Model
143
+ ```
144
+
145
+ ---
146
+
147
+ ## 🔗 Related
148
+
149
+ - **Next:** [`/re-ios-build`](reverse-ios-build.md) (Step 2-6)
150
+ - **Parent:** [`/reverse-ios`](reverse-ios.md)
151
+ - **Framework patterns:** `skills/smali-to-swift/framework-patterns.md`
152
+
153
+ ---
154
+
155
+ *re-ios-scan v2.0.0 — Phase 1: Discovery & Bootstrap*
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: 🍎 Dịch ngược IPA iOS (class-dump, Hopper output) → App Swift hiện đại với SwiftUI, Clean Architecture, và Framework Scanner tự động.
3
+ skill: smali-to-swift
4
+ ---
5
+
6
+ # /reverse-ios — iOS IPA Reverse Engineering Workflow
7
+
8
+ > **Skill:** `smali-to-swift` | **Tech:** Swift + SwiftUI + async/await + URLSession + SwiftData
9
+ > **Philosophy:** "Read ObjC headers to understand WHAT & WHY → Write Swift for HOW"
10
+ > **Sibling:** `/reverse-android`
11
+
12
+ ---
13
+
14
+ ## ⚡ QUICK START
15
+
16
+ User cung cấp: Decrypted `.app` bundle, class-dump headers, Hopper pseudo-code, hoặc nói "reverse engineer IPA này".
17
+ Workflow dẫn dắt từng bước — **không bao giờ nhảy cóc**.
18
+
19
+ ---
20
+
21
+ ## 🔵 Session Setup
22
+
23
+ ### Bước 0.1: Khởi tạo session state
24
+
25
+ ```yaml
26
+ reverse_ios_session:
27
+ project_name: "[TBD - từ Info.plist]"
28
+ app_bundle_dir: "[path]"
29
+ headers_dir: "[class-dump output]"
30
+ current_step: 0
31
+ framework_report_done: false
32
+ plist_analyzed: false
33
+ completed_screens: []
34
+ pending_screens: []
35
+ decisions: []
36
+ ```
37
+
38
+ ### Bước 0.2: Xác nhận input
39
+
40
+ ```
41
+ 🍎 iOS Reverse Engineering bắt đầu!
42
+
43
+ Em cần biết:
44
+ 1. Decrypted .app bundle ở đâu?
45
+ 2. Class-dump headers ở đâu?
46
+ 3. Tên app gốc? Bundle ID?
47
+
48
+ Chưa chuẩn bị?
49
+ → bagbak -o ~/decrypted/ com.example.app
50
+ → class-dump -H ~/decrypted/App.app -o ~/headers/
51
+ ```
52
+
53
+ ---
54
+
55
+ ## 📋 Pipeline Overview (7 Steps)
56
+
57
+ | Step | Phase | Sub-workflow | Gate |
58
+ |------|-------|-------------|------|
59
+ | 0 | 📦 Framework Scanner | [`/re-ios-scan`](reverse-ios-scan.md) | User approve report |
60
+ | 1 | 📄 Info.plist & Bootstrap | [`/re-ios-scan`](reverse-ios-scan.md) | Checkpoint |
61
+ | 2 | 💾 Data Layer | [`/re-ios-build`](reverse-ios-build.md) | Checkpoint |
62
+ | 3 | 🧮 Core Logic & Utils | [`/re-ios-build`](reverse-ios-build.md) | Checkpoint |
63
+ | 4 | 🎨 UI & ViewModel | [`/re-ios-build`](reverse-ios-build.md) | Per-screen loop |
64
+ | 5 | 📦 SDK Integration | [`/re-ios-build`](reverse-ios-build.md) | Checkpoint |
65
+ | 6 | ✅ Parity Check | [`/re-ios-build`](reverse-ios-build.md) | Final QA |
66
+
67
+ ### Execution Flow
68
+
69
+ ```
70
+ Session Setup → Step 0+1 (/re-ios-scan) → Step 2-6 (/re-ios-build)
71
+ ```
72
+
73
+ **Chạy tuần tự:** Xong `/re-ios-scan` → chuyển sang `/re-ios-build`.
74
+
75
+ ---
76
+
77
+ ## 🚫 WORKFLOW RULES
78
+
79
+ ```yaml
80
+ never_skip:
81
+ - Step 0 (Framework Scanner) — always first
82
+ - User approval of Framework Report
83
+ - Checkpoint after each step
84
+
85
+ never_do:
86
+ - Mass-copy assets from IPA
87
+ - Use UIKit when SwiftUI equivalent exists
88
+ - Use GCD for new async code (use async/await)
89
+ - Use ObjC in new code (Swift only, except bridging headers)
90
+ - Skip crypto parity testing
91
+
92
+ always_do:
93
+ - Document decisions in session state
94
+ - Present Framework Report before coding
95
+ - XCTest all crypto/hash functions
96
+ - Use @Observable for ViewModels (iOS 17+)
97
+ - Use NavigationStack for navigation
98
+ - Use SPM for all dependencies
99
+ ```
100
+
101
+ ---
102
+
103
+ ## 🔗 Related
104
+
105
+ - **Sub-workflows:** [`/re-ios-scan`](reverse-ios-scan.md) · [`/re-ios-build`](reverse-ios-build.md)
106
+ - **Skill:** `smali-to-swift` (core knowledge & rules)
107
+ - **Framework DB:** `skills/smali-to-swift/framework-patterns.md`
108
+ - **ObjC Guide:** `skills/smali-to-swift/objc-reading-guide.md`
109
+ - **Sibling:** `/reverse-android` (Android counterpart)
110
+ - **After RE done:** `/test`, `/deploy`, `/code-janitor`
111
+
112
+ ---
113
+
114
+ *reverse-ios workflow v2.0.0 — Modular RE Pipeline*