Installation
CocoaPods (Recommended)
Add the Bit2Connect iOS SDK to yourPodfile:
.xcworkspace file instead of the .xcodeproj file.
Swift Package Manager
Option 1: Using Xcode (Recommended)
- In Xcode, go to File → Add Package Dependencies
- Enter the repository URL:
https://github.com/bit2connect/bit2connect-ios-sdk.git - Select Up to Next Major Version with 1.0.0
- Click Add Package
- Select your target and click Add Package
Option 2: Using Package.swift
Add the following to yourPackage.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:2. Configure Deep Link Handling
Add deep link handling to your AppDelegate:3. Configure URL Schemes
Add the following to yourInfo.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 URLapiKey(String): Your Bit2Connect API keydebugMode(Bool): Enable debug logging
handleDeferredDeepLink(completion: @escaping (DeferredLinkResult) -> Void)
Handle deferred deep links when the app is launched.
Parameters:
completion(Closure): Completion handler with result
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 processcompletion(Closure): Completion handler with result
createDynamicLink(data: DynamicLinkData, completion: @escaping (DynamicLinkResult) -> Void)
Create a new dynamic link with custom parameters.
Parameters:
data(DynamicLinkData): The link data to createcompletion(Closure): Completion handler with result
LinkData
Represents the data from a processed link.Properties
originalUrl(String): The original URL that was processedpath(String): The path component of the URLcampaign(String?): The campaign parametersource(String?): The source parametermedium(String?): The medium parametercontent(String?): The content parameterterm(String?): The term parameterparameters([String: String]): Additional custom parameters
Advanced Configuration
Custom Link Handling
You can customize how links are processed by implementing a custom link handler:Analytics Integration
Track link performance and user engagement:Testing
Test Dynamic Links
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:-
Remove CocoaPods:
-
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
-
Update Import Statements:
-
Test Your Integration:
- Build and run your project
- Test deep link functionality
- Verify all features work as expected
Troubleshooting
Common Issues
Links not being received
Links not being received
Solution: Ensure your app is properly configured for deep linking and
the SDK is initialized before handling links.
iOS links not working
iOS links not working
Solution: Verify that your iOS app’s URL scheme is correctly configured in
Info.plist and that the app is properly signed.
App not opening from links
App not opening from links
Solution: Check that your app is properly configured as a URL scheme
handler and that the links are correctly formatted.
Swift Package Manager import errors
Swift Package Manager import errors
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")] Build errors with SPM
Build errors with SPM
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
- Enable debug mode to see detailed logging
- Test with the Bit2Connect dashboard link tester
- Verify your app’s deep link configuration
- Check that your API key has the correct permissions
- Use Safari to test deep links by typing the URL directly
- For SPM issues: Check Package.swift syntax and target dependencies
- For build errors: Ensure iOS 13.0+ deployment target and Swift 5.0+