Post

Replies

Boosts

Views

Activity

Reply to Mac OS Build Target
Projects and targets have separate deployment target settings. One of them probably has the deployment target set to macOS 11. Check the deployment target settings for both the Mac app target and the project and make sure they're both set to macOS 10.13.
Jan ’22
Reply to xcode 12.5.1 SpriteKit scene addchild fails reason already present
The exception is saying that you are trying to add a physics body that already exists. Does worldLayer have any physics bodies in it when you add the child to it? Do levelNode and mapNode have physics bodies? Did you add any physics bodies to anything in your .sks file? Do you have any code that creates physics bodies? If so, show the code as text, not as a screenshot. Code in a screenshot is hard to read. Can you add children without crashing if the SpriteKit nodes have no physics bodies?
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Jan ’22
Reply to SwiftUI App has disabled keyboard shortcuts on MacOS.
The keyboard shortcuts appearing disabled is the standard look for menu items in recent versions of macOS. If you look at the menus in Xcode the keyboard shortcuts look disabled but they work. I can't reproduce what you're experiencing. The keyboard shortcuts work in my SwiftUI Mac app projects. I created a new SwiftUI Mac app project in Xcode 13.2, and pressing Cmd-M minimizes the window. What are you seeing isn't expected behavior. You shouldn't have to write any code to make the standard keyboard shortcuts work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Documents in SwiftUI app have wrong file extension on Mac
The fix is to make the last part of the custom document UTI match the file extension, com.MyCompany.swiftbook. With that change the following code saves with the correct extension on Mac: static var bookDocumentPackage: UTType { UTType(exportedAs: "com.MyCompany.swiftbook", conformingTo: .package) } static var writableContentTypes: [UTType] { [.bookDocumentPackage, .epub] }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to xcode doesn't work
If you want someone to help you, you need to provide more detailed information about the problem. there is no window after running Is there no Xcode welcome window when you launch Xcode? Does no window open when you run your Xcode project? Or is there another problem? What are you expecting to see and what are you actually seeing? there is no prompt or interface What prompt? What interface? What are you expecting to see and what are you actually seeing? Until you provide detailed answers to these questions, no one can help you. The people on this forum can't see your screen. All they can see is what you write. And you haven't written much.
Jan ’22
Reply to Can Xcode run apps on iOS 12.5.5?
To get your app to run on iOS 12, you have to manually change the deployment target, the earliest version of iOS the app can run on, to iOS 12. When you create a new iOS app Xcode project, the deployment target for the app is the version of the iOS SDK that ships with Xcode. Xcode 13.2 ships with the iOS 15.2 SDK so new projects have the deployment target set to iOS 15.2. A new project won't run on earlier iOS versions until you change the deployment target. Use Xcode's project editor to change the deployment target. If you need detailed instructions on how to change the deployment target, read the article at the following URL: swiftdevjournal.com/supporting-older-versions-of-ios-and-macos/ Also make sure you choose Storyboard from the Interface menu when creating the project. New Xcode projects default to using SwiftUI for the user interface. Apple added SwiftUI in iOS 13 so SwiftUI apps won't run on iOS 12, no matter what you set the deployment target to.
Jan ’22
Reply to Can i use spritekit without xcode ?
You need Xcode to create and build the SpriteKit project, but you can use Visual Studio Code to write the code. Select a Swift (or Objective-C if you're using that) file in the Finder, Get Info on the file, and tell the Finder to use Visual Studio Code as the default editor for Swift files. Double-clicking the Swift file in the Finder will open the file in Visual Studio Code. You can also select a Swift file in Xcode, right-click, and choose Open with External Editor. If you have an iPad that can run iOS 15, another alternative is to use Swift Playgrounds 4 and create a SpriteKit app in that. Create a SpriteView to show a SpriteKit scene in a SwiftUI app, which is what Swift Playgrounds lets you create.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Jan ’22
Reply to Older macs on BigSur won't be able to develop iOS 15.4+ apps anymore?
You can make apps that will run on iOS 15.4+ on Big Sur. An app you make with Xcode 13.2 will run on iOS 15.4. What you won't be able to do is use anything Apple adds in the iOS 15.4 and future SDKs. Another future problem you will have is that around April 2023 Apple will require (most likely) App Store submissions to be built with Xcode 14, which won't run on macOS 11.
Feb ’22
Reply to SceneKit in Swift Playgrounds
Use a SceneView to display a SceneKit scene in a Swift Playgrounds app. Working with SceneKit in the iPad Swift Playgrounds app is going to be tough. You must build your scene in code because Swift Playgrounds currently does not have a scene editor and provides no way to add a new SceneKit scene to the playground. The following Reddit thread may help: reddit.com/r/swift/comments/snodad/using_scenekit_on_ipad/
Feb ’22
Reply to Why I am not success to pass data from one view to another view for many data in SwiftUI?
The reason the image detail view always shows davis is because your image details view always uses the davis image model. struct ImageDetailsView: View {      var body: some View {          ImageDetails(data:  ImageModel(name: "davis"))   } } You need to add a property to the image details view that stores the image model to display. @Binding var imageModel: ImageModel Pass the property to ImageDetails. ImageDetails(data: $imageModel) I don't see any list code, but you have to create a @State property in the view that has the list to store the selected list item. @State private var selectedImage: ImageModel? = nil Your list code should contain a navigation link to the details view. NavigationLink(destination: ImageDetailsView(imageModel: $selectedImage)) Now the details view would show the selected image. But your code has a problem. In both ImageRowView and ImageDetails, you have the following property: var data: ImageModel SwiftUI views do not live long. When a change occurs to a view, SwiftUI creates a brand new view. When SwiftUI creates a new view, you will lose the contents of the data variable. In ImageRowView, you should declare a @State property like the selectedImage property I declared earlier. When you use @State, SwiftUI will keep the property when it creates a new view. In ImageDetails you should declare a @Binding property, like the imageModel binding I declared earlier, so it will show the selected image model. I can't guarantee that everything will work now, but it should get you towards a solution. If you need a working example, the GitHub project at the following URL provides an example of handling list selection and working with @State and @Binding: https://github.com/SwiftDevJournal/WikiDemo
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’22
Reply to Project cannot be opened because it is in a future Xcode project file format
Are you sure the project format is still Xcode 3.2 after working on the project in Xcode 13? Xcode 13 changed the project file format. Working on your project in Xcode 13 may have changed the project format to Xcode 13 so it won't open in Xcode 10. Other people ran into a similar issue, and the fix was to open the project in Xcode 13 and set the project format to an earlier Xcode version.
Feb ’22
Reply to How to add GameController support into macOS app
According to the WWDC 2021 session on game controllers, adding the Game Controller capability adds an entry to Info.plist with the GCSupportsControllerUserInteraction key and the value True. You can manually add that entry to the Mac app target's Info.plist file by selecting the Mac app target from the project editor and clicking the Info button at the top of the project editor.
Topic: Graphics & Games SubTopic: GameKit Tags:
Feb ’22
Reply to how to have 2 functions with one button
You need a Boolean variable that tells you whether or not to run the first function. var shouldRunFirstFunction = true When the button is pressed, check the value of the Boolean variable. If it's true, run the first function. If it's false, run the second function. if buttonPressed { if shouldRunFirstFunction { firstFunction() shouldRunFirstFunction = false } else { secondFunction() shouldRunFirstFunction = true } } In a real app you should also change the button text after clicking the button to indicate you're doing something different each time you click the button. Otherwise people will be confused if clicking a button does one thing the first time and something else the second time.
Topic: UI Frameworks SubTopic: UIKit Tags:
Feb ’22
Reply to Mac OS Build Target
Projects and targets have separate deployment target settings. One of them probably has the deployment target set to macOS 11. Check the deployment target settings for both the Mac app target and the project and make sure they're both set to macOS 10.13.
Replies
Boosts
Views
Activity
Jan ’22
Reply to xcode 12.5.1 SpriteKit scene addchild fails reason already present
You can't add screenshots to comments.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to xcode 12.5.1 SpriteKit scene addchild fails reason already present
The exception is saying that you are trying to add a physics body that already exists. Does worldLayer have any physics bodies in it when you add the child to it? Do levelNode and mapNode have physics bodies? Did you add any physics bodies to anything in your .sks file? Do you have any code that creates physics bodies? If so, show the code as text, not as a screenshot. Code in a screenshot is hard to read. Can you add children without crashing if the SpriteKit nodes have no physics bodies?
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to SwiftUI App has disabled keyboard shortcuts on MacOS.
The keyboard shortcuts appearing disabled is the standard look for menu items in recent versions of macOS. If you look at the menus in Xcode the keyboard shortcuts look disabled but they work. I can't reproduce what you're experiencing. The keyboard shortcuts work in my SwiftUI Mac app projects. I created a new SwiftUI Mac app project in Xcode 13.2, and pressing Cmd-M minimizes the window. What are you seeing isn't expected behavior. You shouldn't have to write any code to make the standard keyboard shortcuts work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Documents in SwiftUI app have wrong file extension on Mac
The fix is to make the last part of the custom document UTI match the file extension, com.MyCompany.swiftbook. With that change the following code saves with the correct extension on Mac: static var bookDocumentPackage: UTType { UTType(exportedAs: "com.MyCompany.swiftbook", conformingTo: .package) } static var writableContentTypes: [UTType] { [.bookDocumentPackage, .epub] }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to xcode doesn't work
If you want someone to help you, you need to provide more detailed information about the problem. there is no window after running Is there no Xcode welcome window when you launch Xcode? Does no window open when you run your Xcode project? Or is there another problem? What are you expecting to see and what are you actually seeing? there is no prompt or interface What prompt? What interface? What are you expecting to see and what are you actually seeing? Until you provide detailed answers to these questions, no one can help you. The people on this forum can't see your screen. All they can see is what you write. And you haven't written much.
Replies
Boosts
Views
Activity
Jan ’22
Reply to Can Xcode run apps on iOS 12.5.5?
To get your app to run on iOS 12, you have to manually change the deployment target, the earliest version of iOS the app can run on, to iOS 12. When you create a new iOS app Xcode project, the deployment target for the app is the version of the iOS SDK that ships with Xcode. Xcode 13.2 ships with the iOS 15.2 SDK so new projects have the deployment target set to iOS 15.2. A new project won't run on earlier iOS versions until you change the deployment target. Use Xcode's project editor to change the deployment target. If you need detailed instructions on how to change the deployment target, read the article at the following URL: swiftdevjournal.com/supporting-older-versions-of-ios-and-macos/ Also make sure you choose Storyboard from the Interface menu when creating the project. New Xcode projects default to using SwiftUI for the user interface. Apple added SwiftUI in iOS 13 so SwiftUI apps won't run on iOS 12, no matter what you set the deployment target to.
Replies
Boosts
Views
Activity
Jan ’22
Reply to Let people post external links in answers
Feedback ID on this issue: FB9861235 I get the invalid domain error in both cases, pasting the whole URL and with the Markdown link syntax.
Replies
Boosts
Views
Activity
Jan ’22
Reply to Can i use spritekit without xcode ?
You need Xcode to create and build the SpriteKit project, but you can use Visual Studio Code to write the code. Select a Swift (or Objective-C if you're using that) file in the Finder, Get Info on the file, and tell the Finder to use Visual Studio Code as the default editor for Swift files. Double-clicking the Swift file in the Finder will open the file in Visual Studio Code. You can also select a Swift file in Xcode, right-click, and choose Open with External Editor. If you have an iPad that can run iOS 15, another alternative is to use Swift Playgrounds 4 and create a SpriteKit app in that. Create a SpriteView to show a SpriteKit scene in a SwiftUI app, which is what Swift Playgrounds lets you create.
Topic: Graphics & Games SubTopic: SpriteKit Tags:
Replies
Boosts
Views
Activity
Jan ’22
Reply to Older macs on BigSur won't be able to develop iOS 15.4+ apps anymore?
You can make apps that will run on iOS 15.4+ on Big Sur. An app you make with Xcode 13.2 will run on iOS 15.4. What you won't be able to do is use anything Apple adds in the iOS 15.4 and future SDKs. Another future problem you will have is that around April 2023 Apple will require (most likely) App Store submissions to be built with Xcode 14, which won't run on macOS 11.
Replies
Boosts
Views
Activity
Feb ’22
Reply to SceneKit in Swift Playgrounds
Use a SceneView to display a SceneKit scene in a Swift Playgrounds app. Working with SceneKit in the iPad Swift Playgrounds app is going to be tough. You must build your scene in code because Swift Playgrounds currently does not have a scene editor and provides no way to add a new SceneKit scene to the playground. The following Reddit thread may help: reddit.com/r/swift/comments/snodad/using_scenekit_on_ipad/
Replies
Boosts
Views
Activity
Feb ’22
Reply to Why I am not success to pass data from one view to another view for many data in SwiftUI?
The reason the image detail view always shows davis is because your image details view always uses the davis image model. struct ImageDetailsView: View {      var body: some View {          ImageDetails(data:  ImageModel(name: "davis"))   } } You need to add a property to the image details view that stores the image model to display. @Binding var imageModel: ImageModel Pass the property to ImageDetails. ImageDetails(data: $imageModel) I don't see any list code, but you have to create a @State property in the view that has the list to store the selected list item. @State private var selectedImage: ImageModel? = nil Your list code should contain a navigation link to the details view. NavigationLink(destination: ImageDetailsView(imageModel: $selectedImage)) Now the details view would show the selected image. But your code has a problem. In both ImageRowView and ImageDetails, you have the following property: var data: ImageModel SwiftUI views do not live long. When a change occurs to a view, SwiftUI creates a brand new view. When SwiftUI creates a new view, you will lose the contents of the data variable. In ImageRowView, you should declare a @State property like the selectedImage property I declared earlier. When you use @State, SwiftUI will keep the property when it creates a new view. In ImageDetails you should declare a @Binding property, like the imageModel binding I declared earlier, so it will show the selected image model. I can't guarantee that everything will work now, but it should get you towards a solution. If you need a working example, the GitHub project at the following URL provides an example of handling list selection and working with @State and @Binding: https://github.com/SwiftDevJournal/WikiDemo
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to Project cannot be opened because it is in a future Xcode project file format
Are you sure the project format is still Xcode 3.2 after working on the project in Xcode 13? Xcode 13 changed the project file format. Working on your project in Xcode 13 may have changed the project format to Xcode 13 so it won't open in Xcode 10. Other people ran into a similar issue, and the fix was to open the project in Xcode 13 and set the project format to an earlier Xcode version.
Replies
Boosts
Views
Activity
Feb ’22
Reply to How to add GameController support into macOS app
According to the WWDC 2021 session on game controllers, adding the Game Controller capability adds an entry to Info.plist with the GCSupportsControllerUserInteraction key and the value True. You can manually add that entry to the Mac app target's Info.plist file by selecting the Mac app target from the project editor and clicking the Info button at the top of the project editor.
Topic: Graphics & Games SubTopic: GameKit Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to how to have 2 functions with one button
You need a Boolean variable that tells you whether or not to run the first function. var shouldRunFirstFunction = true When the button is pressed, check the value of the Boolean variable. If it's true, run the first function. If it's false, run the second function. if buttonPressed { if shouldRunFirstFunction { firstFunction() shouldRunFirstFunction = false } else { secondFunction() shouldRunFirstFunction = true } } In a real app you should also change the button text after clicking the button to indicate you're doing something different each time you click the button. Otherwise people will be confused if clicking a button does one thing the first time and something else the second time.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Feb ’22