matrix-org / matrix-ios-sdk

The Matrix SDK for iOS
Apache License 2.0
451 stars 211 forks source link

Failed wrap MatrixSDK to SwiftPM package #1497

Open artemkrachulov opened 2 years ago

artemkrachulov commented 2 years ago

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:

pixlwave commented 2 years ago

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

artemkrachulov commented 2 years ago

@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 commented 2 years ago

@pixlwave Looks like the issue appears after upgrading to static lib usage: https://github.com/matrix-org/matrix-ios-sdk/commit/c7b873ac2787d00927793a3d3925fa758edfb644

AlexandreHauber commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Hey @artemkrachulov, have you found a workaround?

artemkrachulov commented 2 years ago

@AlexandreHauber nope

mredig commented 2 years ago

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 commented 2 years ago

A matrix SDK needs cache for:

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 commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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.