The delete key removed the Terminal's "New Remote Connection" list in the Build Settings tab.
I added the Info.plist file by adding a key value pair I did find a way to add. This was in "URL Types". As soon as I added this an Info.plist file appeared in the project. I then removed the URL type I added. I then edited the newly created Info.plist file to add the key, value, pair: "Bonjour services", "_ssh._tcp" to it. This worked in the iPhone 14 simulator running in the MacStudio. The MacStudio did show up in Terminal's "New Remote Connection" list.
But when the program was downloaded into a real iPhone 14 over a lightning cable I still got the 65555 NoAuth error, and the real iPhone 14 did not appear in the Terminal's "New Remote Connection" list. It is as if the key, value, pair: "Bonjour services", "_ssh._tcp" in the Info.plist file did not make it into the real iPhone 14. This screen shot shows the setup:
Post
Replies
Boosts
Views
Activity
I have an error when I try to do this. My code is based on eskimo's. My version of it is:
import Foundation
import Network
class SSH_Session: ObservableObject{
public private(set) var listener: NWListener? = nil
public private(set) var ButtonText: String = ""
@Published public private(set) var isListening: Bool = false
init(){
setButtonText( false )
}
public func start(){
print("listener will start")
listener = (try? NWListener(using: .tcp) ) ?? nil
if (listener == nil) {
print( "Failed listener acquisition." )
setButtonText( false )
}else {
listener?.stateUpdateHandler = { newState in
print("listener did change state, new: \(newState)", "" )
if( (self.listener?.debugDescription != nil) && (self.listener?.debugDescription != "") ) {
print( " " + self.listener!.debugDescription )
}else{
print( "\n" )
}
}
listener?.service = .init(type: "_ssh._tcp")
listener?.newConnectionHandler = { connection in
let remotePeer = connection.currentPath?.remoteEndpoint
print("listener rejected a receive connection, from: \(remotePeer as Optional)")
connection.cancel()
}
listener?.start(queue: .main)
setButtonText( true )
}
return
}
public func stop() {
print("listener will stop")
self.listener?.stateUpdateHandler = nil
self.listener?.cancel()
setButtonText( false )
}
public func StartStop() {
if( self.isListening ) {
self.stop()
} else {
self.start()
}
}
private func setButtonText( _ isListening: Bool )
{ self.isListening = isListening
ButtonText = isListening ? "Close SSH Connection" : "Open SSH Connection"
}
}
In my version of stateUpdateHandler I included a verbose diagnostic.
Xcode is installed in the iPhone 14, and it is in developer mode. I turned off Bluetooth, WiFi, and cell service even though it is not connected to a cell service.
Info.plist is not automatically added to a project since Xcode 13. I am using Xcode 14.3. When the project was created I did not know to add one. So I used the properties GUI. In the "Build Settings" tab I added the key value pair shown in this screenshot:
The screenshot includes the error I got. I copy and paste its text here:
listener will start
listener did change state, new: ready
[L1 failed, local endpoint: <NULL>, parameters: tcp, local: ::.49728, definite, attribution: developer, server, port: 49728, path satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, service: <NULL>._ssh._tcp.<NULL> txtLength:0]
listener did change state, new: failed(-65555: NoAuth)
[L1 failed, local endpoint: <NULL>, parameters: tcp, local: ::.49728, definite, attribution: developer, server, port: 49728, path satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, service: <NULL>._ssh._tcp.<NULL> txtLength:0]
The terminal program in the MacStudio does not show any SSH servers are available iPhone. The iPhone's SSH service appears not to be advertised.
I do not know what to do about this error. Any suggestions would be appreciated.
Never mind.
I found out that as of Xcode 13 the Info.plist file is no longer automatically generated, and are now optional. I wanted to edit this file because there was a key value pair I needed to add. I found I can click on the project in the "Project navigator", and add this in the project's "Build Settings" tab by clicking on the + sign to the upper left.
Thank you for your reply. In my case what needs to be enumerated are four iPhones connected to a MacStudio by means of Lightning Cable. I am attempting to enumerate these to establish communications with software also written by me in the iPhones.
I did the conversion you recommended. But when I attempt to use my equivalent of your "newResultsArray" in a View's ForEach statement I find that something is lost in the conversion. When I attempt to use my equivalent, which in my code is the results member of the SSH_Browser class (code below), I get an error in the View. What was lost? What needs to be done to get the print function to accept it?
The code, and the error message in comments:
struct ContentView: View {
@StateObject var sshBrowser = SSH_Browser()
var body: some View {
VStack {
ForEach( sshBrowser.results, id:\.hashValue ) { result in
print("result ", result ) // Red underline under the first character of "print(...". The error: "No exact matches in reference to static method 'buildExpression'"
}
}
.padding()
}
}
class SSH_Browser: ObservableObject {
var browser: NWBrowser!
@Published var results: [NWBrowser.Result] = []
init() {
let bonjourTCP = NWBrowser.Descriptor.bonjour(type: "_ssh._tcp" , domain: nil)
let bonjourParms = NWParameters.init()
browser = NWBrowser(for: bonjourTCP, using: bonjourParms)
// This change event handler code executes when available devices change.
browser.browseResultsChangedHandler = { ( results, changes ) in
for result in results {
print("result ", result ) // No error here. The "result" Set element is accepted.
if case .service(let service) = result.endpoint {
print("bonjourA ", service.name)
}
}
self.results = Array( results ) // Something is lost here, for when used in the View the print() function does not accept the self.results array elements.
}
browser.start(queue: DispatchQueue.main)
}
}
I too got this error when I reorganized, and renamed, project directories. Evidently I did not do that right, if there is a way to do it at all. If there is not, there should be one made. This is the error I got:
Executable Path is a Directory
Domain: DVTMachOErrorDomain
Code: 5
Recovery Suggestion: /Users/spflanze/Library/Developer/Xcode/DerivedData/Bonjour-Trial-iPhone-fotboannvetiniedscmjlgfnqmmh/Build/Products/Debug-iphonesimulator/Bonjour-trial-iPhone.app is not a valid path to an executable file.
User Info: {
DVTErrorCreationDateKey = "2023-05-18 16:11:29 +0000";
}
--
System Information
macOS Version 13.3.1 (a) (Build 22E772610a)
Xcode 14.3 (21812) (Build 14E222b)
Timestamp: 2023-05-18T09:11:29-07:00
I do not know how to fix this project. I have come to the conclusion I will have to start again with a newly made project file, and copy my source code from the failed project into the new one.
Does the Multipeer Connectivity framework support peer to peer connectivity over a lighting cable between a Mac Studio, and iPhone 14?