투케이2K

341. (TWOK/ERROR) [Ios] Cannot load network ... Failed to add network to Espresso plan 본문

투케이2K 에러관리

341. (TWOK/ERROR) [Ios] Cannot load network ... Failed to add network to Espresso plan

투케이2K 2025. 12. 28. 14:07
728x90

[환경 설정 및 설명]

프로그램 : Xcode

설 명 : [Ios] Cannot load network ... Failed to add network to Espresso plan

 

[설 명]

 

--------------------------------------------------------------------------
[개발 및 테스트 환경]
--------------------------------------------------------------------------

- 제목 : [Ios] Cannot load network ... Failed to add network to Espresso plan


- 테스트 환경 : Xcode / Ios


- 사전) VNDetectBarcodesRequest 간단 설명 및 사용 범위 : 

  >> Apple 공식 / 안정적

  >> import Vision 만 하면 바로 사용 가능

  >> QR 코드 디코딩 가능

  >> 1D / 2D 바코드 디코딩 가능

  >> 이미지 파일 디코딩 가능

--------------------------------------------------------------------------





--------------------------------------------------------------------------
[에러 원인]
--------------------------------------------------------------------------

1. Xcode 에서 VNDetectBarcodesRequest 를 사용해 QR 및 Barcode 이미지 스캔 및 디코딩 기능 개발 시 

   실제 휴대폰 기기가 아닌 시뮬레이터에서 해당 기능을 동작 시켜 발생하는 이슈


2. VNDetectBarcodesRequest의 일부 바코드/QR 인식은 iOS 시뮬레이터에서 정상 동작하지 않을 수 있습니다.


3. 특히 iOS 17 시뮬레이터에서는 Quagga / Espresso(CoreML) 모델 로딩 실패 로그가 발생하고 결과가 “바코드 없음”으로 떨어지는 경우가 많습니다.


4. 에러 발생 전체 로그 : 

[Espresso::handle_ex_plan] exception=Cannot load network 

'/Library/Developer/CoreSimulator/Volumes/../System/Library/PrivateFrameworks/Quagga.framework/QuaggaNeuralNetworks.bundle/anmd-model.espresso.net' Failed to add network
"/Library/Developer/CoreSimulator/Volumes/iOS_21A342/Library/Developer/CoreSimulator/Profiles/../Quagga.framework/QuaggaNeuralNetworks.bundle/anmd-model.espresso.net" to Espresso plan, reason: ESPRESSO_STATUS_ERROR_GENERIC

--------------------------------------------------------------------------





--------------------------------------------------------------------------
[해결 방법]
--------------------------------------------------------------------------

1. VNDetectBarcodesRequest 를 사용해 QR 및 Barcode 이미지 스캔 시 실제 Ios 휴대폰 기기를 사용해 디버깅 수행


2. QR 및 Barcode 스캔 소스 코드 첨부 : 

    // ✅ 메소드 인풋 파라미터 정보 : getQrBarcodeImageFileScan(image: UIImage?, completion: @escaping (String)->())


    // ✅ png 파일인 경우 투명 알파 제거
    let renderer = UIGraphicsImageRenderer(size: image!.size)

    let img = renderer.image { _ in
            UIColor.white.setFill()
            UIRectFill(CGRect(origin: .zero, size: image!.size))
            image!.draw(at: .zero)
    }


    // cgImage 변경 수행
    guard let cgImage = img.cgImage
    else {
        S_Log._E_(description: "QR 및 Barcode 저장 된 이미지 스캔 에러 발생", data: ["[Error] : CGImage 변환 실패"])
        return
    }


    // VNDetectBarcodesRequest 객체 생성
    let request = VNDetectBarcodesRequest { request, error in
        if let error = error {
            S_Log._E_(description: "QR 및 Barcode 저장 된 이미지 스캔 에러 발생", data: ["[Error] : Vision - " + error.localizedDescription])
            return
        }

        guard let results = request.results as? [VNBarcodeObservation], !results.isEmpty
        else {
            S_Log._E_(description: "QR 및 Barcode 저장 된 이미지 스캔 에러 발생", data: ["[Error] : Vision - Result Not Found"])
            return
        }

        for barcode in results { // ✅ 결과 확인
            print("Qr 및 Barcode 스캔 : Vision - 심볼 : ", barcode.symbology.rawValue)
            print("Qr 및 Barcode 스캔 : Vision - 값 : ", barcode.payloadStringValue ?? "nil")
        }
        
    }


    // 🔑 QR + Barcode 동시 허용
    request.symbologies = [
        .QR,
        .EAN13,
        .EAN8,
        .UPCE,
        .Code128,
        .Code39,
        .Code93,
        .PDF417,
        .DataMatrix,
        .Aztec
    ]

    let handler = VNImageRequestHandler(cgImage: cgImage, options: [:])

    do {
        try handler.perform([request])
    } catch {
        S_Log._E_(description: "QR 및 Barcode 저장 된 이미지 스캔 에러 발생", data: ["[Exception] : Vision - " + error.localizedDescription])
    }

--------------------------------------------------------------------------





--------------------------------------------------------------------------
[참고 사이트]
--------------------------------------------------------------------------

[라이브러리] [Ios] QRCodeReader (Swift / Camera / QR)

https://blog.naver.com/kkh0977/222915053266?trackingCode=blog_bloghome_searchlist


[라이브러리] [Ios] QRCode (Swift / Camera / QR)

https://blog.naver.com/kkh0977/222915071986?trackingCode=blog_bloghome_searchlist


[Mobile] 모바일 ( android , ios ) 에서 QR 코드 생성 시 화면 밝기 및 QR 코드 사이즈 최대 표시 Alert 팝업창 활성

https://blog.naver.com/kkh0977/223624876714?trackingCode=blog_bloghome_searchlist


[Mobile] 모바일 ( android , ios ) 에서 QR 코드 스캔 후 정보 확인 및 다시 스캔 로직 수행

https://blog.naver.com/kkh0977/223624907452?trackingCode=blog_bloghome_searchlist

--------------------------------------------------------------------------
 
728x90
반응형
Comments