I am using the below code snippet to get the system preferences firewall status wheter it is ON/OFF using system .plist file.func getFirewallStatus() -> Bool {
let paths = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .systemDomainMask, true)
var path = paths[0]
path = "\(path)/\("Preferences/com.apple.alf.plist")"
path = path.replacingOccurrences(of: "/System", with: "")
let _dictionary = NSDictionary(contentsOfFile: path)
// firewall status
let status = (_dictionary["globalstate"] as? NSNumber)?.intValue ?? 0
if status == 0 {
return false
}
return true
}Sandbox disable(Xcode): In this case, I am able to get the firewall status (On/Off).Sandbox enable(Xcode): app is crashing when accessing the contents of file.let _dictionary = NSDictionary(contentsOfFile: path)Please let me know the reasons, why app is crashing in case of sandbox enable mode?My intention is to get the status of firewall and not to update any system preferences config.Thanks in advance!
Post
Replies
Boosts
Views
Activity
I tried using "Reachability" class to check whether my network connected to LTE or Wifi in Swift but i am not able to get the solution.I have created a Mac OS application and added Reachability class. Now i have to check whether my network is Wifi or Cellular(4G, LTE).is there a way to find this?Iam using SystemConfiguration framework and "isWWAN" always returns false.
I am trying to get the connected wifi password from keychain access in one of the macOS application and am able to get the password using the following code:There are two ways to get the wifi password:1. Via Security Framework Api SecItemCopyMatching(_:_:)let query = [
kSecClass as String: kSecClassGenericPassword as String,
kSecAttrAccount as String: accountName,
kSecReturnData as String: kCFBooleanTrue as Any,
kSecMatchLimit as String: kSecMatchLimitOne
] as [String : Any]
var dataTypeRef: AnyObject?
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &dataTypeRef)
var data: Data?
if status == noErr{
data = dataTypeRef as? Data
print(data!)
print(String(decoding: data!, as: UTF8.self))
}
return data != nil ? NSString(data: data!, encoding: String.Encoding.utf8.rawValue)! as String : ""2. Via CoreWLAN Framework Api CWKeychainFindWiFiPassword(_:_:_:), By passing the SSID data, we can get the wifi password.func getPassword(data:Data) -> String {
var responseData:NSString? = nil
var thePassword:String = ""
var status:OSStatus?
if data.count > 0
{
status = CWKeychainFindWiFiPassword(CWKeychainDomain.system, data, &responseData)
if status == noErr {
thePassword = responseData! as String
}
}
return thePassword
}Query:Everytime while executing the either way keychain access is poping the modal window to provide admin credentials to acess the password.Let me know if there is any way to bypass the above modal window by supplying the username and passoword in the code (background).
In my macOS Application, trying to get the stored/saved wifi password from keychain access.Will it be allowed in AppStore? if my application has the code to get the wifi password from keychain access.I have gone through few apple forums but i did not see the exprected reply. Please help me out.
Requirement:Whenever i run the cocoa app exe, I should be able to enable the log level (info, debug, error, fault) using mac terminal.if i enable log level as debug, only debug logs should appear in terminal at runtime.i used the below command to enable the log level as "debug" in subsytem plist file."sudo log config --mode "level:debug" --subsystem com.companyName.ProjectName"but its not enabling the log level, please let me know the steps to achieve this.
I have created the macOS application and I am using "CoreWLAN" framework to list all available wifi networks using the classes "CWInterface" and "CWNetwork" and able to get the current connected interface details like, SSID, BSSID, RSSI etc.UseCase: I have created a new guest network in the router and connected in MAC (ex: "Test_Guest") , now I have to find whether the connected network is Guest network or not?Is there any other frameworks can find this behaviour in the wifi network and that should be acceptable by the AppStore.Thanks in advance.
How to check if my app is using any api's which does not meet the apple review guidelines.Let me know any suggestions to analyze this.