Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions ALL_FIXES_APPLIED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# ✅ All Fixes Applied!

**Status**: Module map, header, and framework search path are now correct.

---

## What Was Fixed

1. ✅ **Module Map Created**: `Bitkit/PipSDK/pipFFI.modulemap`
- Defines `PipUniFFI` module correctly

2. ✅ **Header Copied**: `Bitkit/PipSDK/pipFFI.h`
- Required for module map

3. ✅ **Framework Search Path Fixed**:
- Changed from: `$(SRCROOT)/../../sdk/pip-uniffi` ❌
- Changed to: `$(SRCROOT)/../pip/sdk/pip-uniffi` ✅

---

## Final Steps in Xcode

### 1. Add Files to Project (If Not Visible)

The files exist on disk, but Xcode needs to know about them:

1. **In Xcode**, check if `Bitkit/PipSDK/` appears in project navigator
2. **If NOT visible**:
- Right-click "Bitkit" folder
- "Add Files to Bitkit..."
- Navigate to `Bitkit/PipSDK/`
- Select both `pipFFI.h` and `pipFFI.modulemap`
- ✅ Check "Add to targets: Bitkit"
- ✅ Uncheck "Copy items if needed" (files are already there)
- Click "Add"

### 2. Clean and Rebuild

```
Cmd+Shift+K (Clean build folder)
Cmd+B (Build)
```

---

## Verify Everything

After rebuilding, check:

1. ✅ **No error** for `import PipUniFFI`
2. ✅ **Build succeeds**
3. ✅ **Module is found**

---

## If Still Not Working

### Check Framework Search Path

1. **Select "Bitkit" target**
2. **"Build Settings" tab → "All"**
3. **Search "Framework Search Paths"**
4. **Should show**: `$(SRCROOT)/../pip/sdk/pip-uniffi`

If it shows something else, update it manually.

### Check Files Are in Project

1. **Project Navigator** (left sidebar)
2. **Expand "Bitkit" → "PipSDK"**
3. **Should see**:
- `pipFFI.h`
- `pipFFI.modulemap`

If missing, add them (Step 1 above).

### Verify Framework is Linked

1. **"General" tab**
2. **"Frameworks, Libraries, and Embedded Content"**
3. **Should see**: `PipUniFFI.xcframework`

---

**All fixes are applied. Clean and rebuild in Xcode!** ✅

110 changes: 110 additions & 0 deletions Bitkit/AppDelegate_integration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
//
// AppDelegate Integration for PIP SDK
//
// Add these methods to your AppDelegate.swift
//

import UIKit
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

// Request notification permissions
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in
if granted {
DispatchQueue.main.async {
application.registerForRemoteNotifications()
}
} else if let error = error {
print("Notification permission error: \(error)")
}
}

// Initialize PIP background handler
let config = createPipConfig()
PipBackgroundHandler.shared.initialize(config: config)

return true
}

// MARK: - APNs Registration

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
print("APNs token: \(tokenString)")

// TODO: Send token to PIP receiver for push notifications
// Store in UserDefaults for now
UserDefaults.standard.set(tokenString, forKey: "apns_token")
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("Failed to register for remote notifications: \(error)")
}

// MARK: - Silent Push Handling

func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

print("Received remote notification")

// Delegate to PIP background handler
PipBackgroundHandler.shared.application(
application,
didReceiveRemoteNotification: userInfo,
fetchCompletionHandler: completionHandler
)
}

// MARK: - PIP Config

private func createPipConfig() -> PipConfig {
// Load or generate HMAC key
let sessionStore = PipSessionStore(config: PipConfig(
stateDir: getStateDir(),
esploraUrls: getEsploraUrls(),
useTor: false,
webhookHmacKey: [],
tofuMode: "DualPinGrace"
))

let hmacKey: Data
if let existingKey = sessionStore.loadHmacKey() {
hmacKey = existingKey
} else {
hmacKey = sessionStore.generateAndSaveHmacKey()
}

return PipConfig(
stateDir: getStateDir(),
esploraUrls: getEsploraUrls(),
useTor: false,
webhookHmacKey: [UInt8](hmacKey),
tofuMode: "DualPinGrace"
)
}

private func getStateDir() -> String {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsDirectory = paths[0]
let pipDir = documentsDirectory.appendingPathComponent("pip")

// Create directory if it doesn't exist
try? FileManager.default.createDirectory(at: pipDir, withIntermediateDirectories: true)

return pipDir.path
}

private func getEsploraUrls() -> [String] {
return [
"https://blockstream.info/api",
"https://mempool.space/api",
"https://mempool.emzy.de/api"
]
}
}
75 changes: 75 additions & 0 deletions Bitkit/PaykitIntegration/BUILD_CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Bitkit iOS - Paykit Integration Build Configuration

This guide explains how to configure the Bitkit iOS Xcode project to integrate PaykitMobile.

## Prerequisites

- Xcode 14.0 or later
- PaykitMobile XCFramework built (see `paykit-rs-master/paykit-mobile/BUILD.md`)
- Swift bindings generated

## Step 1: Add XCFramework to Project

1. Build the XCFramework:
```bash
cd paykit-rs-master/paykit-mobile
./build-ios.sh
```

2. Locate the generated XCFramework:
- `paykit-rs-master/paykit-mobile/PaykitMobile.xcframework/`

3. In Xcode, select the Bitkit project
4. Go to target "Bitkit" → General → "Frameworks, Libraries, and Embedded Content"
5. Click "+" and add `PaykitMobile.xcframework`
6. Set "Embed & Sign"

## Step 2: Add Swift Bindings

1. Locate generated Swift files:
- `paykit-rs-master/paykit-mobile/swift/generated/PaykitMobile.swift`
- `paykit-rs-master/paykit-mobile/swift/generated/PaykitMobileFFI.h`
- `paykit-rs-master/paykit-mobile/swift/generated/PaykitMobileFFI.modulemap`

2. Add to Xcode project:
- Right-click Bitkit project → Add Files
- Select the three files above
- Ensure "Copy items if needed" is checked
- Add to Bitkit target

## Step 3: Configure Build Settings

1. Select Bitkit target → Build Settings
2. Search for "Framework Search Paths"
3. Add: `$(PROJECT_DIR)/PaykitIntegration/Frameworks`
4. Search for "Library Search Paths"
5. Add: `$(PROJECT_DIR)/PaykitIntegration/Frameworks`

## Step 4: Verify Integration

1. Build the project (⌘+B)
2. Verify no compilation errors
3. Run tests to confirm PaykitManager initializes

## Troubleshooting

### Framework Not Found
- Ensure XCFramework is added to "Frameworks, Libraries, and Embedded Content"
- Check Framework Search Paths include XCFramework location

### Module Not Found
- Verify modulemap is in the correct location
- Check that Swift bindings are added to the target

### Link Errors
- Ensure XCFramework is set to "Embed & Sign"
- Clean build folder (⌘+Shift+K) and rebuild

## Verification Checklist

- [ ] XCFramework added to project
- [ ] Swift bindings added and compile
- [ ] Build settings configured
- [ ] Project builds successfully
- [ ] PaykitManager initializes without errors
- [ ] Tests pass
Loading
Loading