Skip to main content

Installation

Add the Bit2Connect iOS SDK to your Podfile:
Then run:
After installation, open the generated .xcworkspace file instead of the .xcodeproj file.

Swift Package Manager

  1. In Xcode, go to FileAdd Package Dependencies
  2. Enter the repository URL: https://github.com/bit2connect/bit2connect-ios-sdk.git
  3. Select Up to Next Major Version with 1.0.0
  4. Click Add Package
  5. Select your target and click Add Package

Option 2: Using Package.swift

Add the following to your Package.swift file:

Option 3: Command Line

Requirements

  • iOS 13.0+
  • Xcode 12.0+
  • Swift 5.0+

Setup

1. Initialize the SDK

Initialize the SDK in your AppDelegate:
Add deep link handling to your AppDelegate:

3. Configure URL Schemes

Add the following to your Info.plist:

4. Handle Navigation in View Controllers

Set up navigation handling in your view controllers:

API Reference

Bit2ConnectSDK

The main SDK class for handling dynamic links and deferred deep linking.

Methods

initialize(baseURL: String, apiKey: String, debugMode: Bool)
Initialize the Bit2Connect SDK with your API credentials. Parameters:
  • baseURL (String): The Bit2Connect API base URL
  • apiKey (String): Your Bit2Connect API key
  • debugMode (Bool): Enable debug logging
Example:
handleDeferredDeepLink(completion: @escaping (DeferredLinkResult) -> Void)
Handle deferred deep links when the app is launched. Parameters:
  • completion (Closure): Completion handler with result
Example:
handleDirectDeepLink(url: URL, completion: @escaping (DirectLinkResult) -> Void)
Handle direct deep links when the app is already installed. Parameters:
  • url (URL): The deep link URL to process
  • completion (Closure): Completion handler with result
Example:
createDynamicLink(data: DynamicLinkData, completion: @escaping (DynamicLinkResult) -> Void)
Create a new dynamic link with custom parameters. Parameters:
  • data (DynamicLinkData): The link data to create
  • completion (Closure): Completion handler with result
Example:

LinkData

Represents the data from a processed link.

Properties

  • originalUrl (String): The original URL that was processed
  • path (String): The path component of the URL
  • campaign (String?): The campaign parameter
  • source (String?): The source parameter
  • medium (String?): The medium parameter
  • content (String?): The content parameter
  • term (String?): The term parameter
  • parameters ([String: String]): Additional custom parameters

Advanced Configuration

You can customize how links are processed by implementing a custom link handler:

Analytics Integration

Track link performance and user engagement:

Testing

You can test your integration using the Bit2Connect dashboard or API:

Debug Mode

Enable debug logging to troubleshoot issues:

Best Practices

Error Handling

Always handle potential errors when processing dynamic links

User Experience

Provide fallback navigation for invalid or expired links

Security

Validate link data before processing to ensure security

Performance

Cache link data when appropriate to improve app performance

Choosing Between CocoaPods and Swift Package Manager

When to Use CocoaPods

  • Legacy Projects: If your project already uses CocoaPods
  • Team Preference: If your team is more familiar with CocoaPods
  • Complex Dependencies: When you need fine-grained control over dependency versions
  • CI/CD Integration: If your build pipeline is already configured for CocoaPods

When to Use Swift Package Manager

  • New Projects: For new iOS projects starting fresh
  • Apple Ecosystem: When you want to use Apple’s native package manager
  • Xcode Integration: For seamless integration with Xcode’s built-in package management
  • Cross-Platform: When building for multiple Apple platforms (iOS, macOS, watchOS, tvOS)
  • Modern Development: For projects using the latest Swift and Xcode features

Migration Guide

If you’re migrating from CocoaPods to Swift Package Manager:
  1. Remove CocoaPods:
  2. Add Swift Package Manager:
    • In Xcode: File → Add Package Dependencies
    • Enter: https://github.com/bit2connect/bit2connect-ios-sdk.git
    • Select version and add to target
  3. Update Import Statements:
  4. Test Your Integration:
    • Build and run your project
    • Test deep link functionality
    • Verify all features work as expected

Troubleshooting

Common Issues

Solution: Ensure you’re using the correct import syntax and that the package is properly added to your target. For Package.swift, use: swift dependencies: [.product(name: "Bit2ConnectSDK", package: "bit2connect-ios-sdk")]
Solution: Make sure your project’s iOS deployment target is 13.0 or higher, and that you’re using Swift 5.0+. Try cleaning your build folder and rebuilding.

Debug Tips

  1. Enable debug mode to see detailed logging
  2. Test with the Bit2Connect dashboard link tester
  3. Verify your app’s deep link configuration
  4. Check that your API key has the correct permissions
  5. Use Safari to test deep links by typing the URL directly
  6. For SPM issues: Check Package.swift syntax and target dependencies
  7. For build errors: Ensure iOS 13.0+ deployment target and Swift 5.0+
You can create dynamic links programmatically using the SDK:

Examples

E-commerce App

Social Media App