Is there a way to opt out of user script sandbox c...
# multiplatform
l
Is there a way to opt out of user script sandbox checking when building the shared library from Xcode? It was working for me with sandboxing before, but after some upgrade (of Gradle? Kotlin?), my shared library build now fails. I don't really want to disable user script sandboxing for my whole project.
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':shared:checkSandboxAndWriteProtection'.
> You have sandboxing for user scripts enabled.
  In your Xcode project, navigate to "Build Setting",
  and under "Build Options" set "User script sandboxing" (ENABLE_USER_SCRIPT_SANDBOXING) to "NO".
  Then, run "./gradlew --stop" to stop the Gradle daemon
  For more information, see documentation: <https://kotl.in/iq4uke>
t
@Timofey Solonin maybe you could help here?
t
Hi. You can change your
ENABLE_USER_SCRIPT_SANDBOXING
build setting to yes and prefix gradle call in the Xcode build phase with:
Copy code
ENABLE_USER_SCRIPT_SANDBOXING=NO ./gradlew ...
this way the script and all child subprocesses (Gradle) will be sandboxed, but Kotlin Gradle Plugin will think it is not. I would still highly recommend you to avoid doing this. If Gradle daemon starts in a sandboxed environment, it will be prohibited from doing certain IO. In particular we rely on being able to write files in
CONFIGURATION_BUILD_DIR
which is sandboxed by Xcode.
disable user script sandboxing for my whole project
You could extract Gradle call into a separate Xcode framework/aggregate target and disable sandboxing only for this particular target.
One more warning: we heuristically check that we have access to
CONFIGURATION_BUILD_DIR
and fail the build if it is not accessible. In your build script you will have to iterate over all configured tasks and disable a task named
checkSandboxAndWriteProtection
l
Thank you for your quick and detailed answers. I'll consider how to handle this moving forward. 🙂