1. Initialize in App Init (Not in View)
Initialize the SDK at the app level to avoid blocking the UI and ensure it’s available throughout your application. ✅ Good:2. Use @ObservedObject for Reactive UI
Always use@ObservedObject to ensure your view automatically updates when the SDK state changes.
✅ Good:
@ObservedObject, changes to published properties won’t trigger view updates.
3. Use SBText for Auto-Updating Strings
Use theSBText component for any strings that should update when the language changes.
✅ Good:
SBText automatically handles language changes and network updates, while manual state requires additional synchronization logic.
4. Handle All Three SDK States
Always provide UI for loading, error, and ready states to create a smooth user experience. ✅ Good:5. Disable UI During Language Change
Prevent multiple language change requests by disabling the language picker during the operation. ✅ Good:6. Persist Language Selection
Save the user’s language preference so it’s restored on app restart. ✅ Good:7. Use forceRefresh Sparingly
Only force refresh when the user explicitly requests it, not automatically on every view appearance. ✅ Good:forceRefresh: true bypasses the ETag cache, which is expensive. Only use it when necessary.
8. Monitor Cache Health
Keep an eye on cache performance metrics to identify issues early. ✅ Good:Three-Layer Cache Architecture
Understanding the cache system helps you optimize your implementation:SBText and wait for isReady.
Error Handling Patterns
Handle Initialization Errors
Handle Language Change Errors
Disable UI During Language Change
Cache Management
Get Cache Statistics
Clear Cache
Refresh from Network
Offline-First Development
Test offline functionality to ensure your app works without network:- Launch app with network enabled → SDK syncs data
- Enable Airplane Mode
- Force quit and relaunch the app
- All strings load from cache instantly without network
Performance Targets
The SDK is optimized for these performance benchmarks:- In-memory cache hits: in less than 1ms
- Core Data lookups: 5-20ms
- Network requests: 100-500ms on 4G
- Delta sync metadata: in less than 100ms
- Target overall: in less than 300ms on 4G networks
Logging for Debugging
Enable detailed logging during development to understand SDK behavior:.debug- All SDK activity.info- Important operations.warning- Potential issues.error- Errors only
9. A/B Testing Best Practices
Use consistent device IDs and proper analytics integration for reliable A/B testing. ✅ Good:- Use persistent, installation-level device IDs (not session IDs)
- Set experiments as user properties in analytics (not events)
- Use the same device ID across all SDKs in your app
- Let SDK handle experiment assignment automatically
- Don’t manually assign users to variants
- Test experiment tracking in development before release
Testing Checklist
Before shipping to production:- Initialize SDK in app init (not in views)
- All views use
@ObservedObjectfor StringProvider - Use
SBTextfor all user-facing strings - Handle loading, error, and ready states
- Language picker disabled during language change
- Language selection persisted across app restarts
- Manual refresh uses
forceRefresh: truesparingly - Cache statistics monitored in development
- Offline functionality tested (Airplane Mode)
- Error cases tested and handled gracefully
- Logging disabled for production build
- A/B testing integration verified with analytics platform (if using experiments)