-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to consume XCFramework built for distribution #7313
Comments
If you're building the xcframeowrk with Xcode 12.5, which is using Swift 5.4 tools, is your xcframework building in an app using Xcode 12.5? Sorry if I'm misunderstanding something. |
That is exactly what happens, I build XCFramework with Xcode 12.5 with Swift 5.4. If I try to build the same App using Xcode 13 beta (Swift 5.5) I get the error mentioned above: Failed to build module 'RealmSwift'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)'). Please select a toolchain which matches the SDK. I am setting REALM_BUILD_LIBRARY_FOR_DISTRIBUTION to YES, so the XCFramework should be compatible with other versions of the swift compiler. As stated in this comment, Realm supports library evolution: |
I am facing the same issue. Did you find any solution for this problem? |
Unfortunately not |
@dcacenabes Does this issue happen for you with the latest Xcode beta? |
Do you mean building the Realm SDK with BUILD_LIBRARY_FOR_DISTRIBUTION enabled or build the app that uses the library built in an older Xcode version ? |
@dcacenabes I think what @leemaguire is trying to ask is if you have tried to built the XCFramework with the REALM_BUILD_LIBRARY_FOR_DISTRIBUTION flag with the latest Xcode release (Xcode 13 as today). |
Hi @dianaafanador3 , if I build with the latest Xcode 13 as of today, then I can not try if the XCFramework generated is ABI stable because I can not build with a newer version of the Swift compiler, since I'd be using the latest one to generate the framework. |
@dianaafanador3 @leemaguire I confirm the issue with latest Xcode. My xcode version is 13.0 (Swift 5.5) where I build Realm XCframework with distribution flag enabled. (Realm version: 10.17.0). Everything is good. |
@ravikirankhareedi Sorry to be the bearer of bad news, but according to Apple engineers distribution flag / library evolution support does not support backwards compatibility as you are describing. Read it from Apple engineer directly. The only thing it (supposedly) supports is forward compatibility (very misleading from Apple presentations). Forward meaning... if you build with the flag enabled in 12.5, then you should be able to consume it on 13.0 (not the other way around). However for me... I get the same error above even when setting up simple sample frameworks and tests. What I've discovered: library evolution / distribution flag works fine (with a lot of tweaking you can get it) if there are no embedded libraries. The moment your framework has an embedded static library of any kind, swift or Obj-C mixed, evolution support does not appear to be possible any longer. I could not get this working in my main project or any sub projects. Looks to be broken as of now. Filed formal bugs with Apple and using developer credit. Looks to me (and I've been working on iPhones for 13 years) like they biffed this one badly. If you have a project which has no dependencies (anyone? anyone? no?) you're fine, but if you have embedded libraries one of two results seems to occur in testing: the error above in this thread, or stuck build process around the swift module compiling operations during xcodebuild. It will never continue, and will not give any hints why because the parsing of .swiftinterface is occurring behind the scenes and not visible in logs even when using xcodebuild. The end, so sad. |
I've demonstrated that build for distribution does not work when used with a framework which contains a static library of any type (Swift, or Objective-C mixed), also built with distribution. Simply remove the static library and rebuild the framework to see that library evolution now works (by testing through different Xcode versions). If the static library is present in the distributed framework, it either reports the typical error, swift versions are unaligned, or freezes indefinitely early in the build process. Already filed with Apple. Did you find the same thing? Keep in mind forward compatibility (built by lower xcode, consumed by higher xcode) is the thing that matters. https://github.com/kteman/Testing/tree/main/Test%20Library%20Evolution |
I think I've found the root cause of the issue. In my investigation I found myself getting these errors (in the below image) along with ' I then removed all occurrences of The next step is to figure out a way to avoid the name collision when building with older versions of Xcode. Ideally we could use Update: this gist should help https://gist.github.com/leemaguire/02873487e24541e4ea7aa53c5702bd0a |
Hey @leemaguire Update: I even tried generating xcframework locally with library evolution flag enabled but no luck. |
Goals
I am trying to build Realm as an XCFramework with ABI stability and use it in our app. For that, I am setting
REALM_BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
in RealmSwift.xcconfig file and then building an xcframework with Xcode 12.5. After successfully generating the frameworks (Realm and RealmSwift), I am then importing them into my project and building the app with Xcode 13 beta.Expected Results
My application successfully builds with a different version of the swift compiler.
Actual Results
We get errors:
Failed to build module 'RealmSwift'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)'). Please select a toolchain which matches the SDK.
Steps for others to Reproduce
./build.sh xcframework ios
Code Sample
Sample project can be found at
https://github.com/dcacenabes/ABIDemo
Version of Realm and Tooling
Realm framework version: 10.8.0
Xcode version: 12.5 and 13.0 beta
iOS/OSX version: ios 14 and 15
Dependency manager + version: Tried both with Cocoapods and manually adding the framework to the project. Same result.
The text was updated successfully, but these errors were encountered: