alberti42 / Keynote-Progress-Bar

Automatically add a progress bar to Keynote presentations
Other
5 stars 1 forks source link

framework cannot be loaded #1

Closed njkirkpatrick closed 1 month ago

njkirkpatrick commented 1 month ago

When trying to compile the AppleScript, I get the error "The bundle "KeynoteProgressBarHelper" couldn't be loaded". Also, should the framework path be /Library/Frameworks? I don't have a Frameworks directory in /Users/username/Library

alberti42 commented 1 month ago

Yes, you need to create a folder in ~/Library/Frameworks. Apple does not create by default.

alberti42 commented 1 month ago

You need to compile the Objective-C code. This will produce the framework, which must be placed in ~/Library/Frameworks. The AppleScript should be saved in a compiled .scpt' file. This is nicer than running it directly from.applescript'. I did not want to post the .scpt files here because I was afraid people visiting the github page would not be able to see the contents of the code.

njkirkpatrick commented 1 month ago

Still can't get past the error:

error "The bundle “KeynoteProgressBarHelper” couldn’t be loaded." number -4960 from framework "KeynoteProgressBarHelper"

alberti42 commented 1 month ago

I would need much more information to help you. Is it the message you get when you try to save the AppleScript as a .scpt file?

Did you first compile with Xcode the Objective-C code? Did you install the framework in the folder ~/Library/Frameworks?

njkirkpatrick commented 1 month ago

That is the error I get when trying to compile the AppleScript to save as a .scpt.

I compiled the Objective-C code with Xcode and signed it (not sure if that matters). Then I moved the .framework folder it created to ~/Library/Frameworks. I also tried using /Library/Frameworks instead, but the same error happens

alberti42 commented 1 month ago

Ok, I suspect the problem is with Apple policy. They deemed it dangerous to allow user to run such a code.

Check the post https://forums.developer.apple.com/forums/thread/121080

I wrote the code before 2019 but maintained till today. The thing is that in the past years I moved to Script Debugger which is expensive but very powerful. I can reproduce your error with Apple Script Editor but as the post says, there is no problem with Script Debugger. Once you have compiled the app, you do not need Script Debugger to run it. I actually run it from LaunchBar.

We simply need to figure out how to overcome Apple limits. Of course I understand that Apple would like only certified programmers to share code, because this code has been strictly reviewed by Apple.

Running code from the Internet (as this one) can always hide the potential of malicious code. Only few users are skilled enough that they can review the entire code, even if the code is open source.

We need to do some research to understand how to overcome Apple barrier without paying for Script Debugger.

alberti42 commented 1 month ago

We should consider Locations for Private Frameworks from this Apple note: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html.

Maybe there is a way to create an AppleScript app deploying its own Framework that does not need to be share with the computer.

I can see the risk of shared framework. Any code downloaded from the internet can install itself in ~/Library/Frameworks and then when you run other code, they take the privileges from this other code to run their own malicious code. So, maybe Apple still allows to packages frameworks in the Applescript apps. Let's hope so.

alberti42 commented 1 month ago

Just to confirm it, this is what I see when I try to run it in the Apple Script Editor:

Bildschirmfoto 2024-09-17 um 22 31 06

This is the script in the form of an app with the framework embedded:

![Uploading Bildschirmfoto 2024-09-17 um 22.31.15.jpg…]()

I moved the framework inside the app and removed from the shared folder. It worked!

This is the script in action while upgrading the 73 slides of my presentation:

[removed graphics]

I attach here the zip file containig the app.

Add Progress Bar to Keynote.zip

Very likely you will have to remove the quarantine flag that is automatically applied for material downloaded from the internet. See https://superuser.com/a/28394/652944

Then you may need to enable the app to execute operations like automatizing mouse and keystroke actions:

Bildschirmfoto 2024-09-17 um 22 37 04

This is necessary in small part of the code to open keynote presenter note. It also allows the app to set default durations for the slide the first time it runs.

I have a second script that set the duration of each slide based on the actual result of a rehearsal. I did not publish it yet. Then one finds in the presenter notes how long actually each slide took to be presented. It is helpful to find out if some parts needs to be shorten.

njkirkpatrick commented 1 month ago

Thank you for doing all this! It totally works!

alberti42 commented 1 month ago

Awesome. Can you say something more about what made it work? Was the application in the .zip file? If so, I will post it on the front page for others.

njkirkpatrick commented 1 month ago

Yes the application in the .zip file made it work.

alberti42 commented 1 month ago

I released a new version of the application that fixes some bugs. I close this issue as I believe the problem is now fixed. The framework inside the AppleScript application does not throw an error on my computer.

I am not sure if you had to remove the quarantine flag after downloading the zip or not. If so, I would like to include a note in the instructions. Feel free to contact me directly over GitHub: @alberti42