-
-
Save MapaX/5dc58ccb16ad1f772907154ae4991dca to your computer and use it in GitHub Desktop.
#!/bin/zsh | |
makeXCFramework () { | |
BASEDIR=$(pwd) | |
echo "Script location: ${BASEDIR}" | |
LIBNAME=$(basename $BASEDIR) | |
echo "lib is: $LIBNAME" | |
cd Frameworks | |
mkdir -p iphoneos | |
mkdir -p iphonesimulator | |
# Copy framework into the platform specific directories | |
cp -R $LIBNAME.framework/ iphoneos/$LIBNAME.framework | |
cp -R $LIBNAME.framework/ iphonesimulator/$LIBNAME.framework | |
xcrun lipo -remove x86_64 ./iphoneos/$LIBNAME.framework/$LIBNAME -o ./iphoneos/$LIBNAME.framework/$LIBNAME | |
xcrun lipo -remove arm64 ./iphonesimulator/$LIBNAME.framework/$LIBNAME -o ./iphonesimulator/$LIBNAME.framework/$LIBNAME | |
xcodebuild -create-xcframework -framework iphoneos/$LIBNAME.framework/ -framework iphonesimulator/$LIBNAME.framework/ -output ../../"$LIBNAME.xcframework" | |
cd .. | |
cd .. | |
} | |
cd MLKitCommon | |
makeXCFramework | |
cd MLKitVision | |
makeXCFramework | |
cd MLKitTextRecognition | |
makeXCFramework |
Hi! Thanks for this workaround, you save my day!
I had to make a fix in the script related the issue @AngryDuckFTW commented here. The only frameworks generated was the MLKit ones.
I found that the error "binaries with multiple platforms are not supported" was produced in the Google's dependencies because they have the armv7 architecture inside the frameworks (not only x86_64 and arm64), so the simulator fails because it has 2 architectures (x86_64 & armv7) of 2 different platform (device & simulator).
The fix in the script is quite easy. add the following line:
xcrun lipo -remove armv7 ./iphonesimulator/$LIBNAME.framework/$LIBNAME -o ./iphonesimulator/$LIBNAME.framework/$LIBNAME
below line 49.
I had also to change line 100 from this
if [[ $FrameworkBaseFolder == MLKit* ]] then
to this
if [[ $FrameworkBaseFolder == ML* ]] then
because I have MLImage as a dependency also
Thanks again, and best regards
How would I apply this to GoogleMLKit/Translate?
I think the easy way is to clone the https://github.com/nilsnilsnils/MLKitFrameworkTools repo, tune the Pod file and just follow the instructions in there.
I have not checked what the translate contains, but same approach should work just fine.
can anyone give me xcframework file of GoogleMLKit/FaceDetection. I tried the following script but in output folder, there is no framework at all :(
I created my own MLKit Package.
Readme & Tools