Facepunch / Facepunch.Steamworks

Another fucking c# Steamworks implementation
MIT License
2.94k stars 353 forks source link

macOS build #591

Open Laim opened 3 years ago

Laim commented 3 years ago

Hey,

I'm using Facepunch.Steamworks for my Steam integration for a game I'm releasing on Windows and macOS. When running the game in the Unity Editor it's connecting with steam fine, unlocking achievements etc.

If I build the game for Windows and upload it to Steamworks and install via Steam it works fine, as well as running it as a standard out of steam game using 480 or my own game Steam ID.

However, when I build the game for macOS, it looks like the .dll isn't being included in the build. I've gone through the .app and the windows build, in the windows build I have the 'Plugins' folder inside Game_Data and can see steam_api64.dll, but nothing in the macOS build.

Anyone else seen this?

Laim commented 3 years ago

I've had a look at this, https://github.com/Facepunch/Facepunch.Steamworks/issues/11, but it's from 2017 and that class/method doesn't appear to exist anymore.

Laim commented 3 years ago

OK it looks like it might be an issue with building the game for Intel 64-bit AND Apple Silicon (M1 Chips). I've removed Silicon support and it looks to be building it fine, so looks like either a new release is needed for Silicon support or I'll need to update some settings.

Just an FYI for anyone that comes across this!

gregorgabrovsek commented 3 years ago

I'm also seeing issues when creating a MacOS build with the Architecture set to Intel 64-bit + Apple silicon. Only building for Intel 64-bit works flawlessly. It'd be great if we could get a fix for the Apple Silicon builds!

Pattrigue commented 3 years ago

I would also love to see a fix for this! Steamworks.NET recently addressed this: https://github.com/rlabrecque/Steamworks.NET/pull/414

rhys-vdw commented 3 years ago

I'm getting this error from SteamClient.Init when running an Intel + silicon build:

System.DllNotFoundException: libsteam_api
  at (wrapper managed-to-native) Steamworks.SteamAPI+Native.SteamAPI_Init()
  at Steamworks.SteamAPI.Init () [0x00001] in <e385b4c78c0940819c8b38e56fb84260>:0 
  at Steamworks.SteamClient.Init (System.UInt32 appid, System.Boolean asyncCallbacks) [0x00039] in <e385b4c78c0940819c8b38e56fb84260>:0 
  at Feed.SteamController.Initialize () [0x00026] in <881b8442410847478494c65c6ebe48dd>:0 

Same issue? I'm yet to test with an intel build.

Laim commented 3 years ago

I'm getting this error from SteamClient.Init when running an Intel + silicon build:

System.DllNotFoundException: libsteam_api
  at (wrapper managed-to-native) Steamworks.SteamAPI+Native.SteamAPI_Init()
  at Steamworks.SteamAPI.Init () [0x00001] in <e385b4c78c0940819c8b38e56fb84260>:0 
  at Steamworks.SteamClient.Init (System.UInt32 appid, System.Boolean asyncCallbacks) [0x00039] in <e385b4c78c0940819c8b38e56fb84260>:0 
  at Feed.SteamController.Initialize () [0x00026] in <881b8442410847478494c65c6ebe48dd>:0 

Same issue? I'm yet to test with an intel build.

I'll need to reproduce the issue so I can add it to the original issue post; but that does look like the exact same issue!

It was libstream_api that was complaining, that I know, and it was failing on Init - so it would make sense. I'd definitely try running it as just Intel and see how you get on.

rhys-vdw commented 3 years ago

It was libstream_api that was complaining, that I know, and it was failing on Init - so it would make sense. I'd definitely try running it as just Intel and see how you get on.

Yes, it was. Had a hell of a time working out how to switch the target architecture in build haha. For anyone else looking for the solution it's this:

UnityEditor.OSXStandalone.UserBuildSettings.architecture = UnityEditor.OSXStandalone.MacOSArchitecture.x64;

source

The build settings are stored in user preferences, not the project settings, so you need to set it before you run the build command. (This is if you're using a build script, you can of course select it in the build dialogue if that's your jam.)

tvogt commented 3 years ago

I'm having a similar issue. Here's my player.log - like others, it works fine in the editor, but not in the player:

` Initialising Steam... Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.dylib Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.dylib Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.so Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.bundle Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.dylib Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.dylib Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.so Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api.bundle Fallback handler could not load library /Users/tom/Library/Application Support/Steam/steamapps/common/Black Forest/Black Forest.app/Contents/Frameworks/MonoEmbedRuntime/osx/libsteam_api error initialising Steam: System.DllNotFoundException: libsteam_api assembly: type: member:(null) at (wrapper managed-to-native) Steamworks.SteamAPI+Native.SteamAPI_Init() at Steamworks.SteamAPI.Init () [0x00001] in :0 at Steamworks.SteamClient.Init (System.UInt32 appid, System.Boolean asyncCallbacks) [0x00039] in :0 at BlackForest.SteamManager.Start () [0x0000a] in <1655321de84845b881c3a96792ff9dbb>:0

`

tvogt commented 3 years ago

Also noting that builing just for macOS Intel doesn't fix the issue in my case. Still getting the same error.

mastef commented 2 years ago

Is this issue related to https://github.com/rlabrecque/Steamworks.NET/issues/393 ?

Seems like a bigger blocker right now for MacOS builds, as they default to Intel+Silicon archs. I'm also not sure if removing Silicon arch will then cause problems for M1 Macs?

Is it maybe as simple as setting

image

from:

image

to:

image

?

( Saw it mentioned in this comment https://github.com/rlabrecque/Steamworks.NET/issues/393#issuecomment-763878947 )

Editing file Assets/Plugins/Facepunch.Steamworks/re…/libsteam_api.bundle.meta with:

  - first:
      Standalone: OSXUniversal
    second:
      enabled: 1
-     settings: {}
+     settings:
+       CPU: AnyCPU
Laim commented 2 years ago

Not sure if your screenshots are around the wrong way, but you want CPU to be Intel 64-bit only. If you try and build it for M1/Sillicone support included, it fails to include the libraries.

And as far as I'm aware, yes it stops it from working on M1 macs until the library is updated (sadly). I was going to migrate to something else but it's too integrated into my game now for it to be worth the hassle unfortunately.

mastef commented 2 years ago

Not sure if your screenshots are around the wrong way, but you want CPU to be Intel 64-bit only. If you try and build it for M1/Sillicone support included, it fails to include the libraries.

The first screenshot is how it is right now. The bundle is only included in intel 64 builds. Hence if you try to build for intel 64 + m1 it won't include the library, since it's restricted to intel 64-only builds.

Then I changed the bundle to be for "any" macos build ( meaning intel 64 + m1 ).

Built the game for intel 64 + m1 and I don't have a libsteam_api error currently. The game is correctly connecting to Steam on an intel 64 mac.

I have not tested the game on a m1 mac, yet. But it's already a step further than it was before.

mastef commented 2 years ago

Just tested on a Mac Mini. M1 will still fail with libsteam_api not found, but intel builds have Steam included. So it's a half-working solution until the libsteam_api.bundle is updated. Intel macs will be able to connect to Steam.

wilg commented 2 years ago

How does libsteam_api.bundle get updated? I really don't want to give up native builds! Steamworks.NET seems to work fine on Apple Silicon but it also sucks.

mastef commented 2 years ago

@garrynewman I know it's annoying to get pinged - sorry. It would be really cool if the bundle files could be updated with a new release due to this new technology that was introduced since the last release

freeeranger commented 2 years ago

Any updates on if m1 support will be added at some point? Trying to decide if I should make my game with facepunch.steamworks or with steamworks.net which seems to work with m1.

wilg commented 2 years ago

I gave up and used steamworks.NET

wilg commented 2 years ago

which sucks

garrynewman commented 2 years ago

I have no plans to try to support M1, sorry

mastef commented 2 years ago

I have no plans to try to support M1, sorry

@garrynewman I think it's just updating the Steamworks dll / libsteam_api.bundle to latest version, no? Should have m1 in it. I'm not sure how you generate it/where you get it from

freeeranger commented 2 years ago

@garrynewman I see, really unfortunate. You should however at least update the readme to clearly state that m1 mac isn't supported, since just saying that macOS is supported is kind of false marketing and can lead to a lot of people (including me) starting to develop their games with this library without realizing that it doesn't fulfill their needs platform-wise.

tvogt commented 2 years ago

I have no plans to try to support M1, sorry

any chance of making such plans? Because otherwise I'll have to rip out facepunch and replace it with steamworks or something else and that would really suck because facepunch is by far the best steam lib.

mattluard commented 2 years ago

I think it's just updating the Steamworks dll / libsteam_api.bundle to latest version, no? Should have m1 in it. I'm not sure how you generate it/where you get it from

Does anyone know how libsteam-api.bundle comes into being? If it is just a case of repackaging the Steam dll with a newer version, can we fork the repo with that?

shubhank008 commented 2 years ago

Has anyone been able to figure out how to update libsteam-api.bundle to fix the m1 fiasco ? @garrynewman we understand you might not be interested in updating the project or have time to maintain it, but perhaps please point us in the right direction so some of us can try our hands at it.

If I am not wrong, I think we need to rebuild the DLLs using master branch but with steamworks_sdk 1.52 which added support for m1, is that it ?

NFMynster commented 1 year ago

Sorry for the necro but for anyone reading Steamworks SDK 1.52 does indeed work. I built a version using the latest at time of writing 1.55 and just successfully deployed a Silicon build. I removed the 32 bit dlls entirely.

delzrm commented 1 year ago

any chance of an updated release with a recent steam library and recent macos support?

barrykooij commented 1 year ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef8c406bdf75f52d9fb1537713f75ce865b SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

muzboz commented 1 year ago

Thanks Barry!

I've grabbed a copy, in case it's useful one day for me!

I've not started using Steamworks at all yet, but I'm subscribed to the Facepunch Dev just to get my head around things.

The idea of having a precompiled "recent-ish" version seems very helpful! As I'm sure I'll be pulling my hair out when I go to try to get up to speed on actually using it.

All the best!

Murray Lorden MUZBOZ Games https://www.muzboz.com/

On Wed, 22 Mar 2023 at 10:49, Barry Kooij @.***> wrote:

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef https://github.com/Facepunch/Facepunch.Steamworks/commit/4e7e0ef8c406bdf75f52d9fb1537713f75ce865b SDK version steamworks_sdk_155

Facepunch.Steamworks.zip https://github.com/Facepunch/Facepunch.Steamworks/files/11034905/Facepunch.Steamworks.zip

β€” Reply to this email directly, view it on GitHub https://github.com/Facepunch/Facepunch.Steamworks/issues/591#issuecomment-1478735946, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOZYIPDGHNYCZZUEA37YZDW5I5BXANCNFSM5DAJRSGQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Chizaruu commented 1 year ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

This honestly needs more love.

delzrm commented 1 year ago

We also managed to get this compiling! It refused to compile with visual studio 2019 for me, no matter how many .net sdk versions I installed... I got it building with visual studio 2022 in the end.

barrykooij commented 1 year ago

I've had to update the build, new file is updated in original comment (https://github.com/Facepunch/Facepunch.Steamworks/issues/591#issuecomment-1478735946)

freeeranger commented 1 year ago

Would still like to note that the github readme is quite misleading saying that it works on macOS, since it's only if you build from source that m1 will be supported. Could definitely be clarified... (or a new release could be created :) )

toddgibson commented 1 year ago

Thanks @barrykooij! Unfortunately, when I try to build with this version on my M1 Mac, it still only works if I build for Intel only and use Rosetta.

timothymalcham commented 1 year ago

Thank you @barrykooij, this fixed the issue for me on my M1. I would also add that the table on the readme is misleading, MacOS shouldn't have a check on that table unless this fix is integrated.

barrykooij commented 1 year ago

Thanks @barrykooij! Unfortunately, when I try to build with this version on my M1 Mac, it still only works if I build for Intel only and use Rosetta.

@toddgibson Sorry, not sure what's going wrong there. I only have an M2, but from what I understand there shouldn't be a difference. Are you running Unity in silicon mode? Also, you should set the properties of the files via the Unity editor as explained here: https://wiki.facepunch.com/steamworks/#howtobuildfrommasterbranch

mastef commented 1 year ago

@barrykooij is there any instruction on how we can generate this file ourselves?

Thinking a build script or github action to auto generate this file may make sense

FrostBird347 commented 1 year ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

Thank you so much, I was able to fix steam achievements for a game called BABBDI with this!

devsleeper commented 1 year ago

@barrykooij is there any instruction on how we can generate this file ourselves?

Thinking a build script or github action to auto generate this file may make sense

Second this. Would gladly compensate some cups of coffee, respectfully. 😁

Edit: For anyone stumbling on this thread, I needed a specific version included with the fix so I forked, added the fix commit above as well as the commits I needed then booted to windows, installed dotnet 4.6 as console instructed, built with rider (vs22 also worked)

Now I had the facepunch api, but needed Steamworks itself. I grabbed the one from Steamworks .net repo which is confirmed to work with apple silicon (m1 here) and put the files in the Same Directory as facepunch.

This was enough for me to play in the editor as well as build, for both windows and m1.

Maybe not as streamline a process as others, maybe you can generate the necessary without Steamworks .net? regardless it finally works in a way I can reproduce so I'm happy! :)

ktrack723 commented 12 months ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

G.O.A.T

You saved my life... I was pissed off to know that apple silicons are not supported when they put a green checkmark next to the MacOS in their supported OS list, but now I do not have to overhaul the entire interfaces...

Aweh-GitHub commented 10 months ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

OMG IT WORKS !!!!! Im on Mac M2 had to merge some files, but IT WORKS !! Thanks so much πŸ”₯πŸ”₯πŸ”₯πŸ’ͺ

cemuka commented 10 months ago

@barrykooij is there any instruction on how we can generate this file ourselves? Thinking a build script or github action to auto generate this file may make sense

Second this. Would gladly compensate some cups of coffee, respectfully. 😁

Edit: For anyone stumbling on this thread, I needed a specific version included with the fix so I forked, added the fix commit above as well as the commits I needed then booted to windows, installed dotnet 4.6 as console instructed, built with rider (vs22 also worked)

Now I had the facepunch api, but needed Steamworks itself. I grabbed the one from Steamworks .net repo which is confirmed to work with apple silicon (m1 here) and put the files in the Same Directory as facepunch.

This was enough for me to play in the editor as well as build, for both windows and m1.

Maybe not as streamline a process as others, maybe you can generate the necessary without Steamworks .net? regardless it finally works in a way I can reproduce so I'm happy! :)

I work on a m1 mac and it works for windows builds no issues. But I needed to share the project for a windows machine but It gives import errors. Please, can you clarify how can I follow your guide πŸ™

j1mmie commented 8 months ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's.

To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155

Facepunch.Steamworks.zip

Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

@barrykooij Sorry to bug you, but it looks like that URL has expired. Any chance you could share a new one?

FrostBird347 commented 8 months ago

It took me way longer than I wanted to spend on recompiling this. Compiling on my Mac didn't seem possible, had to boot into Windows, install all sort of outdated .net SDK's. To save anyone the trouble, here's the build. Works on my M2, also in the silicon editor. Last commit in this build: 4e7e0ef SDK version steamworks_sdk_155 Facepunch.Steamworks.zip Update March 24th: I've updated the zip file. It had the steam_api.dll and steam_api64.dll twice, once in the root folder and once in the redistributable_bin folder. This wasn't an issue in play mode, but once I've tried to build for Windows, it failed. Removed files from the root folder (checked old build, didn't have them in root either) and was able to build for Windows.

@barrykooij Sorry to bug you, but it looks like that URL has expired. Any chance you could share a new one?

The link works fine for me and I was able to archive it on the wayback machine without issue: https://web.archive.org/web/20240313081421/https://github.com/Facepunch/Facepunch.Steamworks/files/11057271/Facepunch.Steamworks.zip

j1mmie commented 8 months ago

Ah ignore more. Clicked at the wrong time apparently

linenum commented 7 months ago

@barrykooij

When I installed your zip my code gave the following error:

......error CS0433: The type 'SteamClient' exists in both 'Facepunch.Steamworks.Win32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'Facepunch.Steamworks.Win64, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

I fixed it by deleting:

Facepunch.Steamworks.Win32.dll Facepunch.Steamworks.Win32.pdb Facepunch.Steamworks.Win32.xml

Then when I set the macOS architecture to "Intel 64-bit + Apple silicon" it halted with the error:

Plugin 'libsteam_api.so' is used from several locations: Assets/Plugins/Facepunch.Steamworks/redistributable_bin/linux32/libsteam_api.so would be copied to /libsteam_api.so

I fixed it by deleting the files in linux32.

Steamworks achievements seem to still work on my Mac.

patach commented 3 weeks ago

Does anybody have a fork of this project that has this entirely updated for the Silicon chips?