Issue 1:
mac system: m1 12.5.1 (21G83)

Python 2.7.16

opencv: 4.x

opencv_contrib: 4.x

#import "Headers/opencv2.h"

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/opencv2.h:217:9: note: in file included from /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/opencv2.h:217:

#import <opencv2/TEBLID.h>

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/TEBLID.h:21:5: error: redefinition of enumerator 'SIZE_256_BITS'

SIZE_256_BITS = 102,

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/BEBLID.h:22:5: note: previous definition is here

SIZE_256_BITS = 101

^

:1:9: note: in file included from :1:

#import "Headers/opencv2.h"

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/opencv2.h:217:9: note: in file included from /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/opencv2.h:217:

#import <opencv2/TEBLID.h>

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/TEBLID.h:22:5: error: redefinition of enumerator 'SIZE_512_BITS'

SIZE_512_BITS = 103

^

/Users/green/Desktop/github/ios/build/build-arm64-iphoneos/lib/Release/opencv2.framework/Headers/BEBLID.h:21:5: note: previous definition is here

SIZE_512_BITS = 100,

^

:0: error: could not build Objective-C module 'opencv2'

Command EmitSwiftModule failed with a nonzero exit code

error: emit-module command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/imgcodecs/ImgcodecsExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/imgproc/ImgprocExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/ml/MlExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/text/TextExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/video/VideoExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/videoio/VideoioExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/wechat_qrcode/Wechat_qrcodeExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/xfeatures2d/Xfeatures2dExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/ximgproc/XimgprocExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/aruco/ArucoExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/calib3d/Calib3dExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/ByteVectorExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/CoreExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/dnn/DnnExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/face/FaceExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/features2d/Features2dExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/CvTypeExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/DoubleVectorExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/FloatVectorExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/objdetect/ObjdetectExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/photo/PhotoExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/structured_light/Structured_lightExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/IntVectorExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/MatExt.swift (in target 'opencv2' from project 'opencv2')

CompileSwift normal arm64 /Users/green/Desktop/github/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/core/Typealiases.swift (in target 'opencv2' from project 'opencv2')

EmitSwiftModule normal arm64 (in target 'opencv2' from project 'opencv2')

CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler (in target 'opencv2' from project 'opencv2')

(27 failures)

ERROR: Command '[u'xcodebuild', u'BITCODE_GENERATION_MODE=bitcode', u'IPHONEOS_DEPLOYMENT_TARGET=9.0', u'ARCHS=arm64', u'-sdk', u'iphoneos', u'-configuration', u'Release', u'-parallelizeTargets', u'-jobs', '8', u'-target', u'ALL_BUILD', u'build']' returned non-zero exit status 65

Traceback (most recent call last):

File "opencv/platforms/ios/build_framework.py", line 181, in build

self._build(outdir)

File "opencv/platforms/ios/build_framework.py", line 139, in _build

self.buildOne(target[0], target[1], main_build_dir, cmake_flags)

File "opencv/platforms/ios/build_framework.py", line 329, in buildOne

execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir + "/modules/objc/framework_build")

File "/Users/green/Desktop/github/opencv/platforms/apple/cv_build_utils.py", line 13, in execute

retcode = check_call(cmd, cwd = cwd)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call

raise CalledProcessError(retcode, cmd)

CalledProcessError: Command '[u'xcodebuild', u'BITCODE_GENERATION_MODE=bitcode', u'IPHONEOS_DEPLOYMENT_TARGET=9.0', u'ARCHS=arm64', u'-sdk', u'iphoneos', u'-configuration', u'Release', u'-parallelizeTargets', u'-jobs', '8', u'-target', u'ALL_BUILD', u'build']' returned non-zero exit status 65

Issue 2:
System information (version)

OpenCV => latest source code from this git repo

Operating System / Platform => macOS 12.4

Compiler => OpenCV python build_framework.py

Detailed description

build log:

BUILD FAILED

The following build commands failed:
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/CvTypeExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/DoubleVectorExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/FloatVectorExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/IntVectorExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/MatExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/Typealiases.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/dnn/DnnExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/face/FaceExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/features2d/Features2dExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/objdetect/ObjdetectExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/photo/PhotoExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/structured_light/Structured_lightExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/imgcodecs/ImgcodecsExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/imgproc/ImgprocExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/ml/MlExt.swift (in target 'opencv2' from project 'opencv2')
EmitSwiftModule normal x86_64 (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/aruco/ArucoExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/calib3d/Calib3dExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/ByteVectorExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/core/CoreExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/text/TextExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/video/VideoExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/videoio/VideoioExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/wechat_qrcode/Wechat_qrcodeExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/xfeatures2d/Xfeatures2dExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/ximgproc/XimgprocExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'opencv2' from project 'opencv2')
Copy /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/lib/Release/opencv2.framework/Versions/A/Headers/opencv2-Swift.h /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc/framework_build/opencv2.build/Release/opencv2.build/Objects-normal/x86_64/opencv2-Swift.h (in target 'opencv2' from project 'opencv2')
Copy /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/lib/Release/opencv2.framework/Versions/A/Modules/opencv2.swiftmodule/x86_64-apple-macos.swiftdoc /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc/framework_build/opencv2.build/Release/opencv2.build/Objects-normal/x86_64/opencv2.swiftdoc (in target 'opencv2' from project 'opencv2')
Copy /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/lib/Release/opencv2.framework/Versions/A/Modules/opencv2.swiftmodule/x86_64-apple-macos.swiftinterface /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc/framework_build/opencv2.build/Release/opencv2.build/Objects-normal/x86_64/opencv2.swiftinterface (in target 'opencv2' from project 'opencv2')
Copy /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/lib/Release/opencv2.framework/Versions/A/Modules/opencv2.swiftmodule/x86_64-apple-macos.swiftmodule /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc/framework_build/opencv2.build/Release/opencv2.build/Objects-normal/x86_64/opencv2.swiftmodule (in target 'opencv2' from project 'opencv2')
Copy /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/lib/Release/opencv2.framework/Versions/A/Modules/opencv2.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo /Users/andy/Workspace/OpenCV/build/build-x86_64-macosx/modules/objc/framework_build/opencv2.build/Release/opencv2.build/Objects-normal/x86_64/opencv2.swiftsourceinfo (in target 'opencv2' from project 'opencv2')
(32 failures)
============================================================
ERROR: Command '['xcodebuild', 'MACOSX_DEPLOYMENT_TARGET=10.12', 'ARCHS=x86_64', '-sdk', 'macosx', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '8', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65.
============================================================
Traceback (most recent call last):
File "/Users/andy/Workspace/OpenCV/opencv/platforms/ios/build_framework.py", line 181, in build
self._build(outdir)
File "/Users/andy/Workspace/OpenCV/opencv/platforms/ios/build_framework.py", line 139, in _build
self.buildOne(target[0], target[1], main_build_dir, cmake_flags)
File "/Users/andy/Workspace/OpenCV/opencv/platforms/ios/build_framework.py", line 329, in buildOne
execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir + "/modules/objc/framework_build")
File "/Users/andy/Workspace/OpenCV/opencv/platforms/apple/cv_build_utils.py", line 13, in execute
retcode = check_call(cmd, cwd = cwd)
File "/Users/andy/opt/anaconda3/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['xcodebuild', 'MACOSX_DEPLOYMENT_TARGET=10.12', 'ARCHS=x86_64', '-sdk', 'macosx', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '8', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65.

Steps to reproduce

follow this guide https://docs.opencv.org/4.x/d5/da3/tutorial_ios_install.html

python opencv/platforms/osx/build_framework.py --macos_archs x86_64,arm64 --contrib opencv_contrib ./