akeru-inc/xcnotary

"Error: Expected an application bundle ..." for valid app bundle

martinh2011 opened this issue ยท 2 comments

In a CI pipeline I observed that for a perfectly valid app bundle xcnotary always returned
Error: Expected an application bundle, disk image, or installer package at...

It worked fine If I ran xcnotary manually with the exact same app bundle on the same machine ๐Ÿ˜ฎ

To find the root cause I looked into the xcnotary source and added the mdls call you use to check the input path to my build pipeline, e.g like this

xcodebuild -exportArchive ...
/usr/bin/mdls -name kMDItemContentTypeTree "my-appbundle.app"`
xcnotary notarize "my-appbundle.app" ...

I get kMDItemContentTypeTree = (null) as the mdls result and xcnotary fails. If I add a sleep 30 before the xcnotary call everything works fine.

I could not reproduce this on my development machine, mdls always returned correct results there. I suspect that on the build machine the spotlight index is not updated fast enough. On another machine where spotlight is completely disabled, xcnotary always returns
Error: my-appbundle.app: could not find my-appbundle.app
which is the error message mdls produces when there is no spotlight index

Maybe better not rely on a working spotlight index? ๐Ÿ˜‰

The build system uses macOS 10.15.4, my test system where Spotlight was disabled used macOS 10.15.3.

Thanks for the detailed report! I'm going to simplify this and revert to just using the file extension, since mdls provides dubious benefit (e.g. even mkdir Foo.app && mdls -name kMDItemContentTypeTree Foo.app identifies as bundle.)

Fixed in v0.4.1