Cannot install CocoaPod which includes iOS framework with 'LibTorch-Lite' CocoaPod dependency - ios

MyLibrary: CocoaPod that I am trying to install and run but failing. (https://github.com/steve-ham/MyLibrary) (Includes below 'MyFramework')
MyFramework: iOS framework with 'LibTorch-Lite' CocoaPod dependency. (https://github.com/steve-ham/MyFramework)
When I run 'MyLibrary App' (https://github.com/steve-ham/MyLibrary) I get below error:
libc++abi: terminating with uncaught exception of type torch::jit::ErrorReport:
Unknown custom class type quantized.Conv2dPackedParamsBase. Please ensure it is registered.:
quantized::conv1d(Tensor qx, __torch__.torch.classes.quantized.Conv2dPackedParamsBase packed_weight, float output_scale, int output_zero_point) -> Tensor
~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
terminating with uncaught exception of type torch::jit::ErrorReport:
Unknown custom class type quantized.Conv2dPackedParamsBase. Please ensure it is registered.:
quantized::conv1d(Tensor qx, __torch__.torch.classes.quantized.Conv2dPackedParamsBase packed_weight, float output_scale, int output_zero_point) -> Tensor
~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
I used below code to create MyFramework.xcframework from MyFramework project (https://github.com/steve-ham/MyFramework)
xcodebuild archive -workspace MyFramework.xcworkspace \
-scheme MyFramework \
-sdk iphoneos \
-archivePath "./MyFramework.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO
xcodebuild archive -workspace MyFramework.xcworkspace \
-scheme MyFramework \
-sdk iphonesimulator \
-archivePath "./MyFramework_sim.xcarchive" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
SKIP_INSTALL=NO \
EXCLUDED_ARCHS=arm64
xcodebuild -create-xcframework \
-framework "MyFramework.xcarchive/Products/Library/Frameworks/MyFramework.framework" \
-framework "MyFramework_sim.xcarchive/Products/Library/Frameworks/MyFramework.framework" \
-output MyFramework.xcframework
There's no error like this when I do this with other CocoaPod projects instead of 'LibTorch-Lite'. Is it merely impossible to wrap 'LibTorch-Lite' into .xcframework and deploy it like above wrapping into CocoaPod? Thanks.

Related

Missing Required Module 'RxCocoaRuntime'

I am using RxCocoa in custom framework, so I am trying to inject dependencies with SPM and make that .xcframework.
I made the .xcframework, but the following error keeps appearing.
The process of creating and configuring the framework project and creating the xcframework was as follows.enter image description here
Development Environment
CPU : Apple slicon (M1 PRO)
MacOS : Ventura 13.1
Xcode : 14.2(14C18)
Step
Create framework project (km-ios-sdk)
Set Build Active Architecture Only YES from NO
Mach-O Type is Dynamic Library
Write simple code using RxSwift, RxCocoa
Create .xcarchive and .xcframework
xcodebuild archive \
-scheme km-ios-sdk \
-archivePath ./archive/km-ios-sdk.framework-iphoneos.xcarchive \
-sdk iphoneos \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
xcodebuild archive \
-scheme km-ios-sdk \
-archivePath ./archive/km-ios-sdk.framework-iphonesimulator-arm64.xcarchive \
-sdk iphonesimulator \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
xcodebuild -create-xcframework \
-framework './archive/km-ios-sdk.framework-iphoneos.xcarchive/Products/Library/Frameworks/km_ios_sdk.framework' \
-framework './archive/km-ios-sdk.framework-iphonesimulator-arm64.xcarchive/Products/Library/Frameworks/km_ios_sdk.framework' \
-output './KmSDK.xcframework'
Created Package.swift as below and uploaded it to git.
enter image description here
If you download and import km-ios-sdk as spm in the sample app, the error appears
enter image description here
It is the same even if you manually download .xcframework, and it is the same even if you download it with cocoapod. Is there any way to solve it?

Xcode No such module when importing parent xcframework

I'm trying to import and use an xcframework which has a child xcframework inside and I'm getting a no such module X on the child framework when I try to import the parent.
The specific error is arm64-apple-ios.private No such module X which repeats itself twice. I have set the framework search paths inside the parent framework to $(SRCROOT) recursive and the architectures are set to standard. The framework build script merges the two archives (Simulator & iOS) which contains the child framework in the right location.
Build script:
xcodebuild archive \
-project NAME.xcodeproj \
-scheme NAME \
-destination "generic/platform=iOS Simulator" \
-archivePath "build/SIMULATOR.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
xcodebuild archive \
-project NAME.xcodeproj \
-scheme NAME \
-destination "generic/platform=iOS" \
-archivePath "build/IOS.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES \
xcodebuild -create-xcframework \
-framework "build/SIMULATOR.xcarchive/Products/Library/Frameworks/NAME.framework" \
-framework "build/IOS.xcarchive/Products/Library/Frameworks/NAME.framework" \
-output "build/universal/NAME.xcframework"
Can't see a solution to the error elsewhere so is there something I've missed?

dyld: Symbol not found after importing .xcframework

I've created an .xcframework using this script:
FRAMEWORK_NAME=${PROJECT_NAME}
SCHEME=${PROJECT_NAME}
DISPLAY_NAME=${PROJECT_NAME}
echo "Archiving ${FRAMEWORK_NAME} for iOS simulator..." >> framework.log
xcodebuild archive \
-workspace "${PROJECT_DIR}/${FRAMEWORK_NAME}.xcworkspace" \
-scheme "${SCHEME}" \
-destination "generic/platform=iOS Simulator" \
-sdk iphonesimulator \
-archivePath "${PROJECT_DIR}/Archives/${FRAMEWORK_NAME}-iOS-Simulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
echo "Archiving ${FRAMEWORK_NAME} for iOS..." >> framework.log
xcodebuild archive \
-workspace "${PROJECT_DIR}/${FRAMEWORK_NAME}.xcworkspace" \
-scheme "${SCHEME}" \
-destination "generic/platform=iOS" \
-sdk iphoneos \
-archivePath "${PROJECT_DIR}/Archives/${FRAMEWORK_NAME}-iOS" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
echo "Creating the ${FRAMEWORK_NAME} XC Framework..." >> framework.log
xcodebuild -create-xcframework \
-framework "${PROJECT_DIR}/Archives/${FRAMEWORK_NAME}-iOS-Simulator.xcarchive/Products/Library/Frameworks/${DISPLAY_NAME}.framework" \
-framework "${PROJECT_DIR}/Archives/${FRAMEWORK_NAME}-iOS.xcarchive/Products/Library/Frameworks/${DISPLAY_NAME}.framework" \
-output "${PROJECT_DIR}/${DISPLAY_NAME}.xcframework"
However, when I import the .xcframework in another project I get this error:
dyld: Symbol not found: _$s12ReachabilityAAC10ConnectionO11unavailableyA2DmFWC
Referenced from: /private/var/containers/Bundle/Application/A5315543-8323-4270-8D40-8BB1C940801C/App.app/Frameworks/Framework.framework/Framework
Expected in: /private/var/containers/Bundle/Application/A5315543-8323-4270-8D40-8BB1C940801C/App.app/Frameworks/Reachability.framework/Reachability
in /private/var/containers/Bundle/Application/A5315543-8323-4270-8D40-8BB1C940801C/App.app/Frameworks/Framework.framework/Framework
dyld: launch, loading dependent libraries
DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/GPUTools.framework/libglInterpose.dylib:/usr/lib/libMTLCapture.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib
Every example I've seen on creating an .xcframework doesn't archive using an .xcworkspace, so I'm thinking my issue must be related to that. I need to archive the .xcworkspace because the framework has its own Cocoapod dependencies (Reachability being one of them), but the project I'm integrating with includes those dependencies.
Has anyone successfully created an .xcframework from source code that has Pod dependencies?

How to use SwiftUI in framework

I'm using SwiftUI inside my binary framework, I added SwiftUI.framework as Optional in Embedded Binaries and use #available so it compiles just fine with deployment target iOS 9.
However I cannot use it with xcodebuild, my commands :
xcodebuild clean archive \
-project "${PROJECT_NAME}.xcodeproj" \
-scheme ${1} \
-configuration ${CONFIGURATION} \
-destination "${2}" \
-archivePath "${3}" \
SKIP_INSTALL=NO \
OBJROOT="${OBJROOT}/DependentBuilds" \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES | xcpretty
error message:
use of undeclared type 'View'
use of unresolved identifier 'UIHostingController'
P/s: -weak_framework SwiftUI in Other Linker Flags also didn't work
SwiftUI doesn't have 32 bit header, so adding architecture flag where the error is fix the issue
#if (arch(x86_64) || arch(arm64))
//...
#endif
You can wrap SwiftUI related code in #if canImport(SwiftUI) && canImport(Combine) statements. See example.

Getting Issue in Jenkins Continues Integration to HockeyApp in Xcode 8.3.2

All,
We are using Jenkins Continuous integration for App Uploads Below is the Script in Execute Shell in the Job.
rm -fr ~/Library/Caches/CocoaPods/
rm -fr Pods/
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod install
xcodebuild -configuration Release -scheme MyApp_Test -workspace MyApp.xcworkspace SYMROOT="${WORKSPACE}/MyApp/Build/"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/MyApp/Build/Release-iphoneos/MyApp_Test.app" -o "${WORKSPACE}/MyApp/Build/Release-iphoneos/MyApp.ipa"
Earlier it is working perfectly and able to the integration, Recently we updated he Xcode to 8.3.2, From then we are getting errors below are the Errors we are getting
xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
Build step 'Execute shell' marked build as failure
Build step 'Upload to HockeyApp' marked build as failure
Can any one help in solving the issue seems PackageApplication is deprecated and exportArchive is added, how can we change to that syntax
Before: xcrun with PackageApplication
# Build the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-configuration Release build
# Package the application
/usr/bin/xcrun \
-sdk "${TARGET_SDK}" \
PackageApplication \
-v "${PROJECT_BUILDDIR}/${SCHEME_NAME}.app" \
-o "${BUILD_OUTPUT_DIR}/${APP_NAME}.ipa" \
--sign "${DEVELOPER_NAME}" \
--embed "${PROVISIONING_PROFILE}"
After: xcodebuild with -exportArchive
# Archive the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-configuration Release \
PROVISIONING_PROFILE="${PROVISIONING_PROFILE}" \
archive
# Export the archive to an ipa
xcodebuild \
-exportArchive \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-exportOptionsPlist "${EXPORT_PLIST}" \
-exportPath "${BUILD_OUTPUT_DIR}"

Resources