Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to build iOS app in flutter project #85

Closed
Robopicker opened this issue Dec 2, 2023 · 6 comments
Closed

not able to build iOS app in flutter project #85

Robopicker opened this issue Dec 2, 2023 · 6 comments
Labels
pending-community-response Issue is pending response from the issue requestor question Further information is requested

Comments

@Robopicker
Copy link

Hi Team, I am integrating aws-ui-swift-liveness in the Flutter app, I installed the dependencies using SPMs but when I am building an app on a real iPhone device it it takes forever time to build. Meanwhile, I have few questions on which I need some clarity as well.
questions:-

  1. is it possible to download dependencies through Cocoapods? As far as I know, cocoapods is used in the Flutter app, and installing dependencies through SPM is not supported.
  2. is there any workaround for making things right with AWS liveness in Flutter projects?

building logs:-
building logs.txt

@Robopicker
Copy link
Author

this is the error I am getting everytime.
RegisterExecutionPolicyException /Users/yogesh/Library/Developer/Xcode/DerivedData/Runner-cmobrqtbhrgecxfzmoeybbusxhpb/Build/Products/Debug-iphoneos/FaceLiveness.o (in target 'FaceLiveness' from project 'AmplifyUILiveness')
cd /Users/yogesh/Desktop/amplify-ui-swift-liveness
builtin-RegisterExecutionPolicyException /Users/yogesh/Library/Developer/Xcode/DerivedData/Runner-cmobrqtbhrgecxfzmoeybbusxhpb/Build/Products/Debug-iphoneos/FaceLiveness.o

@yogeshelevn
Copy link

@phantumcode please help me with this problem. I am still stuck on this issue. you help will save me lot of time and effort.

@phantumcode
Copy link
Contributor

@Robopicker Thanks for submitting your issue. In regards to your question:

  1. We do not support Cocoapods
  2. Can you provide additional details or clarifications for what this means? "is there any workaround for making things right with AWS liveness in Flutter projects?" What issue or error are you running into and can you provide a sample app to help reproduce the issue?

For integrating native components in a Flutter app, please reference the following documentation:

@phantumcode phantumcode added question Further information is requested pending-community-response Issue is pending response from the issue requestor labels Dec 5, 2023
@Robopicker
Copy link
Author

@phantumcode Thanks for the info. I was able to successfully integrate aws amplify face verification. closing this issue.

@Linkadi98
Copy link

hi @Robopicker, I am late to the issue but I am struggling when integrating this project to flutter app. Can you please provide an example or a guide to make this happen. I aware of this project doesn't support Cocoapods and what I have tried is turning this project to a Cocoapods project then tried to put it to a flutter plugin, but not working. I have tried to compile this project to xcframework which can be used in a fresh Cocoapods project to integrate to flutter app but still cannot figure out a way to make this happen.

@Robopicker
Copy link
Author

Robopicker commented Nov 12, 2024

@Linkadi98 Thanks for reaching out. I am sharing a code snippet for the Aws Verification controller and AppDelegate file. this code will help out. Keep in mind that you first need to generate a session ID through your backend services and pass that session ID through the flutter channel to the native side. Do let me know if you need further help.

AppDelegate file :-

import UIKit
import Flutter
import Amplify
import AWSCognitoAuthPlugin

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.configure()
            print("Amplify configured with auth plugin")
        } catch {
            print("Failed to initialize Amplify with \(error)")
              }
      let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
      let methodChannel = FlutterMethodChannel(name: "LIVE_VERIFICATION_CHANNEL", binaryMessenger: controller.binaryMessenger)
      methodChannel.setMethodCallHandler { [weak self] (call, result) in
            if call.method == "startLiveVerification" {
                guard let args = call.arguments as? [String: Any],
                      let sessionId = args["sessionId"] as? String else {
                                 result(FlutterError(code: "INVALID_ARGUMENT", message: "Invalid session Id",details: nil))
                                    return
                                }
                print("session id is \(sessionId)")
                let faceLivenessController = FaceLiveDetectionController()
                faceLivenessController.sessionId = sessionId
                faceLivenessController.flutterResult = result
                faceLivenessController.modalPresentationStyle = .fullScreen
                controller.present(faceLivenessController,
                                                                animated: true,
                                                                completion: nil)
            } else {
              result(FlutterMethodNotImplemented)
            }
          }

    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    }
    
    GeneratedPluginRegistrant.register(with: self)
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

FaceLivenessController :-

//
//  FaceLiveDetectionController.swift
//  Runner
//
//  Created by Yogesh on 05/12/23.
//

import Foundation
import SwiftUI
import UIKit
import FaceLiveness

class FaceLiveDetectionController: UIViewController {
    var sessionId: String?
    var flutterResult: FlutterResult!
    var hostingController: UIHostingController<FaceLivenessDetectorView>?
    override func viewDidLoad() {
        super.viewDidLoad();
        configureFaceDetection()
    }
    private func configureFaceDetection() {
        if let sessionID = self.sessionId {
            let faceView = FaceLivenessDetectorView(
                sessionID: sessionID,
                region: 'your-region-code",
                disableStartView: true,
                isPresented: .constant(true),
                onCompletion: { result in
                    DispatchQueue.main.async {
                        switch result {
                        case .success:
                            self.callback("success")
                        case .failure(let error):
                            self.callback(error.message)
                        }
                    }
                })
            hostingController = createHostingController(with: faceView)
            addHostingControllerAsChild(hostingController!)
            configureConstraints(for: hostingController!.view)
        }
        
    }
    
    private func callback(_ res: String) {
        hostingController?.dismiss(animated: true, completion: nil)
        if (res == "success") {
            flutterResult("success")
        } else {
            flutterResult(FlutterError(code: "error", message: res,details: nil))
        }

    }

    private func createHostingController(with rootView: FaceLivenessDetectorView) -> UIHostingController<FaceLivenessDetectorView> {
            return UIHostingController(rootView: rootView)
        }

        private func addHostingControllerAsChild(_ hostingController: UIHostingController<FaceLivenessDetectorView>) {
            addChild(hostingController)
            view.addSubview(hostingController.view)
        }

        private func configureConstraints(for view: UIView) {
            view.translatesAutoresizingMaskIntoConstraints = false
            NSLayoutConstraint.activate([
                view.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 10),
                view.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
                view.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
                view.trailingAnchor.constraint(equalTo: self.view.trailingAnchor)
            ])
        }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-community-response Issue is pending response from the issue requestor question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants