Swift Student Challenge

RSS for tag

Ask questions and connect with other challenge applicants.

Swift Student Challenge Documentation

Posts under Swift Student Challenge tag

138 Posts
Sort by:
Post not yet marked as solved
0 Replies
235 Views
This is the content view which moves down on the screen as I open it from different view. when I click top left button to open menu. The menu When I click the Home option from menu whole view moves down on screen. The whole view gets moved down on screen each time I open it. //the content view import SwiftUI struct ContentView: View {     var body: some View {                       NavigationView{                               ScrollView{                      Text("Men")                          .font(.system(size: 30, weight:.bold))                      .padding(.trailing, 320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:mentshirt()){                          custom(content:Image("mentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:menjeans()){                          custom(content:Image("menjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:menjacket()){                          custom(content:Image("menjacket"),over: "Jacket",col: .black)                          }                      }                  }                      Text("Women")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,280.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:womentshirt()){                          custom(content:Image("womentshirt"),over:"T-shirt",col: .black)                          }                          NavigationLink(destination:womenjeans()){                          custom(content:Image("womenjeans"),over:"Jeans",col: .black)                          }                          NavigationLink(destination:womenjacket()){                          custom(content:Image("womenjacket"),over:"Jacket",col: .black)                          }                      }                  }                      Text("Kids")                          .font(.system(size: 30,weight: .bold))                          .padding(.trailing,320.0)                  ScrollView(.horizontal){                      HStack{                          NavigationLink(destination:kidtshirt()){                              custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)                      }                          NavigationLink(destination:kidjeans()){                          custom(content:Image("kidjeans"),over:"Jeans",col: .black)                          }                              NavigationLink(destination:kidjacket()){                          custom(content:Image("kidjacket"),over:"Jacket",col:.black)                              }                      }                  }                  }                  .navigationBarBackButtonHidden(true)                  .navigationBarItems(leading:                                          NavigationLink(                                          destination: clothlist()){                                                  navcustom(content:                                                             Image(systemName: "line.horizontal.3"),col: .white)                          },                      trailing:                              HStack{                      Image("logo")                          .resizable()                          .clipShape(Circle())                          .shadow(color:.white,radius: 10)                          .frame(width: 30, height: 30, alignment: .center)                              Spacer(minLength: 80)                          NavigationLink(destination: cart()){                              navcustom(content:                                         Image(systemName: "cart"),col: .white)                          }                          Spacer(minLength: 15)                              NavigationLink(destination: login()){                                  navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)                              }                          }                  )              }.navigationBarBackButtonHidden(true)             .ignoresSafeArea()         } } struct ContentView_Previews: PreviewProvider {     static var previews: some View {         Group {               ContentView()                 .environment(\.colorScheme, .dark)         }     } } func custom(content:Image,over:String,col:Color) -> some View {     content         .resizable()         .overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)         .frame(width: 400, height: 500, alignment: .center)         .padding(5)                        } func navcustom(content:Image,col:Color)-> some View {     content         .resizable()         .frame(width: 30, height: 30, alignment: .center)         .foregroundColor(col) } //the menu view from which I open content view import SwiftUI struct clothlist: View {     var body: some View {         List         {             NavigationLink(destination:ContentView())             {             Text(Image(systemName: "house"))+Text(" Home")             }             Text(Image(systemName: "person"))+Text(" Men")             NavigationLink(destination:menjeans())             {             Text("Jeans")             }             NavigationLink(destination:menjacket())             {             Text("Jacket")             }             NavigationLink(destination:mentshirt())             {             Text("Tshirt")             }             Text(Image(systemName: "person"))+Text(" Women")             NavigationLink(destination:womenjeans())             {             Text("Jeans")             }             NavigationLink(destination:womenjacket())             {             Text("Jacket")             }             NavigationLink(destination:womentshirt())             {             Text("Tshirt")             }             Group{             Text(Image(systemName: "person"))+Text(" Kids")             NavigationLink(destination:kidjeans())             {             Text("Jeans")             }             NavigationLink(destination:kidjacket())             {             Text("Jacket")             }             NavigationLink(destination:kidtshirt())             {             Text("Tshirt")             }             }         }         .navigationBarBackButtonHidden(true)     } } struct clothlist_Previews: PreviewProvider {     static var previews: some View {         clothlist()     } } how to stop the view from moving down on screen on every open?
Posted
by
Post not yet marked as solved
0 Replies
228 Views
this below is the view which doesn't remove the columns after I click the delete button and it shows the data even after it is removed from the firestore unless relaunched the app. import SwiftUI import Firebase struct user:Identifiable{     @State var id:String=""     @State var productnm:String=""     @State var quan:String="" } class mainviewmodel:ObservableObject{     @Published var use = [user]()     init(){         fetchCurrentUser()     }      func fetchCurrentUser(){          guard let uid = Firebase.Auth.auth().currentUser?.uid else {             return         }          FirebaseManager.shared.firestore.collection("users").document(uid).collection("product").getDocuments{snapshot,error in              if error==nil{                              //no errors                 if let snapshot = snapshot{                     //update the user property in the main thread                 DispatchQueue.main.async {                     //                        //get all the documents and create user                                             self.use=snapshot.documents.map{ d in //map will iterate over array and perform code on each item                                                 //create an new user for each document returned                                                 return  user(id: d.documentID,productnm: d["product name"] as? String ?? "",                                                              quan: d["quantity"] as? String ?? "")                                             }                                         }                                                          }                  print("no data found")                                                   }                                 else{                                     print("no data found")                                 }         }     } } struct cart: View {     @ObservedObject var model=mainviewmodel()     @ObservedObject  var vm = mainviewmodel()     @State var productnm:String=""     @State var quantity:String=""     @State var address:String=""     @State var payment:String=""     var body: some View{         VStack{         HStack{             Text("Cart")             navcustom(content:                        Image(systemName: "cart"),col: .white)         Button(action: {vm.fetchCurrentUser()         }, label: {navcustom(content:                                 Image(systemName: "repeat.circle.fill"),col: .blue)})         }             List(model.use) {item in                     HStack(spacing: 16) {                         Image(systemName: "person.fill")                         .font(.system(size: 32))                             Text("\(item.productnm)")                             Text("\(item.quan)")                             }                 Button(action: {deleteuser(productnm: item.productnm, quan: item.quan, id: item.id)}, label: {Text("Delete")})                 Button(action: {if(address==""){Text("Enter the delivery address!").foregroundColor(.red)}else{buying(productnm: item.productnm, quantity: item.quan, address: address)}                     deleteuser(productnm: item.productnm, quan: item.quan, id: item.id)                 }, label: {Text("BUY")})                 }             Text("Delivery Address:")             TextField("", text:$address)                 .foregroundColor(.white)                 .frame(width: 295)                 .textFieldStyle(.roundedBorder)                  }     }     func deleteuser(productnm:String,quan:String,id:String){         guard let uid = Firebase.Auth.auth().currentUser?.uid else {            return        }         FirebaseManager.shared.firestore.collection("users").document(uid).collection("product").document(id).delete(){ err in             if let err = err {               print("Error removing document: \(err)")             }             else {               print("Document successfully removed!")                              }     }     }     func buying(productnm:String,quantity:String,address:String){             guard let uid = FirebaseManager.shared.auth.currentUser?.uid else { return }         let userData = ["user":uid,"product name":productnm,"quantity":quantity,"address":address]             FirebaseManager.shared.firestore.collection("purchase").document(uid).collection("product").addDocument(data: userData)             { err in                 if let err = err{                     print(err)                     return                 }             }     } } struct cart_Previews: PreviewProvider {     static var previews: some View {         Group {               cart()                 .environment(\.colorScheme, .dark)         }     } }
Posted
by
Post not yet marked as solved
3 Replies
381 Views
Something wrong with Readline. I can't use readLine()!)! My code is really simple: var aYear = Int(readLine()!)! func isLeap(year: Int) {       var leap = "NO"       //IF divisible by 4 with no remainders.   if year % 4 == 0 {     leap = "YES"     //Is leap year, unless:   }   if year % 100 == 0 {     leap = "NO"     //Is not leap year, unless:   }   if year % 400 == 0 {     leap = "YES"     //Is leap year.   }   print(leap)   } //Don't change this isLeap(year: aYear) This error keeps coming up. I can't figure out how to fix this error: "__lldb_expr_122/readline .playground:1: Fatal error: Unexpectedly found nil while unwrapping an Optional value Playground execution failed: error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18f494588). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation." It is really strange because in online compiler this simple code works just fine. PLEASE HELP ME. I CAN'T FIND THE SOLUTION. It's kinda internal xcode error or what...
Posted
by
Post marked as solved
1 Replies
283 Views
Hello, I am planning on creating a project for the WWDC22 Swift Student Challenge if there is one, and I had a question about a rule for the WWDC21 challenge. In the rules it says "Submissions will be judged offline. Your Swift playground should not rely on a network connection." Additionally, in the terms and conditions of the challenge, it says that you may be disqualified if "your Swift playground requires sign in." If this is true, what type of projects is Apple looking for? Games? And if so, are projects that would have a big impact but an internet connection (for a map, for example) completely disqualified? The only reason I'm asking is because on a newsroom post from Apple about the WWDC21 winners, Apple showcases the app "Feed Fleet" that does require sign in and I assume an internet connection. Thank you in advance for any answers!
Posted
by
Post not yet marked as solved
3 Replies
351 Views
Hello world! I'm planning to participate in this year's WWDC22. And I have a question: for participating at the Challenge I need to provide Educational Supervisor's Contact Information, can I enter the information of my teacher, who is also my class coordinator?
Posted
by
Post marked as solved
1 Replies
177 Views
I currently have the code below that I want to change views but it will not change to the GoalView() NavigationLink(destination: GoalView()) {                 Button("Next \(Image(systemName: "chevron.forward"))") {                 }             }             .padding(.bottom, 30)             .foregroundColor(.green)
Posted
by
Post marked as solved
2 Replies
303 Views
Hello all, I was wondering in the Swift Student Challenge requirements, it states: All content should be in English. What if my game is mainly in English (UI, main content,) but some foreign language (glyph to be specific) is used as part of app. The judge should be able to use the app without any fluency other than English. Will including some foreign language disqualify my entry? Thank you so much for answering my question. Nico
Posted
by
Post marked as solved
1 Replies
190 Views
Hi! I'm currently working on my Swift Student Challenge project and I wanted to know whether or not I'd be allowed to use a live camera feed on my application while programming on Xcode. Since it isn't an app on a mobile device like an iPad, I wasn't sure if everyone would be able to access the live feed feature.
Posted
by
Post marked as solved
1 Replies
281 Views
anyone know how to fix this xcode bug? I am building in swift for the SwiftStudentChallenge. @main struct MyApp: App {     var body: some Scene {         WindowGroup {             run; /Users/christopherrobinson/Documents/WWDC22; Scene.app             ContentView()         }     } }
Posted
by
Post not yet marked as solved
2 Replies
371 Views
Can I use the Swift Playgrounds Mac application to code for the 2022 Swift Student Challenge? On 2021, it says that I can use the Swift Playgrounds Mac application but on 2022, it only says XCode on Mac or Swift Playground on iPad. Thank you in advanced.
Posted
by
Post not yet marked as solved
1 Replies
224 Views
This year it said "Swift Playgrounds app project", and must be a .swiftpm file, so does it means no playground book for this year? In fact, last year it mentioned "Swift playground", it includes playground book. Thanks.
Posted
by
Post not yet marked as solved
1 Replies
143 Views
Hello, I am developing Swift Playground App on Xcode in order to apply Swift Student Challenge. Is it enough to just run my app on iPhone or also should i run on iPad? And will people who win the competition can attend WWDC in person?
Posted
by
Post not yet marked as solved
5 Replies
641 Views
I am 14 years old and would like to participate in the Swift Student Challenge @ WWDC23. I have no experience programming in Swift or any other programming language. What do you suggest to learn Swift?
Posted
by
Post marked as solved
1 Replies
198 Views
The requirements specify to "Create an interactive scene in a Swift Playgrounds app project that can be experienced within three minutes." I had some questions about this. First, there is no technical definition for interactive scene that I should be referencing right? Just some sort of interactive model? I also wanted to clarify: this cannot be a book? I know that only iPad versions of Playgrounds can create apps so if we want to create on a Mac, we use Xcode Playground App right? Sorry for the basic question but if we are using Xcode to create the Playground app what is the difference between this and a standard Swift app? Lastly do we only have to have the app work on Mac or iPad or should they work with both/have dynamic sizing. Basically here are my questions. 1: Interactive scene is very broad right? Are there any specific limitations? 2: Are books eligible? 3: Where can we create the project (Xcode, iPad Playgrounds, etc) 4: What is the difference between this and a standard Swift app? 5: Is the program only being tested on our specified environment or should it be dynamic? Thank you!
Posted
by