Post

Replies

Boosts

Views

Activity

Swift Playgrounds Incompatibility with Xcode 16 Files and Swift Versions
I'm facing an issue with Swift Playgrounds and files created in Xcode 16. It seems that Swift Playgrounds does not support Swift 6, but even when I create files specifically with Swift 5, Swift Playgrounds still reports that the files are unsupported. This creates a significant problem because macOS Sequoia does not allow me to revert to Xcode 15, which might have offered better compatibility. As it stands, I can't find a solution to work seamlessly between Xcode and Swift Playgrounds. Has anyone else encountered this issue? Are there any workarounds or updates planned to address this compatibility gap? Any advice would be greatly appreciated!
2
0
94
3d
Swift unable to find sound file
Hi everyone, I'm currently facing an issue with AVAudioPlayer in my SwiftUI project. Despite ensuring that the sound file "buttonsound.mp3" is properly added to the project's resources (I dragged and dropped it into Xcode), the application is still unable to locate the file when attempting to play it. Here's the simplified version of the code I'm using: import SwiftUI import AVFoundation struct ContentView: View { var body: some View { VStack { Button("Play sound") { playSound(named: "buttonsound", ofType: "mp3") } } } } func playSound(named name: String, ofType type: String) { guard let soundURL = Bundle.main.url(forResource: name, withExtension: type) else { print("Sound file not found") return } do { let audioPlayer = try AVAudioPlayer(contentsOf: soundURL) audioPlayer.prepareToPlay() audioPlayer.play() } catch let error { print("Error playing sound: \(error.localizedDescription)") } }
7
0
1.6k
Feb ’24
Xcode 13 - Swift compile error
Dear community, Yesterday I update Xcode from 12.5.1 to 13.0 and I came across a lot of compile error. Until before the update all was working great, but I suppose probably some syntax rules changes with the update for iOS 15.  .background(Color.systemBlue) error: Type 'Color' has no member 'systemBlue'  .maxWidth(.infinity) error: Cannot infer contextual base in reference to member 'infinity' Value of type 'Image' has no member 'maxWidth' .aspectRatio(contentMode: .fit) error: Cannot infer contextual base in reference to member 'fit'  Image(.system("line.horizontal.3.circle.fill")) error: Type 'String' has no member 'system' .font(.largeTitle, weight: .bold) errors: - Cannot infer contextual base in reference to member 'bold' - Extra argument 'weight' in call  Image(section.logo) .resizable() .height(32) error: Value of type 'Image' has no member 'height' Command CompileSwift failed with a nonzero exit code I hope that this one will fix by itself Basically I got 23 errors... and the code before yesterday was working great. Thanks to those who will help me, hoping it will be useful to other users, Martin
2
0
2.8k
Oct ’21
How to pass variables between .swift files.
Hi, I'm new in coding :), I have a struct that contains variables in a .swift file. I need these datas on another .swift file. How can I import them? (They're on a SwiftUI based app) I have this on the first .swift file   struct MyVariables { static var infoProduct = "" static var idProduct = "" }      I have to use the infoProduct var on the other file Thanks
4
0
3.1k
Dec ’20
Open a ViewController from Swift UI button
Hi, I state that I am a self-taught developer, so I apologize if I will ask you some trivial questions. I developed an app in UIkit, but later decided to use Swift UI for the main grafic interface, implementing it on a HostingViewController. I wanted to ask if and how it is possible to make a button (SwiftUI button) open another ViewController (based on UiKit) Thanks guys :)
1
0
4k
Oct ’20