#AmplifyModels.swift types not in scope

1 messages · Page 1 of 1 (latest)

digital spade
#

I am building an iMessage Extension in Xcode using Amplify as my backend. I already have a cross-platform React Native app using the same Amplify backend. I have already created the Xcode repo for an App with an iMessage Extension as a target as well. I added all the package dependencies and pulled my backend environment. I then ran the command to add the models. I added the iMessage Extension as a target for the AmplifyModels.swift file.
In updating those files, I do not get any errors for either file but do get errors for each model type in the AmplifyModels.swift file. Here is the code for the AmplifyModels.swift file:
// swiftlint:disable all
import Amplify
import Foundation

// Contains the set of classes that conforms to the Model protocol.

final public class AmplifyModels: AmplifyModelRegistration {
public let version: String = "aaa9d5f7fc8695eb8cfd51fd2ac2f739"

public func registerModels(registry: ModelRegistry.Type) {
ModelRegistry.register(modelType: User.self)
ModelRegistry.register(modelType: ContactList.self)
ModelRegistry.register(modelType: Contact.self)
ModelRegistry.register(modelType: Group.self)
ModelRegistry.register(modelType: Event.self)
ModelRegistry.register(modelType: Rsvp.self)
ModelRegistry.register(modelType: StoreVersion.self)
ModelRegistry.register(modelType: GroupUser.self)
}
}

I get the following errors:
Cannot find 'User' in scope
Cannot find 'ContactList' in scope
Cannot find 'Contact' in scope
Cannot find 'Group' in scope
Cannot find 'Event' in scope
Cannot find 'Rsvp' in scope
Cannot find 'StoreVersion' in scope
Cannot find 'GroupUser' in scope.

#

Here is the code for the JuegosApp.swift file:
//
// JuegosApp.swift
// Juegos
//
// Created by Juegos Apple 1 Computer on 6/3/24.
//

import SwiftUI
import Amplify
import AWSDataStorePlugin
import AWSPluginsCore

func configureAmplify() {
let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels())
do {
try Amplify.add(plugin: dataStorePlugin)
try Amplify.configure()
print("Initialized Amplify")
} catch {
print("Could not initialize Amplify: (error)")
}
}

@main
struct JuegosApp: App {
init() {
configureAmplify()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Here is the code for the iMessage Extension MessagesViewController:
//
// MessagesViewController.swift
// JuegosMessageExtension
//
// Created by Juegos Apple 1 Computer on 6/3/24.
//

import UIKit
import Messages
import Amplify
import AWSPluginsCore
import AWSCognitoAuthPlugin
import AWSAPIPlugin
import AWSDataStorePlugin

class MessagesViewController: MSMessagesAppViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
    do {
        let dataStorePlugin = AWSDataStorePlugin(modelRegistration: AmplifyModels())
        try Amplify.add(plugin: dataStorePlugin)
        try Amplify.add(plugin: AWSCognitoAuthPlugin())
        try Amplify.configure()
            print("Amplify initialized")
        } catch {
            print("Failed to initialize Amplify: (error)")
        }
}

// MARK: - Conversation Handling
(REST of file code)

}

#

@manic mural @dense pilot @drowsy tiger