Skip to content
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

macOS Release #6

Closed
thisma opened this issue May 1, 2023 · 25 comments
Closed

macOS Release #6

thisma opened this issue May 1, 2023 · 25 comments
Labels
Mac Something specific to macOS

Comments

@thisma
Copy link
Contributor

thisma commented May 1, 2023

I'd like to use this on macOS. Can you add a macOS binary or bundle to the releases? Alternately I'd love to get into the jai beta, build focus myself, and help support this project.

@meglio
Copy link
Contributor

meglio commented May 1, 2023

I tried to compile it on MacOS:

➜  focus git:(main) jai first.jai - release

In Workspace 3 ("focus"):
/Users/meg/projects/focus/modules/Input/macos.jai:2,1: Error: Unable to parse a statement here.

    #import "Objective_C";
    <<<<<<< HEAD

@focus-editor
Copy link
Owner

Hi @meglio - I've removed the git merge artifacts that were causing the error, maybe you could try again?

I tried to get jai to work on macOS but couldn't because of some permissions problems in one of the libs. Unfortunately the mac version is not getting enough attention right now. Thanks to @CookedNick it exists, but he's busy and can't improve it at the moment.

@ileonte
Copy link
Collaborator

ileonte commented May 1, 2023

Sorry for the merge artifact and thanks for fixing it!

I've prepared a branch where the MacOS build is fixed: https://github.com/ileonte/focus/tree/macos-build-fix

I will also open a PR for these changes.

@ileonte
Copy link
Collaborator

ileonte commented May 1, 2023

@meglio MacOS builds should be fixed now. I don't know how well the editor will run/behave but at least you should be able to build it.

@meglio
Copy link
Contributor

meglio commented May 2, 2023

When I git pulled and tried to compile, the first thing I had to deal with is this:

image

It appeared 20+ times, and I had to click on the "Cancel" button each time. Then I Ctrl+C in the console to stop the build process, and those warnings stopped.

Next, I had to go to the Privacy Settings and manually allow the file to be used:

image

I had to do the same for stb_image.dylib and multiple other files. What's worse, after each such an "Allow", I also had to restart the build process and click on the "Open" button in a dialog like this:

image

Would be very useful if it could be handled automatically somehow, so that I just have to click some "Allow" button as it builds.


Now to the build. It proceeded much further this time, but the last line in the output says "ld: framework not found CoreFoundation", which I guess is still a failure:

➜  focus git:(main) jai first.jai - release
NSWindowController: 104 super: 32
NSViewController: 120 super: 32
NSResponder: 32 super: 8
Running linker: ld -o /Users/meg/projects/focus/focus /Users/meg/projects/focus/.build/focus_0_w3.o -L /Users/meg/projects/focus -L /usr/lib -L /usr/local/lib -L /Library/Frameworks -L /System/Library/Frameworks -L /Users/meg/jai/jai/modules/ -dynamic -macosx_version_min 10.14 -rpath '@loader_path' -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -framework CoreFoundation -lc -lobjc -framework CoreGraphics -framework AppKit -framework Cocoa -framework Foundation -lpthread -lm -ldl -lSystem -framework CoreServices /Users/meg/jai/jai/modules/freetype-2.12.1/macos/freetype.a /Users/meg/projects/focus/modules/Objective_C/LightweightRenderingView/libLightweightRenderingView.a -framework QuartzCore /Users/meg/jai/jai/modules/stb_image_resize/mac/stb_image_resize.a /Users/meg/jai/jai/modules/stb_image_write/mac/stb_image_write.a /Users/meg/jai/jai/modules/stb_image/mac/stb_image.a -framework OpenGL /Users/meg/jai/jai/modules/stb_sprintf/mac/stb_sprintf.a
ld: framework not found CoreFoundation

Note 1:

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates

Note 2:
CPU: Apple M1 Max
MacOS: 13.3 (22E252)

Thanks for looking into it!

Note 3:
jai -version
Version: beta 0.1.062, built on 27 April 2023.

@ileonte
Copy link
Collaborator

ileonte commented May 2, 2023

The first issue is just MacOS being MacOS and refusing to allow you to run software you downloaded through some means other than the app store. In this case it's mad at the Jai compiler itself. You can skip all that aggravation by just running this after you update/install the compiler:

xattr -d -r com.apple.quarantine /path/to/your/jai/distribution

For the second one - not sure what to say. I installed XCode using the graphical installer and it "just worked" for me.

Again, these have nothing to do with Focus but more with setting Jai up to compile stuff on MacOS. Maybe you can get more/better help on the beta discord.

@thisma
Copy link
Contributor Author

thisma commented May 2, 2023

The linker issue with CoreFoundation looks like a problem with your command line developer tools installation. If you’re using the one that’s separate from Xcode, located at /Library/Developer/CommandLineTools, then running these two commands will possibly solve the issue.

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

If that doesn’t work, can you give the output of the following command?

xcode-select --print-path

@meglio
Copy link
Contributor

meglio commented May 3, 2023

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

-- did not help


Output:

xcode-select --print-path
/Library/Developer/CommandLineTools

xcode-select -v
xcode-select version 2397.

@thisma
Copy link
Contributor Author

thisma commented May 3, 2023

@meglio Do you happen to also have Xcode installed? Assuming Xcode is in your applications folder, does compiling work after running this command?

sudo xcode-select -switch /Applications/Xcode.app

@meglio
Copy link
Contributor

meglio commented May 4, 2023

Installing full xcode (rather than just cli tools) solved the issue.

Proposed notes in PR #19

@thisma
Copy link
Contributor Author

thisma commented May 4, 2023

@meglio I’m sad that was necessary, but glad it worked.

@thisma
Copy link
Contributor Author

thisma commented May 4, 2023

@meglio out of curiosity, as I'm trying to think through why Xcode was necessary to get the build to work, do you happen to be using an Apple Silicon based Mac, and used the migration assistant to transfer your files from an Intel based Mac? I've heard migration given as a possible reason for the CoreFoundation framework not found issue. It seems unlikely to me, but worth knowing if true.

@meglio
Copy link
Contributor

meglio commented May 4, 2023

do you happen to be using an Apple Silicon based Mac, and used the migration assistant to transfer your files from an Intel based Mac?

The answer is YES to both.

But I also reinstalled xcode command line tools several times, as well as tried other recommendations found on the internet, i.e. brew doctor, brew link, and others. Basically tried everything I could find on the internet.

@thisma
Copy link
Contributor Author

thisma commented May 4, 2023

As I said, I’m sad it was necessary, but glad it worked.

Are you able to contribute it for release here?

As Jai isn’t cross compiling right now, if you compiled it on Apple Silicon I wonder if it will work on my Mac Pro…

@focus-editor
Copy link
Owner

The macOS version is probably not ready to be distributed to users in its current state anyway. I will try to incorporate the changes made by Raphael Luba and then I'll provide a binary for the Intel mac

@meglio
Copy link
Contributor

meglio commented May 5, 2023

Are you able to contribute it for release here?

I don't have any experience with Jai. My experience with staticly typed languages are from the times of Delphi, more than 15 years ago. I'm currently a web developer seeking to start using Jai gradually for various tasks. So I'll see what I can do as we go. I was just excited that this project appeared.

@CookedNick
Copy link
Collaborator

CookedNick commented May 5, 2023

Full Xcode is required because you need the Cocoa (Mac) SDK installed. The CLI tools do not include these things.

@CookedNick CookedNick closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@CookedNick CookedNick reopened this May 5, 2023
@thisma
Copy link
Contributor Author

thisma commented May 5, 2023

Oh, sorry. I thought CoreFoundation was available in the CommandLineTools. I just about always am working on a machine with Xcode installed though, so I guess I have always accidentally avoided that kind of issue.

@thisma
Copy link
Contributor Author

thisma commented May 5, 2023

@CookedNick I see that you closed but then reopened this issue. Is there still a chance that we’ll get a release for macOS?

@focus-editor
Copy link
Owner

I have attached the binary for macOS as promised.

@meglio
Copy link
Contributor

meglio commented May 6, 2023

Full Xcode is required because you need the Cocoa (Mac) SDK installed. The CLI tools do not include these things.

@CookedNick is it theoretically possible to make it compilable without that SDK - e.g. by including the libraries needed or something like that. I guess no? Just curious.

@thisma
Copy link
Contributor Author

thisma commented May 6, 2023

I have attached the binary for macOS as promised.

Thank you! This does run on my machine.

By the way, it may be helpful to describe that "execute permissions" need to be added for the file. This command does it:

chmod u+x focus_macos_intel

After that double clicking the file will launch the terminal, and run Focus.

@focus-editor for what it's worth, I made an App Bundle with Info.plist and Appicon.icns image file; so it can be launched as a typical app without opening a terminal. I'm happy to contribute that, but don't see an obvious place in the repository for the bundle, or even just the plist. I've made a pull request for the Appicon.icns image though.

@CookedNick CookedNick reopened this May 10, 2023
@CookedNick
Copy link
Collaborator

Just wanted to report that we now build a macOS .app bundle and even a .dmg disk image (just like every other app) automatically when compiling in release mode. AppIcon.icns is now built dynamically based on the same png we use for the Windows icon. So with the next release we do, you'll see a .dmg you can download. You'll then be able to drag Focus.app directly into your Applications folder like any other Mac app. No more Terminal or chmod needed.

@meglio Not sure. But I can think of several reasons it would be a mistake even if we figured it out. Other than being redundant, (because like you said, most devs have Xcode installed for one reason or another) I don't think we have licensing permission from Apple to redistribute their libraries. It would also bloat this (currently very tiny in filesize) repo with the entirety of the Apple SDK just to avoid people installing something they have probably already installed.

@meglio
Copy link
Contributor

meglio commented May 10, 2023

@CookedNick For those who want to help with the development, the steps are the same? I.e. compile jai first.jai and run. Any other notes for developers?

@CookedNick
Copy link
Collaborator

@meglio That gets you the debug executable. To get the dmg, use jai first.jai - release

No other notes other than you can find the mechanisms for all that in first.jai if you are interested in how it's done. If you have ideas for improvement, that is welcome. PRs too.

@CookedNick CookedNick added the Mac Something specific to macOS label May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mac Something specific to macOS
Projects
None yet
Development

No branches or pull requests

5 participants