Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Tutorial Application Alleged Incompatibility with macOS
I took a look at the tutorial and I saw nothing in it that requires macOS 13. Can you clarify what you were doing when you got the error messages? Did the errors occur when you were typing code or when you build the project? At that point in the tutorial, it says the previews won't work because of the new stuff you typed. The next section in the tutorial fixes the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Swiftui MacOS App Example Project OnDelete func
If you are talking about removing items from SwiftUI lists, the modifier for Mac apps is .onDeleteCommand instead of .onDelete, which iOS apps use. For anyone to provide more help, you have to provide the code to delete the item from Core Data and the SwiftUI code for deleting items. The following article may help you: https://www.swiftdevjournal.com/removing-items-from-swiftui-lists-in-mac-apps/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Xcode 14 / iOS 16 - UIViewRepresentables must be value types
Were you able to use a class in earlier Xcode versions? I am almost 100 percent sure you have to make PlayerView a struct. SwiftUI views are structs. The UIViewRepresentable protocol lets you wrap UIKit views to use them in SwiftUI apps, essentially converting UIKit views to SwiftUI views. Therefore views that use UIViewRepresentable must be structs. Create a new class that has the @Published property and the Combine publishers. Add an instance of the class to PlayerView. That way you can use the @Published property and have the view be a struct.
Sep ’22
Reply to Using Document Picker to access files inside app directories
A document picker can't access files inside the app bundle. Use the methods in the Bundle class to load files from the app bundle. If you have documents in the app bundle that you want people to open in the app, copy the documents from the app bundle to the app's Documents directory. The FileManager class has a copyItem method to copy a file from one URL to another.
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’22
Reply to Xcode 12.4 builds do not install on devices using iOS 15
What version of iOS is the device running? What version of the iOS 15 support files did you install? Be more specific than iOS 15, such as iOS 15.6. If the device is running a newer version of iOS than the iOS SDK/Support Files, you won't be able to install the app on the device. I have seen multiple questions on these forums about people unable to install apps built with Xcode 13.4.1 on devices running iOS 15.6. Search these forums for those posts, and you might find a workaround. If you're going to use an older Xcode version, turn off automatic updates on your device. Updating iOS requires updating Xcode or installing iOS support files.
Aug ’22
Reply to URL-Session is not working in Command Line App but in Playground
Does the app have the App Sandbox turned on? If so, network connections might be turned off so the networking code won't do anything. There are checkboxes to turn on network connections in the App Sandbox. To check if the app has the App Sandbox turned on, open the project editor by selecting the project from the left side of the project window. Select the app from the target list on the left side of the project editor. Click the App Capabilities button at the top of the project editor.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’22
Reply to ipa archived on macOS 11.4 cannot be installed
For anyone to help you, you need to supply more information: How are you installing the app? What version of iOS is the device running? What version of Xcode did you use to archive the app? What version of the iOS SDK did you use to archive the app? The site Xcode Releases (https://xcodereleases.com) lists the SDK for each Xcode version. I know that apps submitted to the App Store must be built with the iOS 15 SDK. I don't know if that restriction applies when installing an app on your own device. Updating to the latest non-beta version of Xcode may solve your problem. At the very least you will be archiving with the iOS 15 SDK.
Aug ’22
Reply to HTTP Status 400 – Bad Request
I have two suggestions to help you figure out what's going wrong. First, set a breakpoint at the start of the postTaniTalep function. Step through the code line by line and check that everything in the request is what you expect to see. If you haven't used Xcode's debugger before, the following article will help you: https://www.swiftdevjournal.com/an-introduction-to-xcodes-debugger/ Second, you have the following line of code to make the network call: let (data, response) = try await URLSession.shared.data(for: request) The code uses try. Code with try can throw errors, but you don't handle them. Wrap the network call in a do-catch block and at least print the error in the catch part of the block. The error message you get should be more helpful than "400 Bad Request".
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Multipage PDF with PDFKit on macOS with swift
There are two ways to create PDFs on Mac. The first is to use NSPrintOperation, which is in the AppKit framework. The second is to use the Quartz framework. If you have a lot of text, using Core Text with Quartz may help. The following article shows what you need to do to create a PDF with Quartz and Core Text: https://www.meandmark.com/blog/2016/08/creating-pdfs-with-core-text-and-quartz/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Need help with WKWebKit browser loading website (macOS)
A common cause for your issue is the App Sandbox is turned on with network connections turned off. When the network connections are turned off, you won't be able to show anything in a web view. Select the project from the left side of the project window to open the project editor. Select your app target from the left side of the project editor. Click the Signing and Capabilities button at the top of the project editor. Is there an App Sandbox section? If so, make sure the checkboxes in the Network section are selected. Is the code you showed the whole code you're using for the web view? The code you showed needs to be part of a view controller class with the outlet as a property in the class and the other three lines inside the viewDidLoad function. class ViewController: NSViewController { @IBOutlet weak var web: WKWebView!     override func viewDidLoad() { super.viewDidLoad() let purl = URL(string: "https://www.google.com")! web.load(URLRequest(url: purl)) web.allowsBackForwardNavigationGestures = true     } }
Topic: App & System Services SubTopic: Core OS Tags:
Aug ’22
Reply to SwiftUI Tutorial Application Alleged Incompatibility with macOS
I took a look at the tutorial and I saw nothing in it that requires macOS 13. Can you clarify what you were doing when you got the error messages? Did the errors occur when you were typing code or when you build the project? At that point in the tutorial, it says the previews won't work because of the new stuff you typed. The next section in the tutorial fixes the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Swiftui MacOS App Example Project OnDelete func
If you are talking about removing items from SwiftUI lists, the modifier for Mac apps is .onDeleteCommand instead of .onDelete, which iOS apps use. For anyone to provide more help, you have to provide the code to delete the item from Core Data and the SwiftUI code for deleting items. The following article may help you: https://www.swiftdevjournal.com/removing-items-from-swiftui-lists-in-mac-apps/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Xcode 14 / iOS 16 - UIViewRepresentables must be value types
Were you able to use a class in earlier Xcode versions? I am almost 100 percent sure you have to make PlayerView a struct. SwiftUI views are structs. The UIViewRepresentable protocol lets you wrap UIKit views to use them in SwiftUI apps, essentially converting UIKit views to SwiftUI views. Therefore views that use UIViewRepresentable must be structs. Create a new class that has the @Published property and the Combine publishers. Add an instance of the class to PlayerView. That way you can use the @Published property and have the view be a struct.
Replies
Boosts
Views
Activity
Sep ’22
Reply to I Need Help Please: Storage and Xcode Error
How much free space is on your startup disk? How big is the app you are trying to archive? You most likely have to free up some space on the startup disk. How much space does your app's saved data take up? Can you remove any of it?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to NavigationSplitView Missing in Xcode 14 RC
Are you making an iOS or a Mac app? The Xcode 14 RC removes the macOS 13 SDK so you can't use the new navigation system on a Mac. Use the Xcode beta if you need to use the new navigation system on a Mac app. When macOS 13 ships Apple will ship a new version of Xcode with the macOS 13 SDK.
Replies
Boosts
Views
Activity
Sep ’22
Reply to Using Document Picker to access files inside app directories
A document picker can't access files inside the app bundle. Use the methods in the Bundle class to load files from the app bundle. If you have documents in the app bundle that you want people to open in the app, copy the documents from the app bundle to the app's Documents directory. The FileManager class has a copyItem method to copy a file from one URL to another.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to File locations under Xcode 13.4.1 on Monterey 12.5.1
In Xcode choose Product > Show Build Folder in Finder to find your executable in the Finder. Choosing File > Project Settings will open a sheet. The Derived Data location is where Xcode places the executable it builds. If you want the executable in the same folder as your project, choose Project-relative Location from the Derived Data menu.
Replies
Boosts
Views
Activity
Aug ’22
Reply to Xcode 12.4 builds do not install on devices using iOS 15
What version of iOS is the device running? What version of the iOS 15 support files did you install? Be more specific than iOS 15, such as iOS 15.6. If the device is running a newer version of iOS than the iOS SDK/Support Files, you won't be able to install the app on the device. I have seen multiple questions on these forums about people unable to install apps built with Xcode 13.4.1 on devices running iOS 15.6. Search these forums for those posts, and you might find a workaround. If you're going to use an older Xcode version, turn off automatic updates on your device. Updating iOS requires updating Xcode or installing iOS support files.
Replies
Boosts
Views
Activity
Aug ’22
Reply to URL-Session is not working in Command Line App but in Playground
Does the app have the App Sandbox turned on? If so, network connections might be turned off so the networking code won't do anything. There are checkboxes to turn on network connections in the App Sandbox. To check if the app has the App Sandbox turned on, open the project editor by selecting the project from the left side of the project window. Select the app from the target list on the left side of the project editor. Click the App Capabilities button at the top of the project editor.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to ipa archived on macOS 11.4 cannot be installed
For anyone to help you, you need to supply more information: How are you installing the app? What version of iOS is the device running? What version of Xcode did you use to archive the app? What version of the iOS SDK did you use to archive the app? The site Xcode Releases (https://xcodereleases.com) lists the SDK for each Xcode version. I know that apps submitted to the App Store must be built with the iOS 15 SDK. I don't know if that restriction applies when installing an app on your own device. Updating to the latest non-beta version of Xcode may solve your problem. At the very least you will be archiving with the iOS 15 SDK.
Replies
Boosts
Views
Activity
Aug ’22
Reply to HTTP Status 400 – Bad Request
I have two suggestions to help you figure out what's going wrong. First, set a breakpoint at the start of the postTaniTalep function. Step through the code line by line and check that everything in the request is what you expect to see. If you haven't used Xcode's debugger before, the following article will help you: https://www.swiftdevjournal.com/an-introduction-to-xcodes-debugger/ Second, you have the following line of code to make the network call: let (data, response) = try await URLSession.shared.data(for: request) The code uses try. Code with try can throw errors, but you don't handle them. Wrap the network call in a do-catch block and at least print the error in the catch part of the block. The error message you get should be more helpful than "400 Bad Request".
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Let people post external links in answers
I notice that pasting the URL for the external link without wrapping the URL in Markdown tags creates clickable links.
Replies
Boosts
Views
Activity
Aug ’22
Reply to Multipage PDF with PDFKit on macOS with swift
There are two ways to create PDFs on Mac. The first is to use NSPrintOperation, which is in the AppKit framework. The second is to use the Quartz framework. If you have a lot of text, using Core Text with Quartz may help. The following article shows what you need to do to create a PDF with Quartz and Core Text: https://www.meandmark.com/blog/2016/08/creating-pdfs-with-core-text-and-quartz/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Why does a let variable work in for ... in but not while let ... ?
Where does the for loop mutate threeToGo? The for loop does not mutate threeToGo. It goes through each element in the sequence and prints the element. The while loop generates a syntax error because you made the next function mutating. threeToGo is a let constant so you can't change it or call a mutating function on it.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Need help with WKWebKit browser loading website (macOS)
A common cause for your issue is the App Sandbox is turned on with network connections turned off. When the network connections are turned off, you won't be able to show anything in a web view. Select the project from the left side of the project window to open the project editor. Select your app target from the left side of the project editor. Click the Signing and Capabilities button at the top of the project editor. Is there an App Sandbox section? If so, make sure the checkboxes in the Network section are selected. Is the code you showed the whole code you're using for the web view? The code you showed needs to be part of a view controller class with the outlet as a property in the class and the other three lines inside the viewDidLoad function. class ViewController: NSViewController { @IBOutlet weak var web: WKWebView!     override func viewDidLoad() { super.viewDidLoad() let purl = URL(string: "https://www.google.com")! web.load(URLRequest(url: purl)) web.allowsBackForwardNavigationGestures = true     } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’22