sccn / liblsl

C++ lsl library for multi-modal time-synched data transmission over the local network
Other
107 stars 63 forks source link

LSL for IOS (iPad, Iphone) cmake #186

Open VladimirR46 opened 1 year ago

VladimirR46 commented 1 year ago

Hello!

Our team wants to use an iPad (Air 5) for a series of experiments. Our stimulus program is written in Qt Creator (c++). The program compiles successfully and runs on an iPad with iOS. We want to add lsl to the program to send event markers.

We also tested the program on macOS with a m1 pro processor, everything compiles and works using cmake.

We could not find any compiled libraries for ios. And there is not even any instruction on how to do it.

Maybe someone knows how to do it and can help? Maybe you can use e.g. https://github.com/leetal/ios-cmake Xcode project from root folder is not supported anymore((.

cboulay commented 1 year ago

Thanks for the link. I'll give it a look the next time I'm working on liblsl CMakeLists.txt file. However, due to the low demand and high maintenance costs, I doubt we'll add iOS to our CD builds.

It's been a while, but I've used liblsl on iOS before so I know it works. Even though we don't supply binaries, it shouldn't be too hard to build your own with the right CMake invocation... which might come from that link.

You also have the option grabbing liblsl directly into your own project using CMake's FetchContent to pull in the repo at config time and build it next to your target. If there's anything in our if (APPLE)... fragments that somehow pre-empt iOS then let us know and we'll try to clean those up.

This is untested, but it might look something like this:

include(FetchContent)
set(LSL_BUILD_STATIC ON)
FetchContent_Declare(LSL
            GIT_REPOSITORY https://github.com/sccn/liblsl.git
            FIND_PACKAGE_ARGS
    )
FetchContent_MakeAvailable(LSL)

# ... add your target ...

target_link_libraries(${target_name} PRIVATE LSL)
florin-pop commented 7 months ago

@VladimirR46 I managed to make it work with ios-cmake using the following diff applied to the tag v1.16.0 : a.diff.zip If you want to try it, you will need to set:

XCODE_ATTRIBUTE_DEVELOPMENT_TEAM
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER

This will build a liblsl.dylib that can be used in an iOS app if you have the Multicast Networking entitlement. However I was not able to upload the app using this dynamic library to AppStore because of the error:

ITMS-90426: Invalid Swift Support - The SwiftSupport folder is missing. Rebuild your app using the current public (GM) version of Xcode and resubmit it.

The error message is misleading in what it suggest as a fix because I was using the current public version of Xcode.

My current solution is to manually compile all C++ source code into a .Framework which is very Apple friendly and can be used on both macOS and iOS.

Feel free to download it and try it yourself.