Skip to content

Commit c0a9eba

Browse files
authored
Merge pull request #305 from wmathurin/sqlcipher-4.16
Update SQLCipher to 4.16.0
2 parents 9abe340 + 32f0f24 commit c0a9eba

4 files changed

Lines changed: 355 additions & 3 deletions

File tree

Lines changed: 352 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,352 @@
1+
---
2+
skill: sqlcipher-update
3+
description: Update SQLCipher dependency in Salesforce Mobile SDK for iOS Hybrid
4+
globs:
5+
- "*.podspec"
6+
- "external/SalesforceMobileSDK-iOS"
7+
tags:
8+
- dependency-update
9+
- sqlcipher
10+
- encryption
11+
- smartstore
12+
- hybrid
13+
---
14+
15+
# Update SQLCipher Skill (iOS Hybrid)
16+
17+
This skill automates the process of updating the SQLCipher library version in the SalesforceMobileSDK-iOS-Hybrid project.
18+
19+
## When to Use
20+
Use this skill when you need to:
21+
- Update SQLCipher to a newer version for security patches or new features
22+
- Sync with SQLCipher updates in the iOS native SDK
23+
- Track changes in SQLCipher's OpenSSL provider version
24+
25+
## Background
26+
The iOS Hybrid SDK depends on the iOS native SDK (included as a git submodule) which contains SmartStore with SQLCipher support. The hybrid SDK doesn't directly depend on SQLCipher but inherits it through the MobileSync dependency in its podspec.
27+
28+
## Parameters
29+
- `NEW_VERSION`: The new SQLCipher version (e.g., "4.15.0", "4.16.0")
30+
- `OLD_VERSION`: The current SQLCipher version (check iOS submodule)
31+
- `NEW_PROVIDER_VERSION`: The cipher provider version bundled with the new SQLCipher (check SQLCipher release notes)
32+
33+
## Prerequisite
34+
- iOS submodule must have the SQLCipher update completed first
35+
- The iOS submodule branch (e.g., `sqlcipher-4.16`) should exist and be ready
36+
37+
## Process
38+
39+
### 1. Research the New Version
40+
41+
Before starting, check the SQLCipher release notes:
42+
- Visit: https://github.com/sqlcipher/sqlcipher/releases
43+
- Review changes, breaking changes, and new features
44+
- Note the provider version included (important for tests)
45+
- Check the iOS native SDK repository for the SQLCipher update PR/branch
46+
47+
**Key things to look for:**
48+
- Changes already handled in the iOS native SDK
49+
- Any hybrid-specific implications
50+
- Security fixes or enhancements
51+
- Changes to encryption algorithms or key derivation
52+
53+
### 2. Update iOS Submodule Reference
54+
55+
The iOS Hybrid SDK includes the iOS native SDK as a git submodule at `external/SalesforceMobileSDK-iOS`.
56+
57+
**Check current submodule status:**
58+
```bash
59+
cd /path/to/SalesforceMobileSDK-iOS-Hybrid
60+
git submodule status
61+
```
62+
63+
**Update the submodule to the new SQLCipher branch:**
64+
```bash
65+
cd external/SalesforceMobileSDK-iOS
66+
git fetch origin
67+
git checkout origin/sqlcipher-4.16 # or appropriate branch
68+
cd ../..
69+
git add external/SalesforceMobileSDK-iOS
70+
```
71+
72+
The submodule will now point to the iOS SDK commit with the SQLCipher update.
73+
74+
### 3. Update Swift Package Manager Dependencies
75+
76+
**CRITICAL:** The workspace and sample apps use Swift Package Manager for SQLCipher dependencies. These must be updated to match the iOS submodule version.
77+
78+
#### 3.1. Update Workspace Package.resolved
79+
80+
Update `SalesforceMobileSDK-Hybrid.xcworkspace/xcshareddata/swiftpm/Package.resolved`:
81+
82+
```json
83+
{
84+
"identity" : "sqlcipher.swift",
85+
"kind" : "remoteSourceControl",
86+
"location" : "https://github.com/sqlcipher/SQLCipher.swift",
87+
"state" : {
88+
"revision" : "<COMMIT_HASH>", // Get from SQLCipher tag
89+
"version" : "4.16.0" // Update to new version
90+
}
91+
}
92+
```
93+
94+
**To find the correct commit hash:**
95+
```bash
96+
git clone --depth=1 --branch 4.16.0 https://github.com/sqlcipher/SQLCipher.swift /tmp/sqlcipher-check
97+
cd /tmp/sqlcipher-check
98+
git log -1 --format="%H"
99+
```
100+
101+
#### 3.2. Update Sample App Project Files
102+
103+
Both sample apps have direct SQLCipher package references that must be updated:
104+
105+
**MobileSyncExplorerHybrid:**
106+
Edit `hybrid/SampleApps/MobileSyncExplorerHybrid/MobileSyncExplorerHybrid.xcodeproj/project.pbxproj`:
107+
108+
Find the section `XCRemoteSwiftPackageReference "SQLCipher"` and update:
109+
```
110+
requirement = {
111+
kind = exactVersion;
112+
version = 4.16.0; // Update from 4.15.0
113+
};
114+
```
115+
116+
**AccountEditor:**
117+
Edit `hybrid/SampleApps/AccountEditor/AccountEditor.xcodeproj/project.pbxproj`:
118+
119+
Find the section `XCRemoteSwiftPackageReference "SQLCipher"` and update:
120+
```
121+
requirement = {
122+
kind = exactVersion;
123+
version = 4.16.0; // Update from 4.15.0
124+
};
125+
```
126+
127+
**Why this is needed:** The sample apps declare exact SQLCipher versions in their project files. If these don't match the iOS submodule's version, Xcode's package resolution will fail with:
128+
```
129+
Could not resolve package dependencies:
130+
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'sqlcipher.swift' 4.16.0 and root depends on 'sqlcipher.swift' 4.15.0.
131+
```
132+
133+
### 4. Verify Podspec Dependencies
134+
135+
Check `SalesforceHybridSDK.podspec`:
136+
137+
```ruby
138+
s.subspec 'SalesforceHybridSDK' do |sdkhybrid|
139+
sdkhybrid.dependency 'MobileSync', "~>#{s.version}"
140+
sdkhybrid.dependency 'Cordova', '7.1.1'
141+
# ... other dependencies
142+
end
143+
```
144+
145+
The hybrid SDK depends on `MobileSync` from the iOS SDK, which transitively depends on SmartStore and SQLCipher. No direct SQLCipher dependency should be needed here.
146+
147+
**Important:** The iOS SDK's podspec (SmartStore.podspec) should already have the updated SQLCipher dependency. The hybrid SDK inherits it.
148+
149+
### 5. Build the Hybrid SDK
150+
151+
Build the SalesforceHybridSDK library to catch compilation issues:
152+
153+
```bash
154+
xcodebuild -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
155+
-scheme SalesforceHybridSDK \
156+
-sdk iphonesimulator \
157+
build
158+
```
159+
160+
Address any compilation errors related to:
161+
- Changes in the iOS SDK that affect hybrid code
162+
- Header import changes
163+
- API changes in MobileSync or SmartStore
164+
- Cordova plugin compatibility
165+
166+
### 6. Run Hybrid SDK Tests
167+
168+
**CRITICAL**: Full SalesforceHybridSDK test suite must pass before proceeding.
169+
170+
```bash
171+
xcodebuild test -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
172+
-scheme SalesforceHybridSDK \
173+
-sdk iphonesimulator \
174+
-destination 'platform=iOS Simulator,name=iPhone 16'
175+
```
176+
177+
**Key tests to verify:**
178+
- Hybrid authentication and session management
179+
- Cordova plugin functionality (OAuth, SmartStore, MobileSync, Network)
180+
- SmartStore operations through hybrid plugins
181+
- MobileSync operations through hybrid plugins
182+
- WebView cookie management with encrypted storage
183+
184+
**Common test failures:**
185+
- Cordova plugin bridge issues if iOS SDK API changed
186+
- SmartStore plugin errors if encryption behavior changed
187+
- Session management issues if OAuth/identity flow changed
188+
189+
If tests fail:
190+
- Check if the iOS SDK introduced API changes affecting hybrid plugins
191+
- Review Cordova plugin implementations in `libs/SalesforceHybridSDK/SalesforceHybridSDK/Classes/Plugins/`
192+
- Compare behavior with the iOS SDK's SmartStore tests
193+
194+
### 7. Verify Sample Apps
195+
196+
Test the hybrid sample applications:
197+
198+
```bash
199+
# Build AccountEditor sample
200+
xcodebuild -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
201+
-scheme AccountEditor \
202+
-sdk iphonesimulator \
203+
build
204+
205+
# Build MobileSyncExplorerHybrid sample
206+
xcodebuild -workspace SalesforceMobileSDK-Hybrid.xcworkspace \
207+
-scheme MobileSyncExplorerHybrid \
208+
-sdk iphonesimulator \
209+
build
210+
```
211+
212+
Run the sample apps on a simulator to ensure:
213+
- App launches successfully
214+
- Authentication works
215+
- SmartStore operations function correctly
216+
- MobileSync operations function correctly
217+
218+
### 8. Check Cross-Platform Consistency
219+
220+
Since this is a hybrid SDK:
221+
- Verify the Android hybrid SDK has the corresponding SQLCipher update
222+
- Check the Shared repo for any JavaScript changes needed
223+
- Ensure CordovaPlugin repo is aware of the update (will need `tools/update.sh` run)
224+
225+
### 9. Create Pull Request
226+
227+
When creating the PR:
228+
- **Branch name:** `sqlcipher-4.16` (or appropriate version)
229+
- **Title:** "Update SQLCipher to {NEW_VERSION}" or "Update iOS submodule for SQLCipher {NEW_VERSION}"
230+
- **Description:** Include:
231+
- SQLCipher version being updated to
232+
- iOS submodule commit reference
233+
- Link to iOS SDK PR with SQLCipher update
234+
- Link to SQLCipher release notes
235+
- Test results summary
236+
- Any hybrid-specific changes or notes
237+
- Cross-platform status (Android update status)
238+
239+
## File Checklist
240+
241+
- [ ] `external/SalesforceMobileSDK-iOS` - Update submodule reference
242+
- [ ] `SalesforceMobileSDK-Hybrid.xcworkspace/xcshareddata/swiftpm/Package.resolved` - Update SQLCipher version and commit hash
243+
- [ ] `hybrid/SampleApps/MobileSyncExplorerHybrid/MobileSyncExplorerHybrid.xcodeproj/project.pbxproj` - Update SQLCipher package version
244+
- [ ] `hybrid/SampleApps/AccountEditor/AccountEditor.xcodeproj/project.pbxproj` - Update SQLCipher package version
245+
- [ ] `SalesforceHybridSDK.podspec` - Verify dependencies (usually no change needed)
246+
- [ ] Run full SalesforceHybridSDK test suite
247+
- [ ] Build and test AccountEditor sample app
248+
- [ ] Build and test MobileSyncExplorerHybrid sample app
249+
- [ ] Verify on multiple iOS versions (min deployment target to latest)
250+
- [ ] Check Android hybrid SDK has corresponding update
251+
- [ ] Note CordovaPlugin repo will need update
252+
253+
## Key Files Reference
254+
255+
**Submodules:**
256+
- `external/SalesforceMobileSDK-iOS` - iOS native SDK submodule (contains SmartStore with SQLCipher)
257+
- `external/shared` - Shared JavaScript libraries
258+
- `external/cordova` - Apache Cordova iOS
259+
260+
**Build Configuration:**
261+
- `SalesforceHybridSDK.podspec` - Hybrid SDK pod specification
262+
- `SalesforceMobileSDK-Hybrid.xcworkspace` - Xcode workspace
263+
264+
**Hybrid Plugin Source Files:**
265+
- `libs/SalesforceHybridSDK/SalesforceHybridSDK/Classes/Plugins/SFSmartStorePlugin/` - SmartStore Cordova plugin
266+
- `libs/SalesforceHybridSDK/SalesforceHybridSDK/Classes/Plugins/SFMobileSyncPlugin/` - MobileSync Cordova plugin
267+
268+
**Test Files:**
269+
- `libs/SalesforceHybridSDK/SalesforceHybridSDKTests/` - Hybrid SDK test suite
270+
271+
**Sample Apps:**
272+
- `hybrid/SampleApps/AccountEditor/` - Basic CRUD sample
273+
- `hybrid/SampleApps/MobileSyncExplorerHybrid/` - Complete sync demo
274+
275+
## Troubleshooting
276+
277+
### Package Resolution Failures
278+
279+
**Error:**
280+
```
281+
xcodebuild: error: Could not resolve package dependencies:
282+
Failed to resolve dependencies Dependencies could not be resolved because root depends on 'sqlcipher.swift' 4.16.0 and root depends on 'sqlcipher.swift' 4.15.0.
283+
```
284+
285+
**Cause:** Version mismatch between:
286+
- iOS submodule's SQLCipher dependency (in SmartStore.podspec)
287+
- Workspace Package.resolved
288+
- Sample app project files
289+
290+
**Solution:**
291+
1. Check iOS submodule version: `grep -A 5 "SQLCipher" external/SalesforceMobileSDK-iOS/SmartStore.podspec`
292+
2. Update workspace Package.resolved to match
293+
3. Update both sample app project.pbxproj files to match
294+
4. Clean build folder: `rm -rf ~/Library/Developer/Xcode/DerivedData/*`
295+
296+
### Wrong Commit Hash in Package.resolved
297+
298+
**Error:**
299+
```
300+
Couldn't check out revision 'xxxxx':
301+
fatal: unable to read tree (xxxxx)
302+
```
303+
304+
**Cause:** Incorrect commit hash in Package.resolved
305+
306+
**Solution:**
307+
```bash
308+
git clone --depth=1 --branch 4.16.0 https://github.com/sqlcipher/SQLCipher.swift /tmp/sqlcipher-check
309+
cd /tmp/sqlcipher-check
310+
git log -1 --format="%H"
311+
# Use this hash in Package.resolved
312+
```
313+
314+
### Sample Apps Won't Build After Update
315+
316+
**Cause:** Sample app project files still reference old SQLCipher version
317+
318+
**Solution:**
319+
Search for old version in project files:
320+
```bash
321+
grep -r "4.15.0" hybrid/SampleApps/*/*/project.pbxproj
322+
```
323+
Update all occurrences to new version.
324+
325+
## Notes
326+
327+
- The iOS Hybrid SDK doesn't directly manage SQLCipher dependencies
328+
- SQLCipher updates flow through the iOS SDK submodule
329+
- Always update the iOS SDK first, then update the submodule reference
330+
- The hybrid SDK's dependency on MobileSync brings in SmartStore and SQLCipher transitively
331+
- **Swift Package Manager is used by the workspace and sample apps** - these must be updated separately from podspecs
332+
- Hybrid plugins (SFSmartStorePlugin, SFMobileSyncPlugin) bridge JavaScript to the native iOS SDK
333+
- Test with encrypted databases from previous versions to ensure migration works
334+
- After updating, the CordovaPlugin repo will need to run `tools/update.sh` to sync changes
335+
336+
## Cross-Repository Impact
337+
338+
This update affects:
339+
1. **iOS-Hybrid** (this repo) - Submodule reference update
340+
2. **iOS** - Direct SQLCipher dependency (should be updated first)
341+
3. **Shared** - JavaScript libraries (usually no change for SQLCipher updates)
342+
4. **CordovaPlugin** - Needs `tools/update.sh` run after iOS-Hybrid update
343+
5. **Templates** - Hybrid templates reference CordovaPlugin (will pick up changes automatically)
344+
6. **Android** - Should have corresponding SQLCipher update for consistency
345+
346+
## Resources
347+
348+
- SQLCipher: https://www.zetetic.net/sqlcipher/
349+
- SQLCipher Releases: https://github.com/sqlcipher/sqlcipher/releases
350+
- iOS SDK CLAUDE.md: See `external/SalesforceMobileSDK-iOS/CLAUDE.md` for iOS-specific details
351+
- Cordova iOS: https://cordova.apache.org/docs/en/latest/guide/platforms/ios/
352+
- iOS Hybrid SDK docs: See CLAUDE.md in this repo

hybrid/SampleApps/AccountEditor/AccountEditor.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@
13431343
repositoryURL = "https://github.com/sqlcipher/SQLCipher.swift";
13441344
requirement = {
13451345
kind = exactVersion;
1346-
version = 4.15.0;
1346+
version = 4.16.0;
13471347
};
13481348
};
13491349
/* End XCRemoteSwiftPackageReference section */

hybrid/SampleApps/MobileSyncExplorerHybrid/MobileSyncExplorerHybrid.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@
13431343
repositoryURL = "https://github.com/sqlcipher/SQLCipher.swift";
13441344
requirement = {
13451345
kind = exactVersion;
1346-
version = 4.15.0;
1346+
version = 4.16.0;
13471347
};
13481348
};
13491349
693387C62E83320100F667A7 /* XCRemoteSwiftPackageReference "fmdb" */ = {

0 commit comments

Comments
 (0)