Is it possible to load a configuration profile in a Xojo app? if so, in a transparent way for the user?
Thanks
That’s entirely up to you. Of course, you can save information locally in a file and load it again at any time.
If you are looking for some kind of Preferences File solution, there is something on GitHub that might help you. The project is easy to convert to Xojo API2 format if needed.
CharlieXojo/classPreferences: A cross platform preferences class for Xojo using SQLite (github.com)
The Gatekeeper command (sudo spctl --master-disable) no longer seems to work under macOS Sequoia. It says: “This operation is no longer supported. Use the profile configuration”.
Alienator, the editor of the Sentinel app (GitHub - alienator88/Sentinel: SwiftUI gatekeeper configuration GUI ) found a solution (temporary?) which goes through a macOS configuration profile (at the address: https://github.com/bluppus20/Disable-Gatekeeper - macOS-Sequoia-beta-3 )
Why do you want to disable Gatekeeper?
i used this module settings
at app opening event
Settings.Load
at app closing event
Settings.Save
all the properties have default values
Public Sub Save()
Var f As FolderItem = File
Var d As New Dictionary
d.Value("SaveDate") = DateTime.Now.SQLDateTime
d.Value("AutoSave") = Settings.AutoSave
d.Value("StartMaximized") = Settings.StartMaximized
d.Value("RoundEdges") = Settings.RoundEdges
d.Value("FillStyle") = Settings.FillStyle
d.Value("BoardBackgroundColor1") = ColorToString(Settings.BoardBackgroundColor1)
d.Value("BoardBackgroundColor2") = ColorToString(Settings.BoardBackgroundColor2)
Var j As JSONItem
j = d
j.Compact = False
Var st As TextOutputStream = TextOutputStream.Create(f)
st.Write j.ToString
st.Close
System.DebugLog "Saved Settings to " + f.NativePath
End Sub
Public Sub Load()
Var f As FolderItem = File
If f.Exists = False Then Return
System.DebugLog "Load " + f.NativePath
Var st As TextInputStream = TextInputStream.Open(f)
Var d As Dictionary
d = Xojo.ParseJSON(st.ReadAll)
Settings.AutoSave = d.Lookup("AutoSave",False)
Settings.StartMaximized = d.Lookup("StartMaximized",False)
Settings.RoundEdges = d.Lookup("RoundEdges",True)
Settings.FillStyle = d.Lookup("FillStyle","Full")
Settings.BoardBackgroundColor1 = StringToColor(d.Lookup("BoardBackgroundColor1",ColorToString(Color.FillColor)))
Settings.BoardBackgroundColor2 = StringToColor(d.Lookup("BoardBackgroundColor2",ColorToString(Color.FillColor)))
st.Close
End Sub
Public Function File() As FolderItem
Var path As FolderItem = SpecialFolder.ApplicationData.Child("YourApp")
If path.Exists = False Then path.CreateFolder
Return path.Child("YourAppSettings.json")
End Function
Public Function ColorToString(c As Color) As String
Return Str(c)
End Function
Public Function StringToColor(v as Variant) As Color
Var c As Color = v
Return c
End Function
Protected Property BoardBackgroundColor1 As Color = &cD8E9FC00
Protected Property BoardBackgroundColor2 As Color = &cF2D7DE00
Protected Property AutoSave As Boolean = False
Protected Property StartMaximized As Boolean = False
Protected Property RoundEdges As Boolean = True
Protected Property FillStyle As String = "Full"
ui methods as example
Public Sub FromUI()
Settings.AutoSave = CheckBoxAutoSave.Value
Settings.StartMaximized = CheckBoxStartMaximized.Value
Settings.RoundEdges = CheckBoxRoundEdges.Value
Settings.FillStyle = PopupFillStyle.SelectedRowValue
Settings.BoardBackgroundColor1 = ButtonColor1.BackgroundColor
Settings.BoardBackgroundColor2 = ButtonColor2.BackgroundColor
End Sub
Public Sub ToUI()
LabelPath.Text = Settings.File.NativePath
CheckBoxAutoSave.Value = Settings.AutoSave
CheckBoxStartMaximized.Value = Settings.StartMaximized
CheckBoxRoundEdges.Value = Settings.RoundEdges
PopupFillStyle.SelectedRowIndex = 0
For i as integer = 0 To PopupFillStyle.RowCount-1
If PopupFillStyle.RowValueAt(i) = Settings.FillStyle Then
PopupFillStyle.SelectedRowIndex = i
Exit
End If
Next
ButtonColor1.BackgroundColor = Settings.BoardBackgroundColor1
ButtonColor2.BackgroundColor = Settings.BoardBackgroundColor2
End Sub
Are you sure we’re talking about the same thing? I don’t see the connection with the loading of the configuration profiles.mobileconfig and even less with GK…
Sorry, but your initial question was so open and unspecific that it is not easy to answer…
ClaudeAI request (not tested) :
Loading the file in Xojo:
Dim configFile As FolderItem = GetFolderItem("path/to/gk.mobileconfig")
If configFile <> Nil And configFile.Exists Then
// The file exists and can be read
Else
// Handle the error: file not found
End If
Reading the contents of the file:
Dim configContent As String
Try
Dim textInput As TextInputStream = TextInputStream.Open(configFile)
configContent = textInput.ReadAll()
textInput.Close
Catch e As IOException
// Manage reading errors
End Try
Content analysis:
Dim xmlDoc As New XMLDocument
Try
xmlDoc.LoadXML(configContent)
// Access the profile elements
Dim payloadContent As XMLNode = xmlDoc.DocumentElement.Child("dict").Child("array").Child("dict")
// Check the specific parameters, for example :
If payloadContent.Child("key").Value = "PayloadType" And payloadContent.Child("string").Value = "com.apple.systempolicy.control" Then
// This is indeed a configuration profile for Gatekeeper
End If
Catch e As XMLException
// Handling XML parsing errors
End Try
Application of the profile:
#If TargetMacOS Then
Declare Function SecProfileInstall Lib "Security" (data As Ptr, flags As Integer, ByRef error As Ptr) As Boolean
Dim mb As MemoryBlock = configContent
Dim error As Ptr
If SecProfileInstall(mb, 0, error) Then
MsgBox "Successfully installed Gatekeeper profile"
Else
MsgBox "Error installing the Gatekeeper profile"
End If
#EndIf
Anyone valid?
Thanks