I'm trying to use LestMove to be more precise the second implementation method where it says:
Option 2:
Copy the following files into your project:
PFMoveApplication.h PFMoveApplication.m If your project has ARC enabled, you'll want to disable ARC on the above files. You can do so by adding -fno-objc-arc compiler flag to your PFMoveApplication.m source file. See How can I disable ARC for a single file in a project?
If your application is localized, also copy the 'MoveApplication.string' files into your project.
Link your application against Security.framework.
In your app delegate's "-[applicationWillFinishLaunching:]" method, call the PFMoveToApplicationsFolderIfNecessary function at the very top.
but I'm not able to call the method / Class, could someone help me with this issue? Thanks in advance!
In general, there are a couple of ways to set up an Objective-C class in your AppleScriptObjC project:
@interface
/@implementation
declarationsAdd an outlet property in the AppleScript class/script you are using, e.g. property someProperty : missing value
Instantiate the class programmatically:
set someProperty to current application's ClassName's alloc's init()
or
After setting up the outlet property, the Objective-C methods can be used like any other script/class:
someProperty's handler()
That LetsMove project wasn't really set up for AppleScriptObjC, but I was able to tweak it a bit to get it running. I'm not that great at writing Objective-C, but the following worked for me using a new default AppleScript project with Xcode 10 in Mojave (the original file is over 500 lines long, so I'm just highlighting the changes):
PFMoveApplication.h
and PFMoveApplication.m
files to the project (the class name is LetsMove
)Security.framework
to Link Binary With Libraries in Build Phases-fno-objc-arc
to the Objective-C file in Compile Sources of the Build Phases-- Now to alter the Objective-C files a bit:
@interface
declaration to the .h
file and include the redefined method signatures below in it:The PFMoveToApplicationsFolderIfNecessary
and PFMoveIsInProgress
methods are redefined as instance methods:
- (void)PFMoveToApplicationsFolderIfNecessary;
- (BOOL)PFMoveIsInProgress;
.m
file, and include those methods in the @implementation
section - to do this, move the @end
to just before the helper methods (after the PFMoveIsInProgress
method)isMainThread
statement at the beginning of the PFMoveToApplicationsFolderIfNecessary
method - this is not not needed (AppleScript normally runs on the main thread), and fixes another issueAnd finally, in the AppDelegate.applescipt
file, the following was added to applicationWillFinishLaunching:
current application's LetsMove's alloc's init()'s PFMoveToApplicationsFolderIfNecessary()