1 | initial version |
I have managed to generate a universal XCFramework that can be used for Catalyst. There are probably more efficient ways but this is what worked for me:
Move to the working directory (where OpenCV has been cloned / downloaded).
Run the opencv/platforms/ios/build_framework.py
script as instructed by the OpenCV documentation (https://docs.opencv.org/4.1.1/d5/da3/tutorial_ios_install.html).
Delete the following build files:
<working_dir>/ios/build/build-x86_64-iphonesimulator/build/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/*
Open the following project with Xcode 11 or later:
<working_dir>/ios/build/build-x86_64-iphonesimulator/OpenCV.xcodeproj
Configure all targets for Catalyst:
Build the "ALL_BUILD" scheme ("Release" configuration).
Locate the build products:
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/Release/*.a
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/Release/*.a
Merge the products as a single static library:
libtool -static -o <working_dir>/libopencv_merged_catalyst.a <all paths to *.a files from previous step>
Create the opencv2 framework binary:
lipo -create <working_dir>/libopencv_merged_catalyst.a -o <working_dir>/opencv2
Duplicate the opencv2.framework for iOS and substitute its binary with the new one for Catalyst (generated in the previous step).
Create a universal XCFramework:
xcodebuild -create-xcframework -framework path/to/ios/opencv2.framework -framework path/to/ios-simulator/opencv2.framework -framework path/to/catalyst/opencv2.framework -output <working_dir>/opencv.xcframework
2 | No.2 Revision |
I have managed to generate a universal XCFramework that can be used for Catalyst. There are probably more efficient ways but this is what worked for me:
Move to the working directory (where OpenCV has been cloned / downloaded).
Run the opencv/platforms/ios/build_framework.py
script as instructed by the OpenCV documentation (https://docs.opencv.org/4.1.1/d5/da3/tutorial_ios_install.html).
Delete ). The script must be run twice so that two different opencv2.framework files can be generated: one for real iOS devices, one for the simulator (this is required to generate a universal XCFramework later on). The different frameworks can be obtained by editing the build_framework.py script and commenting out the unwanted targets (at the end of the script):
To generate the opencv2.framework for the simulator:
# (iphoneos_archs, "iPhoneOS"),
(iphonesimulator_archs, "iPhoneSimulator")
To generate the opencv2.framework for real iOS devices:
(iphoneos_archs, "iPhoneOS")
# (iphonesimulator_archs, "iPhoneSimulator")
Back up what has been generated, then delete the following build files:
<working_dir>/ios/build/build-x86_64-iphonesimulator/build/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/*
Open the following project with Xcode 11 or later:
<working_dir>/ios/build/build-x86_64-iphonesimulator/OpenCV.xcodeproj
Configure all targets for Catalyst:
Build the "ALL_BUILD" scheme ("Release" configuration).
Locate the build products:
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/Release/*.a
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/Release/*.a
Merge the products as a single static library:
libtool -static -o <working_dir>/libopencv_merged_catalyst.a <all paths to *.a files from previous step>
Create the opencv2 framework binary:
lipo -create <working_dir>/libopencv_merged_catalyst.a -o <working_dir>/opencv2
Duplicate the opencv2.framework for iOS and substitute its binary with the new one for Catalyst (generated in the previous step).
Create a universal XCFramework:
xcodebuild -create-xcframework -framework path/to/ios/opencv2.framework -framework path/to/ios-simulator/opencv2.framework -framework path/to/catalyst/opencv2.framework -output <working_dir>/opencv.xcframework
3 | No.3 Revision |
I have managed to generate a universal XCFramework that can be used for Catalyst. There are probably more efficient ways but this is what worked for me:
Move to the working directory (where OpenCV has been cloned / downloaded).
Run the opencv/platforms/ios/build_framework.py
script as instructed by the OpenCV documentation (https://docs.opencv.org/4.1.1/d5/da3/tutorial_ios_install.html). The script must be run twice so that two different opencv2.framework files can be generated: one for real iOS devices, one for the simulator (this is required to generate a universal XCFramework later on). The different frameworks can be obtained by editing the build_framework.py script and commenting out the unwanted targets (at the end of the script):
To generate the opencv2.framework for the simulator:
# (iphoneos_archs, "iPhoneOS"),
(iphonesimulator_archs, "iPhoneSimulator")
To generate the opencv2.framework for real iOS devices:
(iphoneos_archs, "iPhoneOS")
# (iphonesimulator_archs, "iPhoneSimulator")
Back up what has been generated, then delete the following build files:
<working_dir>/ios/build/build-x86_64-iphonesimulator/build/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/*
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/*
Open the following project with Xcode 11 or later:
<working_dir>/ios/build/build-x86_64-iphonesimulator/OpenCV.xcodeproj
Configure all targets for Catalyst:
Build the "ALL_BUILD" scheme ("Release" configuration).
Locate the build products:
<working_dir>/ios/build/build-x86_64-iphonesimulator/lib/Release/*.a
<working_dir>/ios/build/build-x86_64-iphonesimulator/3rdparty/lib/Release/*.a
Merge the products as a single static library:
libtool -static -o <working_dir>/libopencv_merged_catalyst.a <all paths to *.a files from previous step>
Create the opencv2 framework binary:
lipo -create <working_dir>/libopencv_merged_catalyst.a -o <working_dir>/opencv2
Duplicate the opencv2.framework for iOS and substitute its binary with the new one for Catalyst (generated in the previous step).
Create a universal XCFramework:
xcodebuild -create-xcframework -framework path/to/ios/opencv2.framework -framework path/to/ios-simulator/opencv2.framework -framework path/to/catalyst/opencv2.framework -output <working_dir>/opencv.xcframework