Post

Replies

Boosts

Views

Activity

Reply to Outlet error
If you want someone to help you, you need to be much more specific about what you are doing, what you expect to happen, and what happens. Does the class of the view controller in the storyboard match the name of the class in the source code file where you are trying to create the outlet? Forgetting to set the view controller's class in the storyboard is a common reason for being unable to connect and create outlets and actions.
Aug ’21
Reply to MacOS Development Reference
The following article has a collection of resources for learning Mac development: swiftdevjournal.com/resources-for-learning-mac-development/ Regarding learning SwiftUI or AppKit, you're going to find many more recent articles and tutorials on SwiftUI. Most of these articles are focused on iOS, but most of the material will apply to Mac too. Lists are the one view where you'll run into issues because lists(table views) have much different behavior on Mac than on iOS.
Topic: UI Frameworks SubTopic: AppKit Tags:
Aug ’21
Reply to How to delete SDK from XCode ?
If you want someone to help you, you need to provide more details on what you are doing, such as the type of project you're creating. What SDK do you want to remove? What kind of program are you trying to make? If you want to start from 0 in Xcode, create an empty project. Click Other at the top of the New Project Assistant to access the empty project template.
Aug ’21
Reply to Can I create a games on ipad
When the new version of Swift Playgrounds is released, you'll be able to create games on an iPad. The new version of Swift Playgrounds requires iOS 15. You must be 18 to publish an app on the App Store. You can publish the game under a parent's name if you are under 18.
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’21
Reply to SwiftUI on MacOS (Not iOS)
The closest thing SwiftUI has out of the box is a document tab bar. If you create a document-based app, you get a tab bar with a tab for every open document and an X button to close the document. The tab bar is initially hidden. Choose View > Show Tab Bar to show the tab bar.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’21
Reply to Enable access to Documents Directory in Xcode 13
What I am trying to do is export a collection of Markdown files into an EPUB book. To create the EPUB book I start by creating a file wrapper that has everything the EPUB needs. I finish by using the ZIPFoundation framework to compress the file wrapper into a valid EPUB/Zip archive. When I finish building the file wrapper, I call the FileWrapper class's write function to temporarily create the file so ZIPFoundation can compress and archive it. do { // mainDirectory is the file wrapper root. wrapperURL is the location to export // from either the file exporter panel or NSSavePanel. try mainDirectory.write(to: wrapperURL, options: [], originalContentsURL: nil) } catch { Swift.print("Error temporarily writing the book's file wrapper to disk. Error: \(error)") } When I step through this code in the debugger, it goes to the catch block and prints the following message in the console: Error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file TestBook in the location (path to folder inside the Documents directory)." This error occurs both with the SwiftUI file exporter and NSSavePanel. The only way I can get the error message to go away is to turn on the App Sandbox, give the Downloads folder read/write access, and export my books in the Downloads folder.
Topic: Code Signing SubTopic: General Tags:
Sep ’21
Reply to Enable access to Documents Directory in Xcode 13
When I try the code you suggested. try "Hello Cruel World!".write(to: wrapperURL, atomically: false, encoding: .utf8) I get the permission error. However, I was inaccurate in my comment about wrapperURL. The wrapperURL variable removes the .epub extension from the location URL from the file exporter or save panel. // location is the URL from the file exporter or NSSavePanel. var wrapperURL = location wrapperURL.deleteLastPathComponent() wrapperURL.appendPathComponent(location.lastPathComponent .replacingOccurrences(of: ".epub", with: "")) When I replace wrapperURL with location in your example, the file permissions error goes away. try "Hello Cruel World!".write(to: location, atomically: false, encoding: .utf8) If I write the wrapper using the location, try mainDirectory.write(to: location, options: [], originalContentsURL: nil) The file permissions error goes away, but the file wrapper is empty.
Topic: Code Signing SubTopic: General Tags:
Sep ’21
Reply to Can I use Xcode for python?
It is possible to use Xcode for Python. Create an external build system project and enter the path to the Python interpreter in the Build Tool text field in the New Project Assistant. Xcode has support for Python syntax highlighting. I'm not sure if Xcode supports Python autocomplete. You're better off using a text editor like BBEdit, Sublime Text, TextMate, or VSCode for Python. Xcode is designed for making apps in Swift and Objective-C, not for Python development.
Sep ’21
Reply to Enable access to Documents Directory in Xcode 13
I took another look at my code and realized why I need the following code: var wrapperURL = location wrapperURL.deleteLastPathComponent() wrapperURL.appendPathComponent(location.lastPathComponent .replacingOccurrences(of: ".epub", with: "")) When someone chooses to publish the book, I get the location to publish the book from the file exporter or save panel. The URL will look similar to the following: /path/to/MyBook.epub When I write the file wrapper to disk, I can't write the wrapper at the location variable's URL because location is the destination for creating the book's Zip archive. I have to temporarily create the file wrapper with a different file name than MyBook.epub. /path/to/MyBook The MyBook file wrapper is the source for creating the Zip archive and MyBook.epub is the destination. I need both files to create the Zip archive with the ZIPFoundation framework. You said in an earlier post: When the user chooses a file in a standard file panel, the system extends your sandbox to access just that file. If you move the extension that’s a different file and you don’t have access to it. Does this mean my creating the temporary file wrapper is forbidden in the App Sandbox? For now I can avoid using the App Sandbox, but these permission errors also occur with the App Sandbox turned off.
Topic: Code Signing SubTopic: General Tags:
Sep ’21
Reply to Enable access to Documents Directory in Xcode 13
The material in the url(for:in:appropriateFor:create:) docs provided the solution. The file permission problem was caused by the temporary file wrapper being in the same folder as the published book, The solution is to create a temporary directory for the file wrapper. Here's the code for anyone else who may have the same problem in the future. var wrapperURL = URL(string: "/") do { wrapperURL = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) wrapperURL?.appendPathComponent("TempBook") } catch { Swift.print("Error creating a temporary URL for the file wrapper. Error: \(error)") }
Topic: Code Signing SubTopic: General Tags:
Sep ’21