Open damywise opened 1 year ago
Hi, damywise! I don't have MacOS so I can't test it, but I think you can use it by installing the static library (libsdl2.dylib and more) on MacOS.
You can do it by using Homebrew.
brew update brew upgrade brew doctor
brew install sdl2 brew install sdl2_image brew install sdl2_ttf brew install sdl2_mixer brew install sdl2_net
Hello there, sorry it took so long, but I have tried installing them and it's still not working. The error is still the same
Good news, I've finally found a fix that loads the sdl2 library: modify dylib.dart as follows, inspired by dart_sdl package
//...
case 'macos':
header = 'lib';
extension = '.dylib';
if (!File(header + mark + extension).existsSync()) {
header = '';
extension = '.framework/$mark';
}
break;
//...
Bad news is, it still doesn't work. Error at this specific line https://github.com/sansuido/sdl2/blob/bbce1c6ed5af456812c0cc557f6c0ef28f3f5dd0/example/main.dart#L16-L20 (Almost same error as dart_sdl, though the audio example in dart_sdl works):
NSWindow drag regions should only be invalidated on the Main Thread!
Assertion failed: (NSViewIsCurrentlyBuildingLayerTreeForDisplay() != currentlyBuildingLayerTree), function NSViewSetCurrentlyBuildingLayerTreeForDisplay, file NSView.m, line 12783.
===== CRASH =====
si_signo=Trace/BPT trap: 5(5), si_code=0, si_addr=0x1921d9b94
version=3.1.1 (stable) (Tue Sep 5 12:20:14 2023 +0000) on "macos_arm64"
pid=53081, thread=11523, isolate_group=(nil)(0x0), isolate=(nil)(0x0)
os=macos, arch=arm64, comp=no, sim=no
isolate_instructions=0, vm_instructions=102cde540
fp=16dae6950, sp=16dae6920, pc=1921d9b94
pc 0x00000001921d9b94 fp 0x000000016dae6950 __abort+0xa0
pc 0x833e8001921d9af4 fp 0x000000016dae6990 __abort+0x833e800000000000
pc 0x0f060001921d8e44 fp 0x000000016dae69f0 err+0xf06000000000000
pc 0xea6b8001956793c4 fp 0x000000016dae6a10 NSViewRootLayerBack+0xea6b800000000000
pc 0xd5788001956792f4 fp 0x000000016dae6a60 NSViewBuildLayerTreeForDisplay+0xd578800000000098
pc 0x8f2f000195da56e0 fp 0x000000016dae6ae0 NSWindowUpdateLayerTree+0x8f2f000000000050
pc 0x8545800195677ae0 fp 0x000000016dae6b20 -[NSWindow displayIfNeeded]+0x85458000000000cc
pc 0x4c58800195677988 fp 0x000000016dae6b80 __NSWindowGetDisplayCycleObserverForDisplay_block_invoke+0x4c58800000000204
pc 0x0a57800195676868 fp 0x000000016dae6bc0 NSDisplayCycleObserverInvoke+0xa578000000000a8
pc 0x9c2e0001956764c4 fp 0x000000016dae6d50 NSDisplayCycleFlush+0x9c2e000000000284
pc 0x8f35800199894b6c fp 0x000000016dae6d80 CA::Transaction::run_commit_handlers(CATransactionPhase)+0x8f35800000000078
pc 0xb538800199893928 fp 0x000000016dae6e60 CA::Transaction::commit()+0xb538800000000140
pc 0xfd6c0001998aed48 fp 0x000000016dae6f30 CA::Transaction::release_thread(void*)+0xfd6c0000000000e4
pc 0xbb448001922c9970 fp 0x000000016dae6f90 _pthread_tsd_cleanup+0xbb4480000000026c
pc 0xbb6b0001922cc69c fp 0x000000016dae6fc0 _pthread_exit+0xbb6b000000000054
pc 0x7f6b8001922cbfb4 fp 0x000000016dae6fe0 _pthread_start+0x7f6b8000000000a0
-- End of DumpStackTrace
===== CRASH =====
si_signo=Trace/BPT trap: 5(5), si_code=0, si_addr=0x1921d9b94
Aborting reentrant request for stack trace.
Exited.
Also I made a fork in case anyone wants to test it out https://github.com/damywise/sdl2. If it the libraries doesn't load, just put the *.framework folders to one of the paths in the error
Code:
Logs:
Flutter doctor: