Recent

Author Topic: Error with my app bundle on macOS 12 AArch64  (Read 7990 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Error with my app bundle on macOS 12 AArch64
« on: December 03, 2021, 04:23:10 pm »
User message: https://github.com/Alexey-T/CudaText/issues/3847#issuecomment-985559965
He runs my app bundle - it differs from x64 bundle in only one aspect - the binary 'cudatext' is compiled for the target 'darwin aarch64'.

Build script, on Linux x64, to make macOS app bundle:
https://github.com/Alexey-T/CudaText/blob/master/setup/mac_common.sh

Any idea why he got an error?
The macOS package is here now, made with FPC 3.2-fixes:
http://uvviewsoft.com/c/
« Last Edit: December 04, 2021, 10:05:01 pm by Alextp »


trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Error with my app bundle for macOS 12 AArch64
« Reply #2 on: December 04, 2021, 06:12:31 am »
If I start your app thus:

/Applications/CudaText.app/Contents/MacOS/cudatext

it runs and seems to work without any issue at all, but if started from the application bundle it fails as you say.

When starting the app, the log shows:

Code: Text  [Select][+][-]
  1. default 15:54:17.298722+1100    kernel  ASP: Security policy would not allow process: 23101, /Applications/CudaText.app/Contents/MacOS/cudatext
  2. default 15:54:17.305210+1100    runningboardd   [app<application.com.uvviewsoft.cudatext.19969826.19969830(501)>:23101] termination reported by launchd (9, 8, 9)

So I tried ad hoc re-signing:

Code: Text  [Select][+][-]
  1. trev@macmini8 [/Users/trev] $ codesign --force --deep -s - /Applications/CudaText.app
  2. /Applications/CudaText.app: replacing existing signature
  3. /Applications/CudaText.app: resource fork, Finder information, or similar detritus not allowed

I think that is the cause of the failure when starting the app. Yep - see:

Code: Text  [Select][+][-]
  1. trev@macmini8 [/Users/trev] $ xattr -lr /Applications/CudaText.app/
  2. /Applications/CudaText.app//Contents/MacOS/cudatext: com.apple.FinderInfo: ????????
  3. /Applications/CudaText.app//Contents/MacOS/cudatext: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4
  4. /Applications/CudaText.app//Contents/MacOS: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4
  5. /Applications/CudaText.app//Contents/Info.plist: com.apple.FinderInfo: ????????
  6. /Applications/CudaText.app//Contents/Info.plist: com.apple.lastuseddate#PS: ??a
  7. /Applications/CudaText.app//Contents/Info.plist: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4
  8. /Applications/CudaText.app//Contents/PkgInfo: com.apple.FinderInfo: ????????
  9. /Applications/CudaText.app//Contents/PkgInfo: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4
  10. /Applications/CudaText.app//Contents: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4
  11. /Applications/CudaText.app/: com.apple.quarantine: 0183;61aaf270;Safari;67EDDC8A-2E8A-4BC0-9173-337617FBDEF4

I fixed it by running:

Code: Text  [Select][+][-]
  1. xattr -cr /Applications/CudaText.app/

and now it will happily start from the application bundle :-)

There's also a (non-fatal) missing file/directory:

Code: Text  [Select][+][-]
  1. default 15:54:13.774615+1100    lsd     Non-fatal error enumerating at <private>, continuing: Error Domain=NSCocoaErrorDomain Code=260 "The file “PlugIns” couldn’t be opened because there is no such file." UserInfo={NSURL=PlugIns/ -- file:///Applications/CudaText.app/Contents/, NSFilePath=/Applications/CudaText.app/Contents/PlugIns, NSUnderlyingError=0x12af64180 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: Error with my app bundle for macOS 12 AArch64
« Reply #3 on: December 04, 2021, 08:55:35 pm »
User confirmed that 'xattr' has solved the problem! Tks!

Now I need to adjust the Linux build-script somehow. Is it possible?
On Linux I cannot run the 'xattr' of course.
Script: https://github.com/Alexey-T/CudaText/blob/master/setup/mac_common.sh

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Error with my app bundle on macOS 12 AArch64
« Reply #4 on: December 04, 2021, 11:23:32 pm »
If you are doing this on Linux, then I cannot for the life of me imagine how Finder.Info attributes are being added to your files - I would have said it is impossible.

I just re-checked the dmg I downloaded, and every single one of the files in your application bundle (including your executable) has a Finder.Info attribute.

I can only conclude that at some point your application bundle was on a real macOS system and perhaps someone used Finder > Show Package Contents which can add those attributes.

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: Error with my app bundle on macOS 12 AArch64
« Reply #5 on: December 11, 2021, 07:14:03 pm »
Thanks for help. But I never put my app-bundle to macOS first, I make it on linux and upload to the web.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Error with my app bundle on macOS 12 AArch64
« Reply #6 on: December 11, 2021, 11:20:03 pm »
Then I cannot explain how Linux can add macOS Finder attributes to your files. I would have said it was impossible.

[Edit]

What does lsattr show for the files on your Linux system?
« Last Edit: December 11, 2021, 11:25:55 pm by trev »

AlexTP

  • Hero Member
  • *****
  • Posts: 2365
    • UVviewsoft
Re: Error with my app bundle on macOS 12 AArch64
« Reply #7 on: December 12, 2021, 12:20:17 am »
lsattr shows only ------------ (proper count of '-') for all files, including macOS binary in the bundle.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Error with my app bundle on macOS 12 AArch64
« Reply #8 on: December 12, 2021, 06:17:00 am »
This time I just mounted your CudaText disk image and ran xattr:

Code: Text  [Select][+][-]
  1. trev@macmini7 [/Users/trev] $ xattr -rv /Volumes/CudaText/CudaText.app
  2. /Volumes/CudaText/CudaText.app/Contents/Info.plist: com.apple.FinderInfo
  3. /Volumes/CudaText/CudaText.app/Contents/MacOS/cudatext: com.apple.FinderInfo
  4. /Volumes/CudaText/CudaText.app/Contents/PkgInfo: com.apple.FinderInfo
  5. /Volumes/CudaText/CudaText.app/Contents/Resources/cudatext.icns: com.apple.FinderInfo
  6. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/Bash script.acp: com.apple.FinderInfo
  7. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/Batch files.acp: com.apple.FinderInfo
  8. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/C++.acp: com.apple.FinderInfo
  9. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/C.acp: com.apple.FinderInfo
  10. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/Lua.acp: com.apple.FinderInfo
  11. /Volumes/CudaText/CudaText.app/Contents/Resources/data/autocomplete/PHP_.acp: com.apple.FinderInfo
  12. [...]

Every file has a FinderInfo attribute.

If I mount other disk images downloaded from the web, I get the expected result with the only attribute on each file being the quarantine flag:

Code: Text  [Select][+][-]
  1. trev@macmini7 [/Users/trev/Downloads] $ xattr -rv /Volumes/TG\ Pro/
  2. /Volumes/TG Pro//.DS_Store: com.apple.FinderInfo
  3. /Volumes/TG Pro//TG Pro.app/Contents/_CodeSignature/CodeResources: com.apple.quarantine
  4. /Volumes/TG Pro//TG Pro.app/Contents/_CodeSignature: com.apple.quarantine
  5. /Volumes/TG Pro//TG Pro.app/Contents/Frameworks/libswiftAppKit.dylib: com.apple.quarantine
  6. /Volumes/TG Pro//TG Pro.app/Contents/Frameworks/libswiftCore.dylib: com.apple.quarantine
  7. /Volumes/TG Pro//TG Pro.app/Contents/Frameworks/libswiftCoreData.dylib: com.apple.quarantine
  8. /Volumes/TG Pro//TG Pro.app/Contents/Frameworks/libswiftCoreFoundation.dylib: com.apple.quarantine
  9. [...]

The data in the FinderInfo attributes appears to be invalid, eg on the executable (identical to every other file):

Code: Text  [Select][+][-]
  1. trev@macmini7 [/Users/trev/Downloads] $ xattr -lvxs /Volumes/CudaText/CudaText.app/Contents/MacOS/cudatext
  2. /Volumes/CudaText/CudaText.app/Contents/MacOS/cudatext: com.apple.FinderInfo:
  3. 00000000  3F 3F 3F 3F 3F 3F 3F 3F 00 00 00 00 00 00 00 00  |????????........|
  4. 00000010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
  5. 00000020

The CoreServices.Framework has a header file, Finder.h, which defines the structures used for file information:

Code: C  [Select][+][-]
  1. struct FileInfo {
  2.   OSType              fileType;               /* The type of the file */
  3.   OSType              fileCreator;            /* The file's creator */
  4.   UInt16              finderFlags;            /* ex: kHasBundle, kIsInvisible... */
  5.   Point               location;               /* File's location in the folder */
  6.                                               /* If set to {0, 0}, the Finder will place the item automatically */
  7.   UInt16              reservedField;          /* (set to 0) */
  8. };
  9. [...]
  10. typedef struct ExtendedFileInfo         ExtendedFileInfo;
  11. struct ExtendedFolderInfo {
  12.   Point               scrollPosition;         /* Scroll position (for icon views) */
  13.   SInt32              reserved1;              /* Reserved (set to 0) */
  14.   UInt16              extendedFinderFlags;    /* Extended flags (custom badge, routing info...) */
  15.   SInt16              reserved2;              /* Reserved (set to 0). Comment ID if high-bit is clear */
  16.   SInt32              putAwayFolderID;        /* Put away folder ID */
  17. };

So, I guess it's possible the Linux filesystem is using the same bytes for something different and they're being mistaken for FinderInfo attributes. If you can zero the relevant bytes on Linux, it may solve the problem on macOS.

 

TinyPortal © 2005-2018