PROBLEM WITH UPLOADING MY APP TO THE APP STORE
Hello. I have a new version of my app in the app store. And I am trying to upload it. But I am running into problems.
The app runs well when I run the app on my iPhone or in the simulator. But when I try to upload it to the app store, it gives me an error message.
The error message is: Type 'MenuItem' has no member 'example'
What am I doing wrong?
..........................................................................................................................................
appDelegate
import UIKit
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
..........................................................................................................................................
ConentView
import SwiftUI
struct ContentView: View {
let menu = Bundle.main.decode([MenuSection].self, from: "menu.json")
var body: some View {
NavigationView {
List {
ForEach(menu) { section in
Section(header: Text(section.name)) {
ForEach(section.items) { item in ItemRow(item: item)
}
}
}
}
.navigationBarTitle("Full Self Drive 365")
.listStyle(GroupedListStyle())
}
}
}
struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
..........................................................................................................................................
Item Row
import SwiftUI
struct ItemRow: View { var item: MenuItem
var body: some View {
NavigationLink(destination: ItemDetail(item: item)) {
HStack {
Image(item.thumbnailImage)
.clipShape(Circle())
.overlay(Circle().stroke(Color.blue, lineWidth: 2))
Text(item.name)
}
}
}
}
struct ItemRow_Previews: PreviewProvider { static var previews: some View { ItemRow(item: MenuItem.example)
}
}
..........................................................................................................................................
Item Detail
import SwiftUI
struct ItemDetail: View { var item: MenuItem
var body: some View {
VStack {
ZStack(alignment: .bottomTrailing) {
Image(item.mainImage)
}
ScrollView {
Text(item.recipe)
.padding()
.font(.headline)
Text(item.ingredient)
.font(.subheadline)
.padding()
Text(item.instruction)
.padding()
.font(.subheadline)
Text(item.emTipTitle)
.padding()
.font(.headline)
Text(item.emTip)
.padding()
.font(.subheadline)
Spacer()
}
}.navigationBarTitle(Text(item.name), displayMode: .inline)
}
}
..........................................................................................................................................
Menu
import SwiftUI
struct MenuSection: Codable, Identifiable { var id: UUID var name: String var items: [MenuItem] }
struct MenuItem: Codable, Equatable, Identifiable { var id: UUID var name: String var recipe: String var ingredient: String var instruction: String var emTipTitle: String var emTip: String
var mainImage: String {
name.replacingOccurrences(of: " ", with: "-").lowercased()
}
var thumbnailImage: String {
"\(mainImage)-thumb"
}
#if DEBUG
static let example = MenuItem(id: UUID(), name: "Maple French Toast", recipe: "Breakfast Icecream", ingredient: "Sweet, fluffy, and served piping hot, our French toast is flown in fresh every day from Maple City, Canada, which is where all maple syrup in the world comes from. And if you believe that, we have some land to sell you…", instruction: "Cook it", emTipTitle: "Energy management", emTip: "Practice 5 minute rule")
#endif
}
struct Menu_Previews: PreviewProvider { static var previews: some View { Text("Full Self Drive 365!") } }
..........................................................................................................................................
order
import SwiftUI
class Order { var items = [MenuItem] ()
func add(item: MenuItem) {
items.append(item)
}
func remove(item: MenuItem) {
if let index = items.firstIndex(of: item) {
items.remove(at: index)
}
}
}
struct Order_Previews: PreviewProvider { static var previews: some View { /@START_MENU_TOKEN@/Text("Hello, World!")/@END_MENU_TOKEN@/ } }
..........................................................................................................................................
Thanks so much.
Did that fix it for you, @arasharcher?