Skip to content
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 wrap MatrixSDK to SwiftPM package #1497

Open
artemkrachulov opened this issue Jun 10, 2022 · 13 comments
Open

Failed wrap MatrixSDK to SwiftPM package #1497

artemkrachulov opened this issue Jun 10, 2022 · 13 comments

Comments

@artemkrachulov
Copy link

Describe the bug
After wrapping version (v.0.23.8) as xcframework and then adding it to the project prints an error:

Failed to build module 'MatrixSDK'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)', while this compiler is 'Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)'). Please select a toolchain which matches the SDK.

Wrapping version 0.23.2 works as expected.
Connecting via pod works as expected.

To Reproduce

  1. Build xcframework (example build script https://github.com/niochat/MatrixSDK/blob/main/.github/workflows/build.yml)
  2. Add to app with SPM
  3. Run

Screenshots
Screenshot 2022-06-10 at 12 17 17 PM

Env:

  • xCode Version 13.4.1 (13F100)
  • Matrix SDK Version 0.23.8
@pixlwave
Copy link
Member

Hey @artemkrachulov, have you also added SwiftyBeaver as a package, like described here: niochat/MatrixSDK#2? I have found that fixed a similar error for me recently with 5.4 & 5.5.

@artemkrachulov
Copy link
Author

@pixlwave Tried to add SwiftyBeaver with/without Realm versions matched to pod file. 1.9.5 and 10.27.0. And an error still the same.

@artemkrachulov
Copy link
Author

@pixlwave Looks like the issue appears after upgrading to static lib usage:
c7b873a

@AlexandreHauber
Copy link

I am also facing this issue with 0.23.9, and had already SwiftBeaver as part of the project.
Last year I forked Nio: https://github.com/AlexandreHauber/MatrixSDK
I update the swift-tools-version on the generate-package.swift, but it didn't make any difference.

@AlexandreHauber
Copy link

Removing the Catalyst framework, I could build 0.23.12, but this error is still happening.

I had to remove Catalyst because, since 0.23.10, Catalyst won't build due to MXCrypto pod addition.

@AlexandreHauber
Copy link

Hey @artemkrachulov, have you found a workaround?

@artemkrachulov
Copy link
Author

@AlexandreHauber nope

@mredig
Copy link
Contributor

mredig commented Aug 4, 2022

Just throwing out there I'm also experiencing this issue. We are just about to add Matrix to our project and would really prefer not to implement CocoaPods into our lean, clean, lightweight codebase.

I'll be playing with investigating some of the diffs where it broke and see if I can figure something out, but from what it looks like so far, it appears related to including Realm and/or SwiftyBeaver, as discussed above. This might be a separate issue, but why does a privacy focused project need remote logging? I'm also curious why Realm is a requirement and while caching makes sense, it seems overkill to my uneducated opinion.

@manuroe
Copy link
Contributor

manuroe commented Aug 5, 2022

A matrix SDK needs cache for:

  • performance reason to avoid to refetch everything from the server on every startup
  • offline mode
  • storing e2ee keys

The 2 first one are optional depending on your app needs. The last one is mandatory if you wan e2ee. You need to store the keys on the user's device.

Logging is for debugging purpose. You can disable the logger in your app.

It does not help on the initial issue but I wanted to share information about your questions.

@mredig
Copy link
Contributor

mredig commented Aug 5, 2022

That makes sense, but I guess I was asking more about why Realm was being used for caching instead of CoreData or if there'd be too much of a performance hit to just use a plist or json file. Either one of those would simplify the dependency tree, if viable.

@mredig
Copy link
Contributor

mredig commented Aug 5, 2022

As for debugging, I looked at the code a bit last night and, if I found everything, it looks like I jumped to conclusions about remote logging and that it's instead just used for console/local file logging. My apologies :)

@ErusaevAP
Copy link

Hi
We have same problem. Do you have any plan for support SPM or fix problem with XCFramework from topic? Plz let me know if you don have capacity and I'll try to help you as SwiftDev. Thx it is very mater for us.

@Topheee
Copy link

Topheee commented Jan 15, 2023

Hi everyone,
this issue has been bugging me too and it has been around for quite a while now. So I made it work for me: https://github.com/Topheee/MatrixSDK. You can simply add this project in Xcode as a Swift package.

I know this isn't the finest way of doing things, but in order to make it work, I had to remove some features; mostly the SwiftyBeaver logging mechanism and the location features. Additionally, I had to remove the Catalyst build (because I was too stupid to make it build on GitHub Actions).

But I parallelized the build process and added debug symbols to the binary framework. To use them in your project, create an LLDBInitFile at the root of that project and add the path to a clone of my fork of the matrix-ios-sdk repository to the source map:

settings set target.source-map /Users/runner/work/MatrixSDK/MatrixSDK/matrix-ios-sdk/MatrixSDK /path/to/matrix-ios-sdk/MatrixSDK

You can view the changes I made to the SDK here https://github.com/Topheee/matrix-ios-sdk/. Clone it and issue git diff master peeree-compat-v0.24.2, to get an overview.
To view the changes in the build process, have a look at https://github.com/Topheee/MatrixSDK/blob/peeree-compat-v0.24.2/.github/workflows/build-peeree.yml.

As you can see, I am already a couple releases behind (but no important fixes, at least not from the release notes).

I am just a hobby programmer. Maybe my work helps the maintainers, though. If I can otherwise help, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants