0

I've written a basic FTP Server app in Swift 5 using SwiftUI, it needs to keep a TCP socket listener open waiting for incoming ftp client connections. Ideally I'll keep it running with the phone locked.

I've read you can hijack the Background modes in Swift to run other code, which is fine as this app will never be published - it's for my use only to transfer pics off a DSLR. Someone suggested in a thread to use the Audio mode to play a silent file and that would keep everything running. Does anyone know if what I'm trying to do is possible?

I've added an AVAudioPlayer that just loops a random file and updated Info.plist to add the Audio BG mode, but I think more than this is required as it doesn't appear to be working.

Based off this post it looks like I could maybe use VoIP bg mode? Any input or advice appreciated :)

Mike Anthony
  • 429
  • 3
  • 9
  • 1
    The only way to implement a server on iOS is _not_ to go into the background. – matt Dec 18 '22 at 15:02
  • 1
    The only way is to pretend to be a "streaming" or VoIP app. I had to do something like that in the past, but I doubt this would be allowed in the app store (I did it for the app that was only used via MDM in an enterprise, so they didn't care). So straight answer is: you can't do it. – timbre timbre Dec 18 '22 at 18:24
  • @akjndklskver I won't need to publish this to the App Store, as I mentioned this is just a personal app for me. Do you have any extra info on implementing the "streaming/voip" part to keep it active in the bg? – Mike Anthony Dec 19 '22 at 02:41

0 Answers0