What errors do you get when you create a new project?
What system are you using?
You can do the following to setup a button to send a request.
Note: you need to use "https" otherwise you will have to fiddle with the security entitlements. import SwiftUI
	 struct ContentView: View {
		var body: some View {
		 Button(action: {sendHttpPost()}) {
				Text("Press here to send a post")
.padding(15)
.foregroundColor(.blue)
.border(Color.blue, width: 2)
}.buttonStyle(PlainButtonStyle())
}
func sendHttpPost() {
let session = URLSession(configuration: .default)
let url = URL(string: "http:...//ServerIP:8000/xmlcommand")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("text/plain", forHTTPHeaderField: "Content-Type") // I guess this can be "text/xml"
// Working line
request.httpBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Commands><command type=\"open\"><name>environments/Animals.hwe</name><id>a1</id></command></Commands>".data(using: .utf8)
let task = session.dataTask(with: request) { data, response, error in
// print(data as Any)
// print(response as Any)
// print(error as Any)
// do something with the result
print(data as Any? as Any)
if let data = data {
print(String(data: data, encoding: .utf8)!)
} else {
print("no data")
}
}
task.resume() // <- otherwise your network request won't be started
}
}