Missing Required Module 'RxCocoaRuntime' - ios

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?

Related

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

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.

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?

How to load framework at runtime in Xcode?

I have a third party framework customx.framework (iOS) customx.framework (Simulator).
To run project on simulator customx.framework (Simulator) to be imported & for device
customx.framework (iOS) to be imported
simultaneously importing is not supported by xcode
At present i am manually importing framework, so i am looking for runtime scrip changes or combined (iOS+Simulator) framework to import in xcode project.
For that
I have tried lipo & libtool but seems didn't worked.
I used validate workspace but it fails when importing modules.
tried links -
iOS merge several framework into one
Building for iOS Simulator, but the linked framework '****.framework' was built for iOS
simultaneously importing is not supported by Xcode
Supported. It is named XCFramework.
So assuming each variant of frameworks have been built correctly (pay attention that BUILD_LIBRARY_FOR_DISTRIBUTION=YES, just in case - Xcode set it to YES automatically), join them in terminal or Xcode script phase with next command:
$ xcodebuild -create-xcframework
-framework "/full_path_to_iOS_variant/customx.framework"
-framework "/full_path_to_Simulator_variant/customx.framework"
-output "/full_path_to_result/customx.xcframework"
and then add it once in target dependency
and that's it.
You can archive for iOS device and iOS simulator and merge them to one xcframework. This is my current project xcodebuild command for it.
- Archive for iOS devices
xcodebuild archive \
-scheme Framework-scheme \
-configuration Release \
-destination 'generic/platform=iOS' \
-archivePath './build/native/Framework-Name.framework-iphoneos.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
- Archive for iOS simulator
xcodebuild archive \
-scheme Framework-scheme \
-configuration Release \
-destination 'generic/platform=iOS Simulator' \
-archivePath './build/native/Framework-Name.framework-iphonesimulator.xcarchive' \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
- build framework from archives
xcodebuild -create-xcframework \
-framework './build/native/AdTrue-Native.framework-iphoneos.xcarchive/Products/Library/Frameworks/Framework-Name.framework' \
-framework './build/native/AdTrue-Native.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/Framework-Name.framework' \
-output './build/native/Framework-Name.xcframework'

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 specify output dir name for ios simulator when using xcodebuild cli in combination with a xcworkspace?

I build a xcode (6.3.1) project that uses workspace because I'm using Pods.
When I do:
xcodebuild \
build \
-workspace MyProject.xcworkspace \
-scheme MyProject \
-configuration Debug \
-sdk iphonesimulator \
-ARCHS=i386 \
VALID_ARCHS=i386 \
SYMROOT="/tmp/build/emulator" \
SHARED_PRECOMPS_DIR="/tmp/build/sharedpch"
It outputs the app to:
/tmp/build/emulator/Debug-iphonesimulator/MyProject.app
Is there a way with the xcodebuild command to get it build to
/tmp/build/emulator/MyProject.app
I have tried to replace SYMROOT with
CONFIGURATION_BUILD_DIR="/tmp/build/emulator"
Now it builds to
/tmp/build/emulator/Monsenso.app
but that do not work smoothly with CocoaPods frameworks (e.g. Typhoon for DI) ~ build fails with:
The following build commands failed:
GenerateDSYMFile /tmp/build/emulator/Typhoon.framework.dSYM /run/emulator/Typhoon.framework/Typhoon

Resources