Skip to content

Commit

Permalink
fix: add try/catch around applesimutils operation
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 committed Jan 6, 2025
1 parent 41b6c39 commit 815f841
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ object LocalSimulatorUtils {
)
}

fun setPermissions(deviceId: String, bundleId: String, permissions: Map<String, String>) {
fun setAppleSimutilsPermissions(deviceId: String, bundleId: String, permissions: Map<String, String>) {
val permissionsMap = permissions.toMutableMap()
if (permissionsMap.containsKey("all")) {
val value = permissionsMap.remove("all")
Expand Down
13 changes: 9 additions & 4 deletions maestro-ios/src/main/java/ios/simctl/SimctlIOSDevice.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ios.simctl

import com.github.michaelbull.result.Result
import com.github.michaelbull.result.onFailure
import com.github.michaelbull.result.runCatching
import hierarchy.ViewHierarchy
import ios.IOSDevice
Expand Down Expand Up @@ -167,13 +168,17 @@ class SimctlIOSDevice(
}

override fun setPermissions(id: String, permissions: Map<String, String>) {
logger.info("[Start] Setting permissions through applesimutils")
LocalSimulatorUtils.setPermissions(deviceId, id, permissions)
val formattedPermissions = permissions.entries.joinToString(separator = ", ") { "${it.key}=${it.value}" }

logger.info("[Start] Setting permissions $formattedPermissions through applesimutils")
runCatching { LocalSimulatorUtils.setAppleSimutilsPermissions(deviceId, id, permissions) }.onFailure {
logger.error("Failed setting permissions $permissions via applesimutils", it)
}
logger.info("[Done] Setting permissions through applesimutils")

logger.info("[Start] Setting Permissions through simctl")
logger.info("[Start] Setting Permissions $formattedPermissions through simctl")
LocalSimulatorUtils.setSimctlPermissions(deviceId, id, permissions)
logger.info("[Done] Setting Permissions through simctl")
logger.info("[Done] Setting Permissions $formattedPermissions through simctl")
}

override fun eraseText(charactersToErase: Int) {
Expand Down

0 comments on commit 815f841

Please sign in to comment.