Post

Replies

Boosts

Views

Activity

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
Reply to Xcode - Developing IOS Applications
You need a Mac that can run the latest version of macOS to submit apps to the App Store. The following page from Apple lists the Macs that can run the latest version of macOS: Mac Hardware Requirements
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
Aug ’21
Reply to How to use iOS15-specific modifiers in SwiftUI on iOS 14 and earlier?
The keyword you're looking for is #available. Use an if-else block, not #if and #endif, putting the iOS 14 code in the else part of the block. TextField("Username", text: $username) if #available(iOS 15.0, *) { .focused($focusedField, equals: .username) } else { // Put the iOS 14 equivalent code here. }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’21
Reply to How to open XCode 13 project in XCode 12?
Open the project in Xcode 13. Select the project file. In the file inspector on the right side of the window is a Project Format menu. Choose an earlier version of Xcode from that menu to open the project in earlier Xcode versions.
Replies
Boosts
Views
Activity
Sep ’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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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.
Replies
Boosts
Views
Activity
Sep ’21
Reply to Enable access to Documents Directory in Xcode 13
If I pass the .atomic option, the file wrapper remains empty.
Topic: Code Signing SubTopic: General Tags:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
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:
Replies
Boosts
Views
Activity
Sep ’21
Reply to App Store Connect Error When Uploading to Apple
The upload error went away when I updated to Xcode 13.
Replies
Boosts
Views
Activity
Sep ’21
Reply to Xcode 13: How to revert changes in side-by-side comparison?
Below the Add button in the toolbar is a set of three buttons. Click the middle button snd choose Side By Side Comparison to use side-by-side comparison.
Replies
Boosts
Views
Activity
Oct ’21
Reply to SwiftUI Image does not display image from existing file
I created an outlet for an image view and called a function in the view controller's viewDidAppear method to load the metadata. I had the following line of code to set the image: coverImageView.image = NSImage(contentsOf: book.metadata.coverFile)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21