Lazarus Cocoa build failed in Mac OS Mojave 10.14 lazarus / 31-LCL ---------------------------------------------------------------------- mohsenti · 2018-10-27 12:10 Hi I'm a new MacOS user and I have compile FPC and Lazarus in MacOS 10.14. FPC x86_64 and cross compile i386 built successful but Lazarus building with cocoa platform failed with below errors Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i cocoaprivate.pas(189,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"cocoaprivate.pas(195,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"cocoaprivate.pas(189,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.cocoaprivate.pas(195,14) Error: Mismatch between number of declared parameters and number of colons in message string.cocoaprivate.pas(254,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"cocoaprivate.pas(254,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.cocoaprivate.pas(273,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"cocoaprivate.pas(280,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"cocoaprivate.pas(273,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.cocoaprivate.pas(280,14) Error: Mismatch between number of declared parameters and number of colons in message string.cocoaprivate.pas(314,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"cocoaprivate.pas(325,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"cocoaprivate.pas(314,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.cocoaprivate.pas(325,14) Error: Mismatch between number of declared parameters and number of colons in message string.cocoaprivate.pas(366,1) Fatal: There were 14 errors compiling module, stoppingFatal: Compilation aborted  And I built lazarus with Quotemake LCL_PLATFORM="cocoa" command. Anyone have any solution for this problem ? ---------------------------------------------------------------------- ChrisR · 2018-10-27 14:18 I have 10.13, not 10.14, but I just built the latest SVN using the following commands: $ svn up Updating '.': U    lcl/interfaces/cocoa/cocoawinapi.inc U    lcl/interfaces/cocoa/cocoagdiobjects.pas U    lcl/interfaces/cocoa/cocoautils.pas Updated to revision 59373. $make LCL_PLATFORM=cocoa CPU_TARGET=x86_64 clean bigide ... $startlazarus ---------------------------------------------------------------------- mohsenti · 2018-10-27 14:33 Thank you ChrisR, I test your solution but it's not work in MacOS 10.14. ---------------------------------------------------------------------- skalogryz · 2018-10-27 15:27 http://wiki.freepascal.org/Cocoa_Internals#Recompilation ---------------------------------------------------------------------- mohsenti · 2018-10-28 09:58 thank you skalogryz. I think after Dark mode theme added  to MacOS, they change cocoa api and this changes break LCL cocoa platform. ---------------------------------------------------------------------- CCRDude · 2018-10-31 12:14 I've got the same problem; trunk both fpc & Lazarus, cross-compiling from Windows. The link by @skalogryz is not helpful here; the error appears in CocoaPrivate.pas, which is part of the LCL; but it refers to ancestors in NSControl -> NSView -> NSResponder, which are defined in FPC package cocoaint. Digging further, the return type of these two functions is bad. In FPC, it's BOOL = boolean8; in LCL, it's Boolean. So break is totally within the FPC/Lazarus world, not Dark Mode / Mojave related. ---------------------------------------------------------------------- Thaddy · 2018-10-31 12:22 There are currently more problems with 32 bit targets due to FPC rev 39986. ---------------------------------------------------------------------- CCRDude · 2018-10-31 13:02 Good that I haven't tried 32 bit yet For the issue of the OP, I have tried to replace boolean with boolean8 in the LCL units. It will compile after replacing quite a bunch, but I guess that was a bit too simple. My compiled application does not accept keyboard input into an InputQuery, which I could imagine - based on the affected methods - might be a result of this. ---------------------------------------------------------------------- skalogryz · 2018-10-31 13:39 Quote from: CCRDude on October 31, 2018, 01:14:00 pm.. trunk .. fpc ... In FPC, it's BOOL = boolean8; in LCL, it's Boolean.     source level compatibility is broken. is it possible to use 3.0.4 ? (3.0.4a?) ---------------------------------------------------------------------- CCRDude · 2018-11-02 08:49 Just wanted to add that my keyboard issues were coming from the compiled file running in terminal. Once wrapped into a .app, everything works fine. Which means the workaround mentioned is working on x86_64-darwin (not tested other modes). ---------------------------------------------------------------------- MISV · 2018-11-27 00:33 I have now reported the cocoaprivate issue here: https://bugs.freepascal.org/view.php?id=34609 Hopefully someone will roll back the changes or fix this - but at least now the problem has been reported ---------------------------------------------------------------------- skalogryz · 2018-12-05 15:58 Could anyone test r59725, please? The fix needs to go with the Lazarus release. It's quite important for LCL to compile with both 3.0.4 (the latest stable FPC) release as well as with FPC trunk (as the most proper compiler version for mac) ---------------------------------------------------------------------- Josh · 2018-12-05 18:35 Just tried install of cocoa 64 bit on trunk lap and fpc. but get error Code: [Select]/Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/. /cocoa/cocoatextedits.pas(585,8) Warning: (4040) Class types "NSTextDelegateProtocol" and "NSObject" are not related /Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/./cocoa/cocoate xtedits.pas(592,40) Warning: (4040) Class types "NSTextDelegateProtocol" and "NSObject" are not related (3104) Compiling ./cocoa/cocoawindows.pas /Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/./cocoa/cocoawi ndows.pas(403,41) Error: (3069) Call by var for arg no. 3 has to match exactly: Got "Boolean8" expected "Boolean" cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping Fatal: (1018) Compilation aborted cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping Fatal: (1018) Compilation aborted Error: /Users/josh/lazarus_trunk_cocoa/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode Error: (lazarus) Compile package LCL 2.1: stopped with exit code 256 Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 256" Error: (lazarus) Building IDE: Compile AutoInstall Packages failed. make: *** [useride] Error 2 fpcupdeluxe: ERROR: LazarusNativeInstaller (BuildModuleCustom: UserIDE): make returned error code #512 fpcupdeluxe: ERROR: LazarusNativeInstaller (BuildModuleCustom: UserIDE): make returned error code #512 ERROR: Fpcupdeluxe fatal error ! Does that help. I will try a fresh install ---------------------------------------------------------------------- CCRDude · 2018-12-05 18:41 I was trying fpcupdeluxe with trunk/trunk as well as fixes3.2/trunk on macOS High Sierra today and got: Quote/Developer/lazarus/lazarus/lcl/interfaces/./cocoa/cocoawindows.pa s(403,41) Error: (3069) Call by var for arg no. 3 has to match exactly: Got "Boolean8" expected "Boolean" cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping Same on Windows 10 cross-compiling for Darwin/Cocoa with trunk/trunk. ---------------------------------------------------------------------- CCRDude · 2018-12-05 18:45 This does not seem trivial to fix, since LclObjCBoolean is defined in CocoaPrivate, but required in the interface of CocoaUtils, causing a circular unit reference. Furthermore, Cocoa_Extra already has an 8 bit ObjCBool. Two different boolean types in two different units with different prefixes do not look like a good idea. ---------------------------------------------------------------------- skalogryz · 2018-12-05 19:00 Quote from: CCRDude on December 05, 2018, 07:45:30 pmThis does not seem trivial to fix, since LclObjCBoolean is defined in CocoaPrivate, but required in the interface of CocoaUtils, causing a circular unit reference. how come? custom changes? Quote from: CCRDude on December 05, 2018, 07:45:30 pmFurthermore, Cocoa_Extra already has an 8 bit ObjCBool. Two different boolean types in two different units with different prefixes do not look like a good idea. ObjCBool is hidden by {$ifdef BOOLFIX} cocoadefines.inc needs to be updated to undefine BOOLFIX for any FPC version past 3.0.4. For 3.0.4 ObjCBool is not a duplication, but rather LCLObjCBoolean - has intent to be cross FPC version compatible ObjCBool - has intent to be binary correct for ObjC call for fpc 3.0.4 Ultimately both are present to address the same problem, but in different spotss. ---------------------------------------------------------------------- CCRDude · 2018-12-05 19:14 No custom changes, fresh checkouts. I simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils. 0. I gave it a few more tries, and moved the LCLObjCBoolean definition to Cocoa_Extra. That avoids the circular reference, and allows to compile, with the following problems coming up: 1. In CocoaDatePicker, there's still TCocoaDatePicker.acceptsFirstResponder with the wrong type in interface and implementation. 2. In CocoaWSMenus, TCocoaMenuItem, you changed boolean to LCLObjCBoolean only in the interface, not the implementation. 3. In cocoaprinters_h.inc, TCocoaPrinterView, the update from boolean to LCLObjCBoolean was still missing for knowsPageRange and isFlipped. With those changes, I was able to cross-compile to Darwin/Cocoa and the output works fine on High Sierra. ---------------------------------------------------------------------- skalogryz · 2018-12-05 19:17 Quote from: CCRDude on December 05, 2018, 08:14:50 pmI simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils. NSResponderHotKeys is a procedure. It doesn't need LCLObjCBoolean Code: Diff  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Index: coco awindows.pas========================================================== =========--- cocoawindows.pas    (revision 59729)+++ cocoawindows.pas  (working copy)@@ -389,6 +389,7 @@   resp : NSResponder;   wn   : NSWindow;   view : NSTextView;+  r    : Boolean; begin   Result := false;   // only respond to key, if focused@@ -400,7 +401,8 @@    if (not resp.lclIsEnabled) then Exit; -  NSResponderHotKeys(self, event, Result, resp);+  NSResponderHotKeys(self, event, r, resp);+  Result := r;   if not Result then     Result:=inherited performKeyEquivalent(event); end; Please provide a patch for points 1 through 3 and I'll apply them tonight! ---------------------------------------------------------------------- CCRDude · 2018-12-05 19:21 NSResponderHotKeys is a procedure that takes, as its third parameter, a "var handled: boolean". But TCocoaWindowContent.performKeyEquivalent passes it's Result, which is a LCLObjCBoolean, as third parameter to NSResponderHotKeys. I felt it safer to adjust the var parameter of the procedure, than to typecast the boolean forth and back. ---------------------------------------------------------------------- CCRDude · 2018-12-05 19:23 I now see your edit, but don't understand it. Since the problem is that NSResponderHotKeys expects a boolean, what help would it do to pass a variable "r" of the same type as the non-functioning result, LCLObjCBoolean? And what exactly means "Result := rsbool", should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"? Whether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this. ---------------------------------------------------------------------- skalogryz · 2018-12-05 19:25 Quote from: CCRDude on December 05, 2018, 08:23:55 pm should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"? yes it should, i updated the patch Quote from: CCRDude on December 05, 2018, 08:23:55 pmWhether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this. These are two different approaches, because change in parameter type requires to move the type declaration. Long term: NSResponderHotKeys  needs to be moved to cocoawindows.pas ---------------------------------------------------------------------- Josh · 2018-12-05 21:36 Just this minute finish attempt at a fresh install of cocoa 64, and it fails with same error as before. Unfortunately I have not been able to compile anything on Cocoa for the past 2 months natively on High Sierra, and now I can't cross compile to cocoa 64 from carbon 32. Would be a good x-mas present to get the Cocoa 64 working again; just to see the improvements over the past  2 months. ---------------------------------------------------------------------- CCRDude · 2018-12-11 10:40 Just another (positive this time) update: today I ran fpcupdeluxe with trunk/trunk and Darwin/x86_64 on my Mac and it produces a Lazarus that produces Cocoa apps out of the box. No more boolean type issues. Many thanks skalogryz for all your hard work on improving the Cocoa widgetset. Much appreciated!