lite icon indicating copy to clipboard operation
lite copied to clipboard

This available on MacOS?

Open wilsonmar opened this issue 3 years ago • 21 comments

wilsonmar avatar Feb 09 '21 14:02 wilsonmar

Looks like the answer is "yes and no" after reading this (https://github.com/rxi/lite/issues/197#issuecomment-711270525). There's an unofficial fork here: https://github.com/mathewmariani/lite-macos.

jaymakes11 avatar Feb 09 '21 17:02 jaymakes11

Yes! as @yet-another-dev pointed out I'm maintaining a macOS version. I'm trying to stay as true to the original rxi/lite as possible

mathewmariani avatar Feb 10 '21 20:02 mathewmariani

@mathewmariani Make a pull request! I just used the fork and its good, time to learn the new keybinds :p

AstroOrbis avatar Feb 11 '21 00:02 AstroOrbis

I was working on refactoring the bindings so that mac/windows can use the same bindings file before submitting a merge request; otherwise, we'll have to deal with using ctrl instead of cmd.

mathewmariani avatar Feb 11 '21 01:02 mathewmariani

For anyone interested, I was able to clone the repo and build lite on my Mac. The only thing that I needed to do, prior to running build.sh, was to brew install sdl2 (requires Homebrew) so that the SDL2 headers were present. After that, it built without issue and I was able to natively run the resulting lite binary.

I am running a 2019 16" MacBook Pro running Big Sur 11.2.1.

bgohsman avatar Feb 24 '21 15:02 bgohsman

For anyone interested, I was able to clone the repo and build lite on my Mac. The only thing that I needed to do, prior to running build.sh, was to brew install sdl2 (requires Homebrew) so that the SDL2 headers were present. After that, it built without issue and I was able to natively run the resulting lite binary.

I am running a 2019 16" MacBook Pro running Big Sur 11.2.1.

If you have problems with xcrun you have to install developer tools: xcode-select --install and works correctly

TheGolurk avatar Feb 24 '21 17:02 TheGolurk

For anyone interested, I was able to clone the repo and build lite on my Mac. The only thing that I needed to do, prior to running build.sh, was to brew install sdl2 (requires Homebrew) so that the SDL2 headers were present. After that, it built without issue and I was able to natively run the resulting lite binary. I am running a 2019 16" MacBook Pro running Big Sur 11.2.1.

If you have problems with xcrun you have to install developer tools: xcode-select --install and works correctly

That is a good point. I had previously installed the Xcode command-line tools, so that was already in place.

bgohsman avatar Feb 24 '21 18:02 bgohsman

I'm tried to compile it, but got the following error:

$ ./build.sh 
compiling (unix)...
linking...
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSUserDefaults", referenced from:
      objc-class-ref in src_platform_macos.m.o
  "___CFConstantStringClassReference", referenced from:
      CFString in src_platform_macos.m.o
  "_objc_msgSend", referenced from:
      _enable_momentum_scroll in src_platform_macos.m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
cleaning up...
done

MacOS version: 11.2.1 (20D74) sdl2 is installed with homebrew:

$ brew reinstall sdl2
==> Downloading https://homebrew.bintray.com/bottles/sdl2-2.0.12_1.big_sur.bottle.2.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/bdf2c30a7267e33a214a0170b6639a31f6a86b5ae524ebfa9dcb06c54d2c1514?response-content-di
######################################################################## 100.0%
==> Reinstalling sdl2 
==> Pouring sdl2-2.0.12_1.big_sur.bottle.2.tar.gz
🍺  /usr/local/Cellar/sdl2/2.0.12_1: 89 files, 4.9MB

Also I'm manually placed the SDL2.framework to /Library/Frameworks/ directory.

drakmail avatar Feb 24 '21 18:02 drakmail

And I found, that precompiled release have issues with retina support. You can see the low DPI fonts of lite at the right and high DPI fonts on the left in the terminal emulator:

image

drakmail avatar Feb 24 '21 18:02 drakmail

I'm tried to compile it, but got the following error:

$ ./build.sh 
compiling (unix)...
linking...
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_NSUserDefaults", referenced from:
      objc-class-ref in src_platform_macos.m.o
  "___CFConstantStringClassReference", referenced from:
      CFString in src_platform_macos.m.o
  "_objc_msgSend", referenced from:
      _enable_momentum_scroll in src_platform_macos.m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
cleaning up...
done

MacOS version: 11.2.1 (20D74) sdl2 is installed with homebrew:

$ brew reinstall sdl2
==> Downloading https://homebrew.bintray.com/bottles/sdl2-2.0.12_1.big_sur.bottle.2.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/bdf2c30a7267e33a214a0170b6639a31f6a86b5ae524ebfa9dcb06c54d2c1514?response-content-di
######################################################################## 100.0%
==> Reinstalling sdl2 
==> Pouring sdl2-2.0.12_1.big_sur.bottle.2.tar.gz
🍺  /usr/local/Cellar/sdl2/2.0.12_1: 89 files, 4.9MB

Also I'm manually placed the SDL2.framework to /Library/Frameworks/ directory.

Mostly out of curiosity, what version of gcc do you currently have? For comparison, here is what is currently installed on my system:

gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

bgohsman avatar Feb 24 '21 18:02 bgohsman

@bgohsman

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

drakmail avatar Feb 24 '21 19:02 drakmail

@bgohsman

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Looks like we have the same gcc setup. So that's not it. lol Unfortunately, I'm not terribly fluent in C/C++. However, I did notice that in main.c, there is an existing check for Apple and a related include:

#ifdef _WIN32
  #include <windows.h>
#elif __linux__
  #include <unistd.h>
#elif __APPLE__
  #include <mach-o/dyld.h>
#endif

This is a hunch (at best), but it looks like your process made it as far as, linking... and then failed. If the linker can't find the dyld.h header, it's going to have all kinds of problems doing much of anything.

https://github.com/opensource-apple/dyld/blob/master/include/mach-o/dyld.h

bgohsman avatar Feb 24 '21 20:02 bgohsman

I've supplied all the scripts I use for building and bundling in my repo, and I added a release for v1.11. I don't have macOS Big Sur so I can't test on that version.

However, if Apple may have moved mach-o/dyld.h somewhere else in which case you would just need to replace the include statement with the new location. If that's the case I would move all mac specific include into platform/macos.h.

@drakmail I see you're trying to build for unix. You need to run build.sh macos

Also, we could move all discussions to the lite-macos repo.

mathewmariani avatar Feb 25 '21 17:02 mathewmariani

@mathewmariani oh, that's the point! build.sh macos solved the compilation issue 🤦

drakmail avatar Feb 25 '21 17:02 drakmail

Building for mac using SDL2 homebrew brew install SDL2

./build.sh release macOS
compiling (macos)...
linking...
ld: framework not found SDL2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
cleaning up...
done

Here are changes I've made to the build.sh script to fix.

elif [[ $* == *macos* ]]; then
  platform="macos"
  outfile="lite"
  compiler="gcc"
  cflags="$cflags -DLUA_USE_POSIX"
  lflags="-D_THREAD_SAFE -I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2 -framework Foundation -lobjc -lm -o $outfile"
else

./bundle_macos.sh worked fine and a bundle file was available (.app).

@drakmail However the build has low-res fonts within the retina display. If anyone has a fix let me know.

stevenanthonyrevo avatar Mar 08 '21 02:03 stevenanthonyrevo

Cannot build on Mac m1 - have issue:

src/renderer.h:4:10: fatal error: 'SDL2/SDL.h' file not found #include <SDL2/SDL.h>

I have installed sdl2 by brew install sdl2

Valexr avatar Mar 14 '21 06:03 Valexr

Cannot build on Mac m1 - have issue:

src/renderer.h:4:10: fatal error: 'SDL2/SDL.h' file not found #include <SDL2/SDL.h>

I have installed sdl2 by brew install sdl2

try this:

elif [[ $* == *macos* ]]; then
  platform="macos"
  outfile="lite"
  compiler="gcc"
  cflags="$cflags -DLUA_USE_POSIX -I/opt/homebrew/include/ -D_THREAD_SAFE"
  lflags="-L/opt/homebrew/lib -lSDL2 -framework Foundation -lobjc -lm -o $outfile"
else

Dimentium avatar Mar 19 '21 17:03 Dimentium

Cannot build on Mac m1 - have issue: src/renderer.h:4:10: fatal error: 'SDL2/SDL.h' file not found #include <SDL2/SDL.h> I have installed sdl2 by brew install sdl2

try this:

elif [[ $* == *macos* ]]; then
  platform="macos"
  outfile="lite"
  compiler="gcc"
  cflags="$cflags -DLUA_USE_POSIX -I/opt/homebrew/include/ -D_THREAD_SAFE"
  lflags="-L/opt/homebrew/lib -lSDL2 -framework Foundation -lobjc -lm -o $outfile"
else

Tx👍🏻it's working! But low font resolution...

Valexr avatar Mar 20 '21 08:03 Valexr

@Valexr you may be interested to know that in lite-xl the font rendering is much improved. Unfortunately for the moment we don't have a Mac OS X build but we made a few steps forward in this direction with @mathewmariani and with some help and time now it may compile on OS X without major difficulties.

francesco-st avatar Mar 23 '21 09:03 francesco-st

Hello everyone,

I was able to create a notarized app for Mac OS (Intel x86-64) for lite-xl here:

https://github.com/franko/lite-xl/releases/tag/v1.16.5-macos-1

It works on my system, Mac OS Mojave, but I would be glad if someone else can test. I used some of the work of @mathewmariani, the icons, the Info.plist file and I took inspiration from the build script, thank you Mat!

Lite-xl is a fork of lite that includes some improvements among which the most prominent:

  • improved font rendering, state of the art subpixel font rendering and positioning with slight hinting (but can be customized)
  • reduced CPU usage to be friendly to laptop's battery. Actually zero CPU usage when unfocused and relatively low when the window is in use.

If the app I created works correctly I will probably integrate in lite-xl the Mac OS adaptations made by @mathewmariani.

Otherwise I was planning to release also the notarized app for the original lite so that people can try the original application without having to compile it by themselves.

franko avatar Apr 18 '21 21:04 franko

Dear ladies, gentlemen,

it took a while and quite some work but I was finally able to bake the support for retina displays in lite-xl.

The package is available there:

https://github.com/franko/lite-xl/releases/tag/v1.16.6-sdl-renderer-2

It is a testing release but the first tests are positive. The package is notarized so you can download and test without any fear. If you have a retina display you should see a beautiful, nice little editor popup on the screen but I leave to you the pleasure to test.

Well, in fact I am really proud of this (modest ?) accomplishment and I wanted to show it to other people. In addition I would like to have some more feedback from macos users.

If there are no major problems I will properly release the retina-enabled package for macos starting from the next release to come.

franko avatar Apr 28 '21 17:04 franko