openvanilla / McBopomofo

小麥注音輸入法
http://mcbopomofo.openvanilla.org/
MIT License
626 stars 76 forks source link

Which version can be built on macOS 10.5? #349

Closed barracuda156 closed 1 year ago

barracuda156 commented 1 year ago

I think to update McBopomofo in Macports, where it is now at 0.9.11. Our general policy is to support all systems (at least from 10.5) and archs (including ppc/ppc64), as long as it is possible. It seems that the current version of McBopomofo requires substantially newer macOS, so it can be used only for a subset of systems in Macports. Could you recommend a version for older systems? If some fixes are needed for PPC, I could try that, but we need a version that does not rely heavily on SDK features which are not present in 10.5.8.

lukhnos commented 1 year ago

First of all, thanks for your work in supporting the systems and archs!

From what I see, 0.9.4 is the last version whose Xcode project has Mac OS X 10.5 as deployment target. 0.9.5 changed the project structure and is the first version that requires Mac OS X 10.6, and 0.9.9 is the last version that is on Mac OS X 10.6 SDK.

It's been a long time since any of us touched the pre-1.0 versions and I no longer have a setup that allows me to work on PPC support, but feel free to reopen the issue if you run into anything.

barracuda156 commented 1 year ago

@lukhnos I have tried building 0.9.9 on 10.6.8, however it fails. Macports had it earlier, but not sure if anyone ever built it on 10.6: https://github.com/macports/macports-ports/commit/c028289ded5cfd6ed11a13f9047a7fc9871544b0

There are quite a number of errors, so I just attach a full log. Build for ppc also fails with same errors. The log is for x86_64. 0.9.9_10.6.8_x86.txt

lukhnos commented 1 year ago

Thanks. Do you have a PPC Mac running 10.5 that you can run McBopomofo on? We should be able to fix the build issue, but will need to verify that it does run and work.

barracuda156 commented 1 year ago

@lukhnos Yes, I have 10.5.8 PowerPC, 10.6 PowerPC and 10.6.8 (Intel with Rosetta). All three can run ppc32, 10.5.8 also supports ppc64.

lukhnos commented 1 year ago

See if you can get this branch build: leopard-support. It builds 0.9.9.1-leopard, which is based on 0.9.9 but reverted two commits that required later dev toolchain support. The deployment target set to Mac OS X 10.5, and x86_64+i386+ppc fat binaries are built.

When you get McBopomofoInstaller built and run, it should look like this:

installer

And if you get the input method installed, you should be able to enter text like this:

inputmethod
barracuda156 commented 1 year ago

@lukhnos Thank you! I will try this today and update you.

barracuda156 commented 1 year ago

@lukhnos Does not seem to work, unfortunately. I have tried building both in Macports and in Xcode directly. First of all, in both cases this error happens (same on 10.5.8 and 10.6 PPC):

:info:build     /usr/bin/make
:info:build bin/buildFreq.py
:info:build   File "bin/buildFreq.py", line 19
:info:build     except IOError as e:
:info:build                     ^
:info:build SyntaxError: invalid syntax
:info:build make: *** [PhraseFreq.txt] Error 1

Then, Macports build has these:

:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_aqua_McBopomofo/McBopomofo/work/openvanilla-McBopomofo-1474aff/Source/Installer/AppDelegate.h:30: error: cannot find protocol declaration for ‘NSApplicationDelegate’
:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_aqua_McBopomofo/McBopomofo/work/openvanilla-McBopomofo-1474aff/Source/CandidateUI/VTVerticalCandidateController.m:39: error: cannot find protocol declaration for ‘NSTableViewDelegate’
:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_aqua_McBopomofo/McBopomofo/work/openvanilla-McBopomofo-1474aff/Source/UpdateNotificationController.h:37: error: cannot find protocol declaration for ‘NSWindowDelegate’
:info:build /opt/local/var/macports/build/_opt_PPCLeopardPorts_aqua_McBopomofo/McBopomofo/work/openvanilla-McBopomofo-1474aff/Source/AppDelegate.h:40: error: cannot find protocol declaration for ‘NSApplicationDelegate’

Xcode build fails with:

error: there is no SDK with the name or path 'macosx'

Or am doing something wrong?

P. S. Macports sets targets to build Data and McBopomofo, skipping McBopomofoInstaller: https://github.com/macports/macports-ports/blob/master/aqua/McBopomofo/Portfile But I deleted custom settings in the portfile when trying to build 0.9.9.1-leopard.

lukhnos commented 1 year ago

Was bin/buildFreq.py run with a Python intepreter? If so, what was the Python version used?

The Mac app targets need to be built with Mac OS X 10.6 SDK, even if the deployment target is set to 10.5.

barracuda156 commented 1 year ago

Was bin/buildFreq.py run with a Python intepreter? If so, what was the Python version used?

I did not call Python specifically and did not expect it to be needed, since Macports portfile did not set a dependency on Python. Apparently that is wrong.

We do not have to use ancient system Python though, any version can be used.

The Mac app targets need to be built with Mac OS X 10.6 SDK, even if the deployment target is set to 10.5.

Aha, okay. Should we build all three targets by the way? I am not sure why Macports were skipping Installer.

P. S. 10.6 SDK would break ppc64 in Leopard, since libSystem.b doesn’t have it. But what to do.

lukhnos commented 1 year ago

Aha, okay. Should we build all three targets by the way? I am not sure why Macports were skipping Installer.

From the Portfile it seems that the post-install action already moves the built app to "${destroot}/Library/Input Methods/McBopomofo.app", which is half of what the Installer does. There's an optional, separate step that the Installer does, which is to register and activate the input method. Without that, a user will have to go to System Preferences themselves to enable the input method (which will be auto-discovered by OS X at that point).

I'll defer to MacPorts users to what they prefer. If they think the input method should also be registered and enabled at that point, one can simply invoke the binary with ${destroot}/Library/Input Methods/McBopomofo.app/Contents/MacOS/McBopomofo install (code here).

P. S. 10.6 SDK would break ppc64 in Leopard, since libSystem.b doesn’t have it. But what to do.

Is ppc64 strictly necessary? At least if I still remember it correctly, on 64-bit Intel, an input method service app can still be run as 32-bit, and 64-bit apps' text service needs are served by interprocess communication.

Alternatively, try if you can set the base SDK to Mac OS X 10.5 and remove all the offending use of protocols not existing in the older SDK (such as NSApplicationDelegate). I seem to remember those formerly informal protocols were turned formal during that period.

barracuda156 commented 1 year ago

@lukhnos We can certainly live without ppc64: it is desirable but not essential. If building against 10.6 SDK can be avoided, however, that makes life easier: Xcode 3.1.4 won’t have it, and installation of an additional SDK complicates things (I can do it, no issues, but consider casual users, not developers). There are few ports which require a newer SDK than OS itself, so it is possible to implement, but do we lose much when building against 10.5 SDK on 10.5.8?

P. S. It looks like 10.6 PPC SDK also lacks those methods, which is ironically more problematic, since I cannot have 2 SDKs for the same os.major, and I do not want to replace native SDK. This is not a Macports-relevant issue strictly speaking (Macports does not support developer builds of OS X), but anyway.

lukhnos commented 1 year ago

It looks like 10.6 PPC SDK also lacks those methods, which is ironically more problematic

I see. If that's the case, definitely try removing those protocol references and use 10.5 as the base SDK.

lukhnos commented 1 year ago

See if patching in this commit would make everything buildable on Xcode 3.1.4 with Mac OS X 10.5 SDK: https://github.com/openvanilla/McBopomofo/commit/4c239a2a5fe10610d63473727a71f9b30077667c

barracuda156 commented 1 year ago

See if patching in this commit would make everything buildable on Xcode 3.1.4 with Mac OS X 10.5 SDK: https://github.com/openvanilla/McBopomofo/commit/4c239a2a5fe10610d63473727a71f9b30077667c

I will try that, thank you.

UPD. This has been postponed forever, sorry, but yes, it builds! Thank you.