Recent

Author Topic: Apple Developer Transition Kit  (Read 5478 times)

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #15 on: July 19, 2020, 10:18:17 pm »
Jonas,

Thanks, I'll try again. It looks a bit complicated at this stage.

BTW, when I waited for "Finding software", I opened System Preferences > Updates and Mac suggested me install Command Line Tools Beta 2. It was downloaded and installed successfully. But I'm not sure that was installed correctly.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2514
    • havefunsoft.com
Re: Apple Developer Transition Kit
« Reply #16 on: July 20, 2020, 04:27:49 am »
2. I can't install SVN. Because brew is not installed by default. I tried to manually download brew and install it, but it doesn't work correctly.
Another option - MacPorts says that my macOS is not Catalina and exits.
you can try to copy over svn binaries (executable and dependency libs) intel build from 10.15 (or any other macOS version)

Rosetta does its job nicely.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #17 on: July 21, 2020, 08:31:51 am »
Dmitry,

Thanks! I'll try this today.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #18 on: July 21, 2020, 11:02:28 am »
Did you install Xcode 12 beta 2
or Xcode 12 for macOS Universal Apps beta 2 ?

When I run this command:

make distclean

I get the following error:

Quote
igor@Igors-Mac fpcsrc % make distclean
xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): could not use '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' because it is not a compatible arch).
igor@Igors-Mac fpcsrc %

ChrisR

  • Full Member
  • ***
  • Posts: 163
Re: Apple Developer Transition Kit
« Reply #19 on: July 21, 2020, 11:37:02 am »
Igor-

I made this mistake as well, and Jonas provided the solution:

---

It's because you installed those manually downloaded command line tools. They only contain x86-64 code, and the command line tools inside the Xcode-beta app are trying to load libraries from them.

You can try switching them over back to the ones in the Xcode-beta.app with
 sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer/

Also, when doing a make install after building, add
FPC=$PWD/compiler/ppca64

to the make install command line (along with the OPT="-FD.. -XR..") to ensure a native aarch64 compiler gets installed rather than an x86-64 cross compiler.

----

Once you have compiled fpc, you can set up your ~/.fpc.cfg so you do not have to include the FD and XR arguments, as described here:

https://wiki.freepascal.org/macOS_Big_Sur_changes_for_developers#ARM64.2FAArch64.2FAppleSilicon_Support

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #20 on: July 21, 2020, 11:55:14 am »
Thanks, Chris!

I did that you suggested, and it seems to solved the problem.

Now I'm performing steps suggested by Jonas.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #21 on: July 21, 2020, 12:00:31 pm »
Chris,

Can you also tell how you installed Lazarus?

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #22 on: July 21, 2020, 03:00:55 pm »
I compiled Lazarus Trunk as described in Wiki

When I try to run it:

Quote from: pascal
open startlazarus.app --args "--pcp=~/.laz_trunk"

I get the following error:

Quote
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2514
    • havefunsoft.com
Re: Apple Developer Transition Kit
« Reply #23 on: July 21, 2020, 03:19:03 pm »
apparently the "startlazarus" or "lazarus" files are missing execute right
https://apple.stackexchange.com/questions/181026/lsopenurlswithrole-failed-with-error-10810-cant-open-install-os-x-yosemite

you can set the right via command line or via Finder file properties
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

ChrisR

  • Full Member
  • ***
  • Posts: 163
Re: Apple Developer Transition Kit
« Reply #24 on: July 21, 2020, 03:32:26 pm »
After following Jonas' fpc guide
 https://wiki.freepascal.org/macOS_Big_Sur_changes_for_developers#ARM64.2FAArch64.2FAppleSilicon_Support

I downloaded the svn trunk of Lazarus and ran "make bigide" in the Lazarus folder. The "Lazarus.app" was created that I can run from the finder and put on my dock. If you do follow the page you link, remember to use CPU_TARGET=aarch64 rather than CPU_TARGET=x86_64, but it seems like Cocoa and the aarch64 are chosen implicitly if you do not specify them.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #25 on: July 21, 2020, 04:21:03 pm »
skalogryz,

I used chmod 755 for lazarus and startlazarus

then I get again this error if I call in Terminal:

open startlazarus.app --args "--pcp=~/.laz_trunk"

Quote
igor@Igors-Mac lazarus % open startlazarus.app --args "--pcp=~/.laz_trunk"
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.

If I run lazarus.app in Finder I get -1 error.

But If I run:
./lazarus
It starts and works.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #26 on: July 21, 2020, 04:23:22 pm »
Chris, how you installed svn? Can you explain in more details?
I have no problem with installing svn on traditional Mac, not on this Apple DTK.

ChrisR

  • Full Member
  • ***
  • Posts: 163
Re: Apple Developer Transition Kit
« Reply #27 on: July 21, 2020, 07:53:02 pm »
The DTK comes with git, so the easiest solution is to just get the latest svn from github
  https://github.com/graemeg/lazarus
Dmitry helped me install svn software on my DTK, so I am not sure the method he used. So for my system I can just run svn, but for other users git clone is an easier solution that should work the same.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 215
Re: Apple Developer Transition Kit
« Reply #28 on: July 21, 2020, 08:44:36 pm »
Regrettably Lazarus from Trunk works wrong on this Apple DTK.

1. I downloaded again Lazarus trunk from Git (manually from website).

2. "make bigide" (or "make LCL_PLATFORM=cocoa CPU_TARGET=x86_64 bigide")

3. chmod +x lazarus, chmod +x startlazarus

4. I can run only ./lazarus from /lazarus.app/Contents/MacOS/

Click on Lazarus.app in Finder shows error -1

startlazarus.app (or ./startlazarus) shows an error:

Quote
LSOpenURLsWithRole() failed with error -10810 for the file /Users/igor/WnSoft/Development/lazarus/startlazarus.app.

ChrisR

  • Full Member
  • ***
  • Posts: 163
Re: Apple Developer Transition Kit
« Reply #29 on: July 21, 2020, 09:53:55 pm »
Igor,
 I can not replicate your issue, as I can launch my copies of Lazarus either from the command line or clicking on the "startlazarus" or "Lazarus.app" icons in the finder.

However, with this version of MacOS, it is clear that clicking an icon from the finder has different privileges than running the same application from the terminal. Here is what I have observed when clicking in the finder that does not happen when running in the terminal:
 1. The app will receive an argument with a unique process serial number, e.g. "-psn_0_989382", so if a Pascal program uses ParamStr(), it needs to ignore this.
 2. The app will refuse to open any file that has the executable bit set on. Perhaps git clone is copying some files with this bit on. You could check this for your files (e.g. 'ls -l ~/.fpc.cfg' and switch this bit off 'chmod -x ~/.fpc.cfg')
 3. The app will refuse to open any files that are not within its sandbox.  The files that are permitted to be opened can change when the application is recompiled, as the OS seems to decide the user has not explicitly provided access to the file. I found this really tricky, as I have a most-recently-used menu item that allows the user to quickly open recently seen files. If the app is rebuilt, the FileExists() function reports the file exists, the fpAccess() function does not give sensible information, and the FileSize reports the correct file size even though the user does not have read access.

I would propose that fpAccess should be updated for recent MacOS versions (sounds like a Dmitry's expertise) so R_OK correctly reflects if the user can open a file. Additionally, it might be nice to have the pascal file reading routines give a meaningful message if the file is outside the sandbox. Troubleshooting these routines is a bit of a pain, as trusted applications work fine, but the same application works differently when run from the finder.

My brute-force method to find out if the executable has permission to read a file is to read the first byte from the file. A try..except block keeps the program from crashing.

function IsReadable(fnm: string): boolean;
label 222;
var
  f: file;
  b: byte;
begin
  result := false;
  if not fileexists(fnm) then goto 222;
  if FSize(fnm) < 2 then goto 222;
  AssignFile(f, fnm);
  {$I+}
  try
    FileMode := fmOpenRead;  //Set file access to read only
    Reset(f, 1);
    if ioresult <> 0 then
       exit;
    b := 0;
    BlockRead(f, b, sizeof(b)); //Byte-order Identifier
    CloseFile(f);
    result := true;
  except
    result := false;
  end;
  222:
  if result then exit;
  printf('Unable to read file (not in sandbox?): '+fnm);
end;

 

TinyPortal © 2005-2018