-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Compiling for Catalyst #10
Comments
(of course, I could be heading down the entirely wrong path here. If I only compile OpenSSL using marcelosalloum/OpenSSL-for-iPhone with targets "ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 mac-catalyst-x86_64", they import just fine. But, of course, I need libssh2 too) |
It may be my lack of knowledge of Catalyst, but is not the only architecture you need for Catalyst on OSX 10.15 x86_64?
|
Or could you just use the libssh2 for macOS for a Catalyst app? |
Hi @Jan-E , I've tried embedding separate libssh2.a files for arm64 and for macOS, but I keep getting "Building for Mac Catalyst, but the linked library 'libssh2.a' was built for iOS + iOS Simulator. You may need to restrict the platforms for which this library should be linked in the target editor, or replace it with an XCFramework that supports both platforms." Lipo'ing them together into one gave the added trouble that both the simulator and macOS versions were x86_64, and removing the simulator part got me back to the error above. So apparently x86_64 in the simulator and x86_64 on macOS is not the same in its eyes. That's why I brought up the targets from the OpenSSL-for-iPhone project above: "ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 mac-catalyst-x86_64". Compiling it gives me static libraries, no .xcframework, and those static libraries just work. :-) So if we could only bring this to libssh2.a too, that should solve the problem too. For the xcframework route - I tried adding the following to its Info.plist and copying the files into place myself, but alas I'm back at "While building for Mac Catalyst, no library for this platform was found in 'libssh2.xcframework'." The lines I added were
|
OK, clear. When I have got the time I'll experiment further, but for the moment I am out of ideas. Wishing you the best with your attempts. |
I have made a demo catalyst app with OpenSSL integrated fine and the libssh2.a compiled as described above: https://github.com/niklassaers/DemoCatalyst |
Getting closer. See Jan-E@4262507 and Jan-E@4262507#commitcomment-35983917 for a working example of building a MacCatalyst library of libssh2. The trick of building for MacCatalyst is adding |
I tried to use these libs in a real iPad app:
Ergo, the other libs have to be added to the fat library as well. |
Jan-E@5f233a1 brought me closer to compiling arm64 for Mac Catalyst. Build command:
The trick is to add
Where to find a libSystem.tbd, built for Mac Catalyst?? There are about 8 variants of libSystem.tbd in the Xcode.app. I tried the most likely ones, but none of hem worked. The missing required architecture arm64 in libclang_rt.osx.a is worrying as well, but it is only a warning, not a fatal error. |
Thanks a lot, @Jan-E , great find with the CFLAGS and thanks for explaining how to use them. I'll follow your lead here and see what I can find out |
I think I have solved it with this commit: Jan-E@b9610a1 There is a script catalyst.sh in the repo now that builds OpenSSL 1.1.1d and LibSSH2 1.9.0 for Mac Catalyst. The idea was stolen from the OpenSSL for iPhone repo: build x86_64 for Mac Catalyst and all the others just for iOS and create a fat library with those libs. You cannot combine x86_64 for iOS and x86_64 for Mac Catalyst in the same fat library, so I went for the Mac Catalyst version.
where x86_64 is the MacOSX version. I added those lib and the headers to https://github.com/Jan-E/DemoCatalyst/commits/master |
FWIW: I tested the libs in a B2B iPad app: it uploaded 15.0 MB in 3.99 seconds. The iPad app uses the camera, so I will have to update a lot more to make it work on Mac Catalyst. |
Wonderful, checking it out and will report back! :-) |
The iOS simulator does not work:
In my main app that is no real problem, because I cannot test the camera either. |
Wonderful work. My initial report is that it's working well! :-) I'll look into getting the simulator back up and running. In the catalyst world we could probably reduce build time a bit by skipping i386? |
FWIW: Yesterday I built LibSSH2 1.9.0 & OpenSSL 1.1.1e for Mac Catalyst. I updated my Catalyst branch a little bit: @niklassaers Did you ever succeed in combining the libraries for Mac Catalyst and for iOS simulator? |
Thanks. I didn't manage that, but I made one target that contained the catalyst binary and one target that contained the simulator binary, and then worked around it that way - two binaries, each with their own target |
See Jan-E@a76c657 for a mac Catalyst build using the Mac OSX SDK 11.0. |
Jan-E@ddb9391 works fine for OpenSSL 1.1.1k and LibSSH2 1.9.0 with Xcode 12.4 |
Jan-E@f9f6d1f which leads to Jan-E@f9f6d1f#commitcomment-49456294 |
Xcode 12.5 implied an update of the macosx SDK from 11.1 to 11.3. That is automatically detected now by Jan-E@52eb3f0 If you want to build Catalyst libs:
Grab a coffee or 2 and wait until the libs have been built with OpenSSL 1.1.1k and LibSSH2 1.9.0 (autodetected versions at this time). |
Compiling with OpenSSL 1.1.1l went smooth. The end of running ./catalyst.sh:
|
I had to update the script to auto-detect libSSH2 1.10.0, but then it went smooth: Building Mac Catalyst openssl lib done.
|
Building Catalyst libs autodetected macOS SDK 12.1 & iOS SDK 15.2 (Xcode 13.2 on Monterey 12.1), OpenSSL 1.1.1m and LibSSH2 1.10.0. Everything OK in my fork:
Grab a coffee or 2 and wait until the libs have been built with OpenSSL and LibSSH2 for Mac Catalyst. |
The macabi target had to be changed for Xcode 13.3. See Jan-E@ec0bb5d#commitcomment-68465816 for a complete session on building the Catalyst fat library |
Update to OpenSSL 1.1.1n went without changing the scripts |
Update to OpenSSL 1.1.1o went without changing the scripts |
For the last ever libs that will support iOS 9.3.6 I dropped iPhoneSimulator i386. Building the catalyst branch with OpenSSL 1.1.1s ended as follows;
|
I updated https://github.com/Jan-E/iSSH2/tree/catalyst for Xcode 14.1.
And ends like this:
The x86_64 architecture in that fat file is for Mac Catalyst. |
I ran the scripts for Catalyst and normal iOS just after the release of OpenSSL 1.1.1u. When I returned to my mail the release announcement of LibSSH2 1.11.0 arrived. As a test I also compiled this one. No errors on compilation, but I did not test it thoroughly yet. Please share any experience in this new issue: #19 |
Hi,
I'm trying to compile for Catalyst, and the way I try doing that is through making an .xcframework. So I tried the following:
But that gave me:
"error: binaries with multiple platforms are not supported 'libssh2_iphoneos/lib/libssh2.a'"
So I compiled x86_64 and arm64+arm64e separately
but that gave me a new error:
"error: unable to find any architecture information in the binary at 'libssh2_iphoneos_arm64_arm64e/lib/libssh2.a'"
Even splitting arm64 and arm64e into binaries for just them, or only include arm64 or arm64e themselves, gave me the same error. Why won't it find architecture information?
Not including arm64 and arm64e at all, however, gave me success:
"xcframework successfully written out to: libssh2.xcframework"
But obviously, I'd like a framework with arm64 and arm64e support. :-)
Any input on how to proceed from here? Would be really good to be able to build this for Mac Catalyst
The text was updated successfully, but these errors were encountered: