HI,
i am created command line tool in main swiftui app for MacOS using the following link.
Apple Developer Link
my queries are:
How to run command line app when main swiftui app starts ?
How to check command line app is running or not ?
How to stop command line app using main app?
How to get data from command line app using main swiftui app?
How to terminate command line app when main app terminates?
Post
Replies
Boosts
Views
Activity
Hi,
I am new to MacOS SwiftUI App Development. I am having a post request implemented with URLSession.shared.dataTask which it was working fine upto now. Suddenly i am not getting response from the request.
I am testing this parallelly in 3 macs, in that one mac is running continuously from past one week, another one is running is running from one day and last one is started running one hour before. All of sudden this request is stopped working at the time of post. my expected response is string added
let url = URL(string: "my url for request")!
var request = URLRequest(url: url)
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let encoded = try? JSONEncoder().encode("my data to post")
request.httpBody = encoded
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard
let data = data,
let response = response as? HTTPURLResponse,
error == nil
else {
// check for fundamental networking error
print("error", error ?? URLError(.badServerResponse))
return
}
guard (200 ... 299) ~= response.statusCode else { // check for http errors
print("statusCode should be 2xx, but is \(response.statusCode)")
print("response = \(response)")
return
}
do {
let responseObject = try JSONDecoder().decode(String.self, from: data)
print(responseObject)
} catch {
print(error) // parsing error
if let responseString = String(data: data, encoding: .utf8) {
print("responseString = \(responseString)")
} else {
print("unable to parse response as string")
}
}
}
task.resume()
Note: 1. only above mentioned post request stooped working, get requests are working fine.
2. I checked same post request with postman working fine.
3. i Checked same post request in windows system working fine.
Hi,
I am new to MacOS SwiftUI Development. I am creating Simple Login Screen with fixed width and height which it is showing differently in different screen resolutions.
Please suggest designing the screen suitable to any screen resolution.
Hi,
I am trying to build, archive and create MacOS release app without hosting to app store.
steps:
Changed scheme to Any Mac (Apple Silicon, Intel)
Build Created
Archived
click on Distribute App > Selected App Store Connect > Selected Export >
Preparing app record clicked skip > App store connect distribution options clicked next > Re-sign Mac Tracker clicked next > Clicked Export.
*.pkg file Created.
installed App in new Mac.
App installed in Applications folder.
App crashes with error "Code Signature Invalid" when trying to open the App.
Hi,
I am trying to implement macOS application with swiftUI, In that i am trying to get current user location using following code.
import Foundation
import CoreLocation
import MapKit
class CurrentLocationManager2: NSObject, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
override init() {
super.init()
locationManager.delegate = self
}
func startLocation() {
locationManager.requestAlwaysAuthorization()
// locationManager.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled(){
locationManager.startUpdatingLocation()
}else{
print ("Error Location")
}
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedAlways {
print("authorizedAlways status is assigned")
manager.startUpdatingLocation()
}
else if status == .denied {
print("denied status is assigned")
}
else if status == .notDetermined {
print("notDetermined status is assigned")
manager.requestAlwaysAuthorization()
}
else if status == .restricted {
print("restricted status is assigned")
}
else {
print("status is not assigned")
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
//last
if let location = locations.first {
print("Found user's location: \(location)", "lat =", location.coordinate.latitude," long = ",location.coordinate.longitude)
LogModel.latitude = String(location.coordinate.latitude)
LogModel.longitude = String(location.coordinate.longitude)
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("Failed to find user's location: \(error.localizedDescription)")
}
}
let location = CurrentLocationManager2()
location.startLocation()
Hi,
I am trying to capture screenshot in MacOS App with sand box.
I am getting background screen only.
can any one tell me best way to capture complete screenshot.
Hi,
I am developing macOS app with sandbox. I am implementing HID Device functionality in macOS app which shows error.
0x1000638ee: TCC deny IOHIDDeviceOpen
Could not open HID manager
In entitlements :
com.apple.security.device.usb is set to true