Hello,
I faced a weird problem with my framework imported into my app. MyFramework uses some other frameworks like OpenSSL etc. I build MyFramework with the script:
FrameworkName="MyFramework"
rm -rf build/
xcodebuild archive -scheme "$FrameworkName" \
-configuration Debug -destination 'generic/platform=iOS' \
-archivePath "./build/$FrameworkName.framework-iphoneos.xcarchive" \
SKIP_INSTALL=NO \
BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme "$FrameworkName" \
-configuration Debug -destination 'generic/platform=iOS Simulator' \
-archivePath "./build/$FrameworkName.framework-iphonesimulator.xcarchive" \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme "$FrameworkName" \
-configuration Debug -destination 'generic/platform=macOS' \
-archivePath "./build/$FrameworkName.framework-macos.xcarchive" \
SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
# Fix https://bugs.swift.org/browse/SR-14195 (caused by https://bugs.swift.org/browse/SR-898)
pattern="./build/$FrameworkName.framework-iphoneos.xcarchive/Products/Library/Frameworks/$FrameworkName.framework/Modules/$FrameworkName.swiftmodule/*.swiftinterface"
grep -rli "$FrameworkName.$FrameworkName" $pattern \
| xargs sed -i '' "s,$FrameworkName.$FrameworkName,$FrameworkName,g"
# end fix
xcodebuild -create-xcframework \
-framework "./build/$FrameworkName.framework-iphoneos.xcarchive/Products/Library/Frameworks/$FrameworkName.framework" \
-framework "./build/$FrameworkName.framework-iphonesimulator.xcarchive/Products/Library/Frameworks/$FrameworkName.framework" \
-framework "./build/$FrameworkName.framework-macos.xcarchive/Products/Library/Frameworks/$FrameworkName.framework" \
-output "./build/$FrameworkName.xcframework"
# Wait for process completion and verify result
pid=$!
wait $pid
echo "Process with PID $pid has finished with Exit status: $?"
[[ ! -d "./build/$FrameworkName.xcframework/" ]] && {
msg="[ERROR] expected ./build/$FrameworkName.xcframework/ to exist"; echo -e $msg
exit 1
}
As you can see, it is also built framework for the macOS platform. A little digression: I prefer using Carthage to build xcframeworks, but here it doesn't work, I don't the reason.
The aforementioned build solution works great, all frameworks included in MyFramework don't have any issues when I use MyFramework in my iOS App. The problem starts with using MyFramework in macOS target App. It shows two related errors, I tried some solutions but didn't find a proper way... Errors:
blablabla/DerivedData/MyApp-hdzvzxtsnsdivzcialzikxjdwidw/Build/Products/Debug/MyFramework.framework/Modules/MyFramework.swiftmodule/arm64-apple-macos.swiftinterface:9:8: error: no such module 'OpenSSL'
import OpenSSL
And the second one:
blablabla/Helpers/Injected/Services.swift:10:8: error: failed to build module 'MyFramework' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
import MyFramework
I can import the OpenSSL framework to the macOS app and then I faced the same problem with the next framework from MyFramework's importing list - it isn't a solution... What causes that problem?
Thanks in advance for any help... 🥺