The code lacks file permission? or something else?

Trying to make a sample project swiftUI project file run from an another program.
The play button pops up a file selection dialog and then the program should run.
I set the Project IDE --> signing capabilities --> "read/write" for App sandbox.
I still get the error in the console xcrun: error: cannot be used within an App Sandbox.
The file is in the onedrive folder, but I have made the file to be available locally.

xCode, macOS

How to rectify this?

import SwiftUI
import Foundation
import Cocoa

struct ContentView: View {
    var body: some View {
        Button(action: {
            let openPanel = NSOpenPanel()
            openPanel.canChooseFiles = true
            openPanel.canChooseDirectories = false
            openPanel.allowsMultipleSelection = false
            openPanel.begin { result in
                if result == .OK, let url = openPanel.url {
                    let tempDir = NSTemporaryDirectory()
                    let buildDir = URL(fileURLWithPath: tempDir).appendingPathComponent("MyAppBuild")
                    let process = Process()
                    process.launchPath = "/usr/bin/xcodebuild"
                    process.arguments = ["-project", url.path, "-scheme", "MyApp", "-derivedDataPath", buildDir.path, "clean", "build"]
        }) {