libtorrent
libtorrent copied to clipboard
Building for iOS
I'm aware this has been asked before for older versions of libtorrent but having tried the methods for 2.0.6 it doesn't seem to work the same.
How would one go about building libtorrent for iOS, if at all possible?
I'm currently using 1.2.3 as far as I can remember but would like to take advantage of the newer features, etc.
Edit: thank you in advance for any response, even if it only nudges me in the right direction.
Does this help as it has the steps to compile libtorrent.
https://github.com/qbittorrent/qBittorrent/wiki/Compilation:-macOS-(x86_64,-arm64,-cross-compilation)
https://github.com/qbittorrent/qBittorrent/wiki/Compilation:-macOS
I think the first link might be easier to use though
@userdocs I'll look into it in the morning and report back, thanks for reaching out!
very likely mentioned guides for macOS will NOT help, unfortunately... I'm saying that as its author :) building for iOS using CMake is not a trivial task, it requires some custom (but very likely very well community-supported) configs for environment setup. and furthermore, there are many limitations for library formats on iOS compared to macOS. I can't provide more details, I just "touched" the project which was already set up for building with CMake for iOS. one thing I can recommend is just google for "cmake ios" and follow those guides/recommendations. when you overcome the environment setup step, the rest is trivial and the same as for any other environment. also, I recommend building a static library, because "plain" shared libraries are definitely not supported on iOS (I may be wrong, I'm not an iOS developer, but we faced problems with this on iOS), they must be frameworks, and corresponding rules must be present in CMakeLists.txt to build them (and there are no such rules right now, so static library is the one option). but this is not only the one thing - you also need to build libtorrent' dependencies first: Boost and OpenSSL, this may be even harder rather libtorrent itself, because both of them use their own build systems.
The osx workflow they use does not seem that complicated
https://github.com/qbittorrent/qBittorrent/blob/master/.github/workflows/ci_macos.yaml
But they are using homebrew for dependencies
https://github.com/qbittorrent/qBittorrent/blob/master/.github/workflows/ci_macos.yaml#L32-L37
With the core dependencies installed it should be pretty easy to build libtorrent from just boost source with b2
but I have no idea how you get ggc and stuff on OSX
I did previously get 2.0.5 working on iOS but as a separate sim/device framework, when using lipo to combine them it broke so wanted to ask and see if my process was different/wrong.
don't know if lipo
is suitable to combine binaries for device and emulator and even this is supposed... usually, binaries for device and emulator are separate frameworks bundled into .xcframework (which in turn just a directory with special structure and contains frameworks for each build flavor).
I didn't see any "universal" binaries for emulator and device, but again, I'm not an iOS developer, I just worked on a huge project and had to deal with it a lot.
Ended up getting 2.0.6 running on iOS using the official build guide with only a few changes to the user-config.jam.
Edit: useful log is on the 4th line at the bottom
@official-antique what official build guide do you mean? this one http://libtorrent.org/building.html ? what changes are required to user-config.jam? and what about OpenSSL dependency?
the CI workflow for iOS could also be helpful: https://github.com/arvidn/libtorrent/blob/RC_2_0/.github/workflows/macos.yml#L110
@arvidn sorry, may I ask how to use this yml file to build the iOS output? thanks.
I compiled the most recent one some time ago @jingliancui; https://github.com/official-antique/QuixTorrent/releases/tag/1.0.1
@official-antique thank you, do you mind share the way that how you build these output on your repo. I am very very interesting in this.
Absolutely, I'll add a how-to as soon as I can. That repository also contains an SPM for ease of access but requires additional code (more so a wrapper)
Thanks, I'm curious about can we reuse the h files directly in ios? Why need the wrapper.
You can still use the .h/.hpp from libtorrent but to be able to use the .cpp you'll need to either do C++>ObjC++, C++>ObjC++>Swift or C++>Swift interoperability
Thanks for the explanation