mirror of
https://github.com/mixpanel/mixpanel-swift
synced 2026-04-21 13:37:18 +00:00
Fix iOS CI: exclude simulator from file-protection open flag
SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION is only meaningful on real iOS devices. The simulator uses the macOS host file system and has no Data Protection, so applying the flag there can cause sqlite3_open_v2 to hang or fail, breaking tests that rely on the tracking queue.
This commit is contained in:
parent
3ad0fb8221
commit
0f9d0af3d3
1 changed files with 12 additions and 1 deletions
|
|
@ -55,7 +55,18 @@ class MPDB {
|
|||
return
|
||||
}
|
||||
if let dbPath = pathToDb() {
|
||||
if sqlite3_open_v2(dbPath, &connection, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nil)
|
||||
// On iOS (excluding Mac Catalyst and simulator), use SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION
|
||||
// so the database and its WAL/SHM files remain accessible in the background after first
|
||||
// unlock. Without this, WAL file fsync/pwrite can hang indefinitely when the screen is
|
||||
// locked during background execution, causing a watchdog kill.
|
||||
// Mac Catalyst and the simulator use macOS/host file systems with no Data Protection,
|
||||
// so the flag is unnecessary and can cause issues there.
|
||||
#if os(iOS) && !targetEnvironment(macCatalyst) && !targetEnvironment(simulator)
|
||||
let openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FILEPROTECTION_COMPLETEUNTILFIRSTUSERAUTHENTICATION
|
||||
#else
|
||||
let openFlags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
|
||||
#endif
|
||||
if sqlite3_open_v2(dbPath, &connection, openFlags, nil)
|
||||
!= SQLITE_OK
|
||||
{
|
||||
logSqlError(message: "Error opening or creating database at path: \(dbPath)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue