-
Notifications
You must be signed in to change notification settings - Fork 53
fix: Fix crash after SDK initialization #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #369 +/- ##
==========================================
- Coverage 55.96% 55.88% -0.08%
==========================================
Files 136 136
Lines 6309 6327 +18
==========================================
+ Hits 3530 3535 +5
- Misses 2779 2792 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical crash during SDK initialization caused by force-unwrapping folder creation operations. The crash was occurring when CrowdinFolder.shared.createFolder() failed, causing the app to crash on launch as reported in issue #362.
Changes:
- Replaced
try!(force try) with optional try (try?) and fallback values for folder creation in three locations - Changed
LocalLocalizationStorageto fall back to the root CrowdinFolder when subfolder creation fails - Changed
XCStringsStorageto use lazy initialization with a fallback to root CrowdinFolder - Changed
RULocalLocalizationStorageto conditionally set the folder only if creation succeeds
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
Sources/CrowdinSDK/CrowdinSDK/Localization/Provider/LocalLocalizationStorage.swift |
Replaced force try with optional try and nil-coalescing fallback to CrowdinFolder.shared |
Sources/CrowdinSDK/Providers/Crowdin/LocalizationDownloader/Operations/CrowdinXcstringsDownloadOperation.swift |
Changed static property to use lazy initialization with optional try and fallback to CrowdinFolder.shared |
Sources/CrowdinSDK/Features/RealtimeUpdateFeature/LocalizationProvider/RULocalLocalizationStorage.swift |
Added conditional folder assignment instead of force try, falling back to parent class's folder |
...wdinSDK/Features/RealtimeUpdateFeature/LocalizationProvider/RULocalLocalizationStorage.swift
Outdated
Show resolved
Hide resolved
Sources/CrowdinSDK/CrowdinSDK/Localization/Provider/LocalLocalizationStorage.swift
Outdated
Show resolved
Hide resolved
.../Providers/Crowdin/LocalizationDownloader/Operations/CrowdinXcstringsDownloadOperation.swift
Outdated
Show resolved
Hide resolved
...wdinSDK/Features/RealtimeUpdateFeature/LocalizationProvider/RULocalLocalizationStorage.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Closes #362
Note
Low Risk
Small, localized change that primarily adds error handling and conditional cleanup around filesystem operations; risk is limited to fallback paths and deintegrate behavior.
Overview
Prevents crashes during SDK initialization by replacing several
try!calls that create localization subfolders (Crowdin, RealtimeUpdates, XCStrings) withdo/catch, logging failures and falling back toCrowdinFolder.shared.Tightens deintegration cleanup to avoid removing the Crowdin root folder when it’s being used as the active
localizationFolderfallback, reducing the chance of deleting shared storage unexpectedly.Written by Cursor Bugbot for commit 75652d3. This will update automatically on new commits. Configure here.