-
Notifications
You must be signed in to change notification settings - Fork 123
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
[Feature Request] Add support for Mac Catalyst #168
Comments
I've managed to add support for Mac Catalyst in my fork, but I feel that it's full of hacks. Nevertheless it works. You can check out this commit in my fork. This is how it can be built: export CC=clang
export CFLAGS='-O2 -g -target arm64-apple-ios13.1-macabi -miphoneos-version-min=13.1 -fembed-bitcode'
cmake -B ./build \
-G "Unix Makefiles" \
-D CMAKE_INSTALL_PREFIX=./dist/darwin/catalyst \
-D CMAKE_VERBOSE_MAKEFILE=true \
-D CMAKE_OSX_ARCHITECTURES='arm64' \
-D BUILD_SHARED_LIBS=ON \
-D MAC_CATALYST=ON \
-D USE_APPLICATION_SERVICES=OFF \
-D USE_IOKIT=OFF \
-D USE_APPKIT=OFF \
-D USE_EPOCH_TIME=ON
cmake --build ${{github.workspace}}/build \
--parallel 2 \
--config RelWithDebInfo \
--clean-first
cmake --install ${{github.workspace}}/build --config RelWithDebInfo This will build the arm64 version - the x86_64 can be built the same way basically, just changing arm64 to x86_64. |
I just dug thought your changes. It looks pretty doable. I have some questions: I guess the first thing I am trying to figure out is what is "Mac Catalyst" and why does it require the library be compiled differently for use with it? I don't know much about Apples ecosystem so this is just so I can figure out why we are doing this. Looking though your changes, I would prefer not to have the I am not sure where
I am trying to figure out why you removed the following. It shouldn't have any effect on Catalyst support.
The last bit is the difference in build flags:
Changing I am guessing that we need to look for How did we get away with dropping support for If you would like to open a PR, please do so and we can get this merged into 1.3. |
Mac Catalyst is a macOS system which enables running apps for iOS and iPadOS on macOS. As I've said, MAUI - a cross-platform UI framework for .NET - uses Mac Catalyst for macOS apps, so that's why SharpHook needs to support it. Apps and libraries must be compiled for iOS in order to work on Mac Catalyst, that's why we need a different build of libuiohook. Since Regarding macOS version support, Mac Catalyst itself appeared in version 10.15, so if we're building for Mac Catalyst, we're automatically building for 10.15+. Mac Catalyst versions correspond with iOS versions, and the earliest supported iOS version is 13.1. I've decided to drop support for versions of macOS older than 10.15 in my fork, because .NET itself doesn't officially support them. That's why I've removed some definitions from headers. Obviously, they should be kept if you want to support 10.5. Regarding And regarding I can make a PR with these changes, but I'm sure I didn't implement it in the best way possible (or even in a good way), so if you can improve on it, it would be awesome. |
Well, I understand what you did, but I cant seem to get it to compile. I keep seeing this warning |
Okey, so I think this is as good as it will get and I hope it works. I need you to do some testing because I have no idea how to use the output of this build. Ideally we should be able to do something like this, however, CMake does not support building for catalyst and it doesn't look like that support is showing up anytime soon.
The main issue is that the system name is required to be iOS which is how cmake converts |
Sorry for not answering earlier, I see that you've tinkered with it quite a lot. I'll test my fork with this configuration and let you know whether it works in the next couple days. When I first tried building libuiohook for Mac Catalyst, I tried creating an app in XCode in Objective-C, target Mac Catalyst, and link libuiohook to it, but it got nowhere since I don't know anything about Apple toolchains or Objective-C. Maybe, you'll have more luck if you try that. |
I've just tested a build of libuiohook for Mac Catalyst, and everything seems to work fine. I've tested global hooks, input simulation, and mouse properties. I've used this configuration from the latest commit on your branch: cmake -B ./build \
-G "Unix Makefiles" \
-D CMAKE_INSTALL_PREFIX=./dist/catalyst/arm64 \
-D CMAKE_VERBOSE_MAKEFILE=true \
-D BUILD_SHARED_LIBS=ON \
-D BUILD_DEMO=ON \
-D USE_APPLICATION_SERVICES=OFF \
-D USE_IOKIT=OFF \
-D USE_APPKIT=OFF \
-D BUILD_DEMO=OFF This configuration works great. But the configuration from your last comment doesn't work, it gives out this error:
|
Would it be possible to compile libuiohook for Mac Catalyst in addition to macOS? I've tried to fiddle with CMake, but didn't achieve much with it. I don't know if it's even possible to support Mac Catalyst without changes to the code.
I'm asking for this because one of the most popular UI frameworks for .NET - MAUI - uses Mac Catalyst to run apps on macOS (it doesn't provide a way to run apps as normal macOS apps). Several people have asked me to add support for MAUI on macOS to my libuiohook wrapper for .NET, and I don't know how to make it work as I don't have experience with CMake.
The text was updated successfully, but these errors were encountered: