Swift Troubleshooting Guide

This guide addresses common issues you might encounter when integrating Para with your Swift iOS application. It provides solutions and best practices to ensure a smooth integration.

General Troubleshooting Steps

Before diving into specific issues, try these general troubleshooting steps:

  1. Clean the build folder: In Xcode, go to Product > Clean Build Folder

  2. Update dependencies: If you’re using CocoaPods:

    pod update
    

    If you’re using Swift Package Manager, update packages in Xcode.

  3. Ensure Para SDK is up to date: Check your Podfile or Swift Package Manager configuration and update to the latest version if necessary.

  4. Rebuild the project: In Xcode, go to Product > Build

Common Issues and Solutions

1. Package Integration Issues

Problem: Xcode can’t find the Para package or there are integration errors.

Solution: Ensure the Para SDK is properly integrated into your project.

For Swift Package Manager:

  1. In Xcode, go to File > Swift Packages > Add Package Dependency
  2. Enter the Para SDK repository URL
  3. Select the version you want to use

For CocoaPods:

  1. Ensure your Podfile includes:
    pod 'ParaSwift'
    
  2. Run pod install in your terminal
  3. Use the .xcworkspace file to open your project

2. Minimum iOS Version Incompatibility

Problem: Compiler errors due to unsupported iOS version.

Solution: Ensure your project’s minimum deployment target is compatible with Para SDK.

  1. In Xcode, select your project in the navigator
  2. Go to the “General” tab
  3. Under “Deployment Info”, set “Minimum Deployments” to iOS 13.0 or later (or the minimum version required by Para)

3. Initialization Errors

Problem: Para fails to initialize or throws errors on startup.

Solution: Ensure proper initialization in your AppDelegate or SceneDelegate:

import ParaSwift

class AppDelegate: UIResponder, UIApplicationDelegate {
    let para = ParaSwift.Para(environment: .beta(jsBridgeUrl: nil), apiKey: "YOUR_API_KEY")

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    // ... other AppDelegate methods
}

4. Asynchronous Operation Errors

Problem: Errors when performing asynchronous operations with Para.

Solution: Ensure proper use of Swift concurrency (async/await) and error handling:

func createUser(email: String) async {
    do {
        try await para.createUser({email: email})
        // Handle successful user creation
    } catch {
        print("Error creating user: \(error)")
        // Handle error appropriately
    }
}

5. UI Thread Blocking

Problem: Para operations blocking the main thread.

Solution: Ensure all Para operations are performed on background threads:

DispatchQueue.global(qos: .userInitiated).async {
    Task {
        do {
            let wallet = try await self.para.createWallet()
            // Handle wallet creation
            DispatchQueue.main.async {
                // Update UI
            }
        } catch {
            print("Error: \(error)")
        }
    }
}

6. Keychain Access Issues

Problem: Errors related to keychain access for storing sensitive data.

Solution: Ensure proper keychain access and entitlements:

  1. In your project’s Capabilities tab, enable “Keychain Sharing”
  2. If necessary, add a keychain access group in your entitlements file

Problem: Network calls failing or timing out.

Solution: Ensure proper network permissions and handling:

  1. Add the following to your Info.plist:
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    
  2. Implement proper network reachability checks and error handling

Best Practices

  1. Use the Latest Versions: Always use the latest versions of Xcode, Swift, and Para SDK to ensure compatibility and access to the latest features.

  2. Error Handling: Implement robust error handling for all Para operations. Use Swift’s do-catch blocks and custom error types if necessary.

  3. Secure Storage: Use Keychain Services for storing sensitive data related to Para operations.

  4. Concurrency: Leverage Swift’s concurrency features (async/await) for cleaner asynchronous code.

  5. Memory Management: Be mindful of retain cycles, especially when using closures with Para operations.

  6. Testing: Write unit and integration tests for your Para integration to catch issues early. Use XCTest framework for testing.

  7. Localization: If your app supports multiple languages, ensure all user-facing strings related to Para are properly localized.

  8. App Transport Security: Ensure your app’s ATS settings are configured correctly for Para’s network communications.

Debugging Tips

  1. Enable Verbose Logging: If available, enable verbose logging for Para operations to get more detailed information.

  2. Use Breakpoints: Set breakpoints in your Para integration code to step through and identify issues.

  3. Network Debugging: Use tools like Charles Proxy or Xcode’s network debugger to inspect network calls made by Para.

  4. Memory Debugging: Use Xcode’s Memory Graph Debugger to identify any memory leaks or retain cycles involving Para objects.

  5. Simulator vs Real Device: Test your Para integration on both the iOS Simulator and real devices, as some issues may only appear on physical devices.

By following these troubleshooting steps and best practices, you should be able to resolve most common issues when integrating Para with your Swift iOS application.

Integration Support

If you’re experiencing issues that aren’t resolved by our troubleshooting resources, please contact our team for assistance. To help us resolve your issue quickly, please include the following information in your request:

  1. 1

    A detailed description of the problem you’re encountering.

  2. 2

    Any relevant error messages or logs.

  3. 3

    Steps to reproduce the issue.

  4. 4

    Details about your system or environment (e.g., device, operating system, software version).

Providing this information will enable our team to address your concerns more efficiently.