-
Notifications
You must be signed in to change notification settings - Fork 190
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
Adding Mac Catalyst target to the MacOS build #168
Comments
By manually adding the "maccatalyst" target in the libpdfium.dylib with vtool and then copying the libpdfium.dylib file into my .app package I'm able to use Pdfium in my MAUI application on Mac. Here is the vtool command I used: Would be great if the maccatalyst target could be added in your build process :) |
@sungaila, I think this one is for you. |
Hi @torfluor, if you can help to create iOS and Catalyst binaries for pdfium, I'll add the missing NuGet packages needed for MAUI. I don't have a Mac myself to test any of this. Please take a look at the build scripts and modify them to create the required binaries. It would be very helpful if someone who is familiar with Mac development could help here. |
Hi @sungaila, I would be happy to contribute! I don't have much experience with build scrips and cross platform builds, but looking at the script files I think it would be easies to do separate builds for maccatalyst instead of trying to add multiple targets to the Mac builds. As the library works on Catalyst by just adding the "maccatalyst" target, I would try with the following changes: build.sh 05-configure.sh 07-stage.sh 08-test.sh I have a M1 MacBook Air and an old Intel MacBook Pro that I can test the NuGet packages on. I can also set up a cloud build server to test the suggested changes, but then I would need instructions on how to set it up. |
I've tried for a few hours to get this working in my fork but I couldn't do it. The pdfium build files don't have catalyst as a target and I'm not clever enough to write git patches to get these working (see https://github.com/sungaila/pdfium-binaries/actions/runs/9596534182/job/26463597042). Maybe @bblanchon can help out with that. I'd still help with the NuGet packages once the workflows, bash scripts and git patches are in place. |
The OS names are defined by Google; we cannot add them like this (okay, we did for I don't know anything about Mac Catalyst or its interaction with .NET and NuGet. |
AFAIK Mac Catalyst is its own build target for dylibs consumed by both macOS and iOS (plus derivatives like iPadOS). .NET has the |
@bblanchon: What I did with vtool is more of a hack to see if it would run on Catalyst. It's recommended to rebuild the library instead of modifying the dylibs as described by Quinn from Apple. Maybe this blog entry might be helpful: How to build WebRTC for Mac-Catalyst or Ninja intro for Apple-developers. |
So maybe the pdfium build should be run with |
An additional build would add another maintenance burden to this project. |
But is vtool available in your build environment? vtool ships as part of Xcode. |
The hosted runners by GitHub have Xcode preinstalled. But I personally would prefer a clean build over a hack (which is not yet confirmed to run on iOS). |
The macOS and iOS builds have a cumulated build time of 4h20 every week. @torfluor, please provide the full list of commands we must run to produce the catalyst library from the existing builds. |
Maybe the |
@bblanchon Only the vtool command is needed. If you run
Now run Run
|
I've drafted a pull request for the mentioned changes: #169 @torfluor Please verify if the following NuGet packages are working (macOS, iOS and so on): |
PDFiumV8 works great on my M1 MacBook Air, but using the other crashes my test app with the following error message:
|
@torfluor Are you sure that the dylib was correctly copied and loaded? The logs says And since the V8 build worked, it is very odd that the "normal" stripped down build isn't. I would test it myself but I don't want to invest into a Mac Mini just for debugging Catalyst. 😅 |
I think there must be some difference in the Nuget package. Here is how I tested:
I'm using the PDFiumCore NuGet Package for the bindings, and this works fine with the Windows, iOS, and V8 MacCatalyst packages. |
The difference between those NuGet packages are the contained dylib and some unrelated metadata. I've had the chance to create a blank MAUI app in Visual Studio for Mac. Both NuGet packages will fail the build with the error message
No idea what that means but the part |
I sometimes got the same build error when I switched between the two NuGet packages. Running |
Any update on this issue? Did the |
@torfluor No, the issues were unrelated to NuGet and restore, I couldn't get the hacked binaries to run. Someone with knowledge in C++ development and Catalyst libraries is needed here. Best I can do is to help producing the NuGet packages. |
So I m not an expert, but I do have some friends like I can try ping to see if it helps. I want to start by trying to build locally and generate the nupkg. Is that possible ? do we have build scripts locally ? |
Is there any chat on discord or something we can chat? Ok first try
|
@rmarinho This project has no group chat, you have to ask your questions in the issues. I would suggest you create a fork of this project and run the GitHub workflows (e.g. build-one.yml) to test the build scripts. Then change the build scripts and re-run the workflows as needed. This is easier than setting up the build toolchain locally. Also I think there is a proper Mac Catalyst build needed here. The project maintainer does not wish for an other build target so the binaries should be distributed in a repo fork (I have one for Blazor WebAssembly). I can help you with creating the NuGet packages as soon as you have successfully created Mac Catalyst builds. |
ok @sungaila I m going to try locally got stuck here but need to look more ..
|
@sungaila, that's not what I said. Also, any new build configuration increases the risk of a failed build. @rmarinho, I don't think anyone in this thread knows how to build for maccatalyst, but if you know how to do it, we'll be happy to help. |
Ok, I don't know but I work with people that I almost sure know how to do it , so I will ask around , ( I work in .net maui at Microsoft). And I have a worker that does skiasharp nugetpackages so I think I might ask him for help. |
It isn't enough to set Here is how it is done for iOS: https://github.com/bblanchon/pdfium-binaries/blob/master/patches/ios/pdfium.patch Here is the original BUILD.gn: https://pdfium.googlesource.com/pdfium/+/refs/heads/main/core/fxge/BUILD.gn You will need to check the original pdfium build stuff and create git patches for maccatalyst. |
yeah we want target_environment , I reading it .. and testing locally .. if we see the gn files for iOS they already have support for catalyst in there |
So now we test this ? https://github.com/rmarinho/pdfium-binaries/actions/runs/10634833862 |
@rmarinho I took your lib and packaged it into a nupkg: Just a few suggestions:
I don't have the time test it right now but I'll create a .NET MAUI app, add this nuget package and run it on macOS later on. Maybe you (@rmarinho) can test this on macOS and iOS/iPadOS as well. |
Ok I did a build all that added xc64 .. didn t do v8 yet, lets test this works.. what's the variable for the output dir ? https://github.com/rmarinho/pdfium-binaries/actions/runs/10635311877 |
@rmarinho The directory is named like the I have some nuspec files and icons prepared for the nuget packages. If it is ok with you, I'll open a PR to your fork so you can create the nuget packages yourself (with the workflow). |
YEah sure I m using this branch https://github.com/rmarinho/pdfium-binaries/tree/add-maccatalyst can pr agains it |
hum.. it worked now it s broken.. need to figure what am I missing now |
OK not sure why I building with v8 now .. https://github.com/rmarinho/pdfium-binaries/actions/runs/10637396968 |
@rmarinho I've created nuget packages out of your artifacts: Also please consider to merge my PR (rmarinho#1) into your fork. Then you should be able to create nuget packages yourself. |
bblanchon.PDFium.MacCatalyst.130.0.6679.zip https://github.com/rmarinho/pdfium-binaries/actions/runs/10639243588#artifacts buhh I did had a release complete, but tested the catalyst artifact but still fails for me |
Ok we need some tweaks I think ..
but hey.. progress... |
I can't get it to run either. Building a .NET MAUI app with the
I noticed that SkiaSharp.NativeAssets.MacCatalyst distributes a framework instead of a dylib. Maybe this is something that has to be done for pdfium as well? But since I have no idea about native Mac development, my tests end here. |
Yeah something is missing, I was reading the code for the ninja scripts trying to see what makes sense. but it might that is just configured to be build only as framework. I will continue to investigate. |
When I'm trying to use the MacOS NuGet package with a .NET MAUI Catalyst project the dll is not found. I get the following error:
I also tried to use the iOS NuGet package, but I get the following compile error:
The text was updated successfully, but these errors were encountered: