Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacBase Plugin, MBS MacExtras Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacExtras/Sparkle/TestApp
This example is the version from Thu, 24th Jun 2020.
Project "TestApp.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
// please build this app
// make sure the Info.plist is adjusted for your feed URL
// make sure Sparkle.framework is found and included
Dim AppFile As FolderItem = app.ExecutableFile
Dim MacOSFolder As FolderItem = AppFile.parent
Dim ContentsFolder As FolderItem = MacOSFolder.parent
Dim FrameworksFolder As FolderItem = ContentsFolder.Child("Frameworks")
Dim f As FolderItem = FrameworksFolder.Child("Sparkle.framework")
If Not SUUpdaterMBS.LoadFramework(f) Then
break
MsgBox "Failed to load Sparkle framework"
quit
end if
u=new MySUUpdater
dim d as date
dim lines(-1) as string
lines.Append "Sparkle Status:"
lines.Append ""
dim b as NSBundleMBS = u.hostBundle
if b = nil then
lines.Append "HostBundle: ?"
else
lines.Append "HostBundle: "+b.bundlePath
end if
try
lines.Append "FeedURL: "+u.feedURL
catch n as NSExceptionMBS
lines.Append "FeedURL: ?"
end try
d=u.lastUpdateCheckDate
if d=nil then
lines.Append "lastUpdateCheckDate: ?"
else
lines.Append "lastUpdateCheckDate: "+d.LongDate+" "+d.LongTime
end if
// shows information
MsgBox Join(lines,EndOfLine)
u.checkForUpdates
exception e as NSExceptionMBS
MsgBox e.message
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
Property Private u As mysuUpdater
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MySUUpdater Inherits SUUpdaterMBS
EventHandler Sub didAbortWithError(error as NSErrorMBS)
Log CurrentMethodName
Log "Errorcode: "+Str(error.Code)
Log "LocalizedDescription: "+error.LocalizedDescription
End EventHandler
EventHandler Sub didDownloadUpdate(item as SUAppcastItemMBS)
log CurrentMethodName
End EventHandler
EventHandler Sub didExtractUpdate(item as SUAppcastItemMBS)
log CurrentMethodName
End EventHandler
EventHandler Sub didFindValidUpdate(update as SUAppcastItemMBS)
Log CurrentMethodName
log "Title: "+update.title
log "Version: "+update.displayVersionString
'log "DSASignature: "+update.DSASignature
End EventHandler
EventHandler Sub didFinishLoadingAppcast(update as SUAppcastMBS)
log CurrentMethodName
'MsgBox update.incrementalData
End EventHandler
EventHandler Sub failedToDownloadUpdate(item as SUAppcastItemMBS, error as NSErrorMBS)
Log CurrentMethodName
Log "Errorcode: "+Str(error.Code)
Log "LocalizedDescription: "+error.LocalizedDescription
End EventHandler
EventHandler Sub updaterDidNotFindUpdate()
log CurrentMethodName
End EventHandler
EventHandler Sub willDownloadUpdate(item as SUAppcastItemMBS, request as Variant)
log CurrentMethodName
End EventHandler
EventHandler Sub willExtractUpdate(item as SUAppcastItemMBS)
log CurrentMethodName
End EventHandler
EventHandler Sub willInstallUpdate(update as SUAppcastItemMBS)
log CurrentMethodName
End EventHandler
Private Sub log(s as string)
System.DebugLog s
window1.List.AddRow s
End Sub
End Class
ExternalFile Info
End ExternalFile
End Project
The items on this page are in the following plugins: MBS MacExtras Plugin.