Skip to content

iOS framework built with Xcode older than version 12.5 has Swift type conflicts on 12.5 #19992

@heshuimu

Description

@heshuimu
System information (version)
  • OpenCV => 4.5.2
  • Operating System / Platform => iOS
  • Compiler => Xcode
Detailed description

iOS framework built with Xcode older than version 12.5 has Swift type conflicts on 12.5. Rebuilding the framework with Xcode 12.5 made the issue disappear.

The following are just two examples out of the dozen errors thrown.

.../opencv2.framework/Modules/opencv2.swiftmodule/arm64-apple-ios.swiftinterface:29:122: error: ambiguous type name 'Size' in module 'opencv2'
  @nonobjc public class func calibrateCamera(objectPoints: [opencv2.Mat], imagePoints: [opencv2.Mat], imageSize: opencv2.Size, cameraMatrix: opencv2.Mat, distCoeffs: opencv2.Mat, rvecs: inout [opencv2.Mat], tvecs: inout [opencv2.Mat], stdDeviationsIntrinsics: opencv2.Mat, stdDeviationsExtrinsics: opencv2.Mat, perViewErrors: opencv2.Mat, flags: Swift.Int32, criteria: opencv2.TermCriteria) -> Swift.Double
                                                                                                                 ~~~~~~~ ^
opencv2.Size:1:12: note: found candidate with type 'Size'
open class Size : NSObject {
           ^
Darwin.Size:1:18: note: found candidate with type 'Size' (aka 'Int')
public typealias Size = Int

.../opencv2.framework/Modules/opencv2.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:520:94: error: ambiguous type name 'Point' in module 'opencv2'
  @nonobjc public class func goodFeaturesToTrack(image: opencv2.Mat, corners: inout [opencv2.Point], maxCorners: Swift.Int32, qualityLevel: Swift.Double, minDistance: Swift.Double, mask: opencv2.Mat, blockSize: Swift.Int32, useHarrisDetector: Swift.Bool)
                                                                                     ~~~~~~~ ^
opencv2.Point:1:12: note: found candidate with type 'Point'
open class Point : NSObject {
           ^
Darwin.Point:1:15: note: found candidate with type 'Point'
public struct Point {


Steps to reproduce

To reproduce the issue, download one of the artifacts built with Xcode 12.3 by one of the official buidworker (you can find it here with context: #18489 (comment)).

I also built the framework locally with Xcode 12.4 and it broke with the same errors in Xcode 12.5.

The integration was as simple as this:

import UIKit
import opencv2

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        print(Mat())
    }
}
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions