Issue 1:
System Information

OpenCV version: 4.6.0

MacBook M1 Pro

Venture 13.1

Xcode 14.1

Python 3.11.0

Command:

python opencv/platforms/ios/build_framework.py ios --contrib opencv_contrib --iphoneos_archs arm64 --iphonesimulator_archs x86_64

Detailed description

Always Build error with different *Ext.swift files

---
note: Run script build phase 'Generate CMakeFiles/ALL_BUILD' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'ALL_BUILD' from project 'opencv2')
** BUILD FAILED **

The following build commands failed:
SwiftCompile normal arm64 Compiling\ PhotoExt.swift,\ Structured_lightExt.swift /Users/don/Projects/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/photo/PhotoExt.swift /Users/don/Projects/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/don/Projects/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/don/Projects/ios/build/build-arm64-iphoneos/modules/objc_bindings_generator/ios/gen/objc/structured_light/Structured_lightExt.swift (in target 'opencv2' from project 'opencv2')
(3 failures)
============================================================
ERROR: Command '['xcodebuild', 'BITCODE_GENERATION_MODE=bitcode', 'IPHONEOS_DEPLOYMENT_TARGET=11.0', 'ARCHS=arm64', '-sdk', 'iphoneos', '-configuration', 'Release', '-parallelizeTargets', '-jobs', '10', '-target', 'ALL_BUILD', 'build']' returned non-zero exit status 65.
============================================================

Steps to reproduce

again compiling error with other *Ext.swift files ?!

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 any solution

I updated to the latest OpenCV version and the issue is still there

There is reproducer code and related data files (videos, images, onnx, etc)

Issue 2:
** BUILD FAILED **

The following build commands failed:
EmitSwiftModule normal x86_64 (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/build/build-x86_64-macosx/modules/objc_bindings_generator/osx/gen/objc/ml/MlExt.swift (in target 'opencv2' from project 'opencv2')
CompileSwift normal x86_64 /Users/andy/Workspace/OpenCV/build_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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_xcframework/macos/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')
(27 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.
============================================================
ERROR: Command '['python3', '/Users/andy/Workspace/OpenCV/opencv/platforms/osx/build_framework.py', './build_xcframework/macos', '--macos_archs', 'x86_64,arm64', '--framework_name', 'opencv2', '--build_only_specified_archs', '--contrib', 'opencv_contrib']' returned non-zero exit status 1.
============================================================
Traceback (most recent call last):
File "opencv/platforms/apple/build_xcframework.py", line 99, in <module>
execute(command, cwd=os.getcwd())
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 '['python3', '/Users/andy/Workspace/OpenCV/opencv/platforms/osx/build_framework.py', './build_xcframework/macos', '--macos_archs', 'x86_64,arm64', '--framework_name', 'opencv2', '--build_only_specified_archs', '--contrib', 'opencv_contrib']' returned non-zero exit status 1.