Idris Ocasio
01/13/2025, 5:20 AMjw
01/13/2025, 6:17 AMPearce Keesling
01/13/2025, 1:36 PMIdris Ocasio
01/13/2025, 1:40 PMIdris Ocasio
01/13/2025, 1:43 PMIdris Ocasio
01/13/2025, 5:14 PMPearce Keesling
01/13/2025, 5:20 PMfun getDataFolderPath() = requireNotNull(NSFileManager.defaultManager.containerURLForSecurityApplicationGroupIdentifier("group.com.your.identifier")).path
Idris Ocasio
01/13/2025, 5:28 PMactual class DatastoreFactory {
actual fun createDatastore(): DataStore<Preferences> {
return initDataStore {
val directory = NSFileManager.defaultManager.URLForDirectory(
directory = NSDocumentDirectory,
inDomain = NSUserDomainMask,
appropriateForURL = null,
create = false,
error = null
)
requireNotNull(directory).path() + "/${Constants.DATASTORE_FILE_NAME}"
}
}
}
Seems like you're using the App group which is so that apps can read from the same files. But I didn't think widgets and the app would have different directoriesPearce Keesling
01/13/2025, 5:29 PMdirector.path()
on both targets and make sure they are the same. If I remember correctly they were in different locations for usIdris Ocasio
01/13/2025, 5:30 PMPearce Keesling
01/13/2025, 5:31 PMNow that your data is ready to be written and read externally, we need access to shared storage for that data. We will accomplish this by creating an App Group and adding both the app and the widget to it. Normally, iOS isolates each app into its own container; App Groups are the operating system’s way of letting apps access shared containers and communicate through interprocess communication, which is exactly what you will need for your app and widget.That's just the result of a random google though so take it with a grain of salt
Idris Ocasio
01/13/2025, 9:56 PMPearce Keesling
01/13/2025, 9:56 PMIdris Ocasio
01/13/2025, 9:59 PMPearce Keesling
01/13/2025, 10:00 PMPearce Keesling
01/13/2025, 10:01 PMIdris Ocasio
01/13/2025, 10:01 PMPearce Keesling
01/13/2025, 10:03 PMPearce Keesling
01/13/2025, 10:03 PMPearce Keesling
01/13/2025, 10:03 PMIdris Ocasio
01/13/2025, 10:05 PMlistOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "ComposeApp"
isStatic = true
}
}
This was the default implementationIdris Ocasio
01/13/2025, 10:05 PMIdris Ocasio
01/13/2025, 10:11 PMIdris Ocasio
01/13/2025, 10:11 PMIdris Ocasio
01/13/2025, 10:11 PMIdris Ocasio
01/13/2025, 10:12 PM(Fwiw I am not an iOS expert at all, just fumbled around enough to get our app to build)No worries! I really appreciate your help. I am an Android developer just fumbling around too lol
Pearce Keesling
01/13/2025, 10:57 PMno script like that for the widget targetYou might want to try adding an equivalent under the widget target
Idris Ocasio
01/14/2025, 1:18 AM