8 Replies
      Latest reply on Oct 3, 2019 5:57 AM by john daniel
      m.masa Level 1 Level 1 (0 points)

        Now I'm working on developing iOS application which need the function of FTP client.

         

        And I'm looking for an available OSS(Library) of FTP client but couldn't find good one.

         

        Now I'm implementing the application with Swift4(XCode9.2, iOS11SDK)

         

        My requirements for the OSS are below:

         

        • Support passive mode, FTPS, port select, make/remove folder, SSL Implicit mode(optional)
        • Avoid deprecated API as far as possible
        • Currently maintained
        • MIT or BSD License

         

        If you know other recommended FTP client OSS for iOS, please let me know.

         

        I'd appreciate if you would provide me helpful information.

         

         

        So far I've found the following OSS.

         

        [GoldRaccoon]

        <https://github.com/albertodebortoli/GoldRaccoon>

        • I've tested FTP file upload with sample Application and it succeeded.
        • No update for nearly 4 years.
        • Has Deprecated API such as `CFWriteStreamCreateWithFTPURL`

         

        [rebekka]

        <https://github.com/Constantine-Fry/rebekka>

        • Written in Swift2
        • Has Deprecated API such as `CFWriteStreamCreateWithFTPURL`
        • I'm working on building for this OSS with Xcode9.2(Swift4). But it doesn't yet.

         

        [FileProvider]

        <https://github.com/amosavian/FileProvider>

        • Written in Swift4 and maintained even now. But no sample application.
        • I'm trying to create test application for this OSS. But it doesn't work yet.
        • Re: FTP client OSS(Library) for iOS
          john daniel Level 3 Level 3 (450 points)

          cURL?

          • Re: FTP client OSS(Library) for iOS
            eskimo Apple Staff Apple Staff (11,955 points)

            Why are you implementing FTP?  FTP is a horrible protocol in general, and it has specific security problems that make it unsuitable for use on the modern Internet.  In the vast majority of cases there are better alternatives.

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: FTP client OSS(Library) for iOS
              Sim2019 Level 1 Level 1 (0 points)

              What did you end up using?

               

              I tested FileProvider but it's pretty buggy with Swift 5 and it doesn't look like the author's even supporting it anymore (he hasn't posted in the "Issues" section in months).

                • Re: FTP client OSS(Library) for iOS
                  akirmse Level 1 Level 1 (0 points)

                  I'm also curious.. I tried FileProvider but it has some hard-coded sleep() calls in its protocol implementation that appear to be hacky and don't work with all servers, in particular, the one I'm connecting to.

                   

                  Since Quinn has pointed out the deficiencies of FTP in multiple threads, I'll add that I'm connecting to an old U.S. government server that supports only FTP.  I have pointed out the security problems but they have refused to upgrade for the last 4 years.  The Android version of my app has no problems doing FTP.  The iOS version currently uses the deprecated CFWriteStreamCreateWithFTPURL so I am worried about it suddenly breaking at some point in the future due to Apple's whims.

                    • Re: FTP client OSS(Library) for iOS
                      eskimo Apple Staff Apple Staff (11,955 points)

                      I'm connecting to an old U.S. government server that supports only FTP.

                      In this situation my advice would be to create a web service to front the FTP server.  You can then talk to your web service using HTTPS, and the web service can talk to the legacy server using FTP.

                      This has a bunch of advantages:

                      • You don’t have to worry about doing FTP on the client.

                      • If the legacy server changes to break your client, it’s easy to deploy a fix.

                      • It’s significantly more secure, because the insecure connection is data centre to data centre, not client to data centre.

                      The obvious disadvantage is that you have to maintain this infrastructure.

                      Share and Enjoy

                      Quinn “The Eskimo!”
                      Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                      let myEmail = "eskimo" + "1" + "@apple.com"

                        • Re: FTP client OSS(Library) for iOS
                          john daniel Level 3 Level 3 (450 points)

                          I'm sorry, but I'm going to have to disagree with you on that approach.

                          • FTP on the client is no big deal. I don't understand the requirement to have a native Swift solution. I did mention perhaps the most robust of all FTP clients, cURL. I'm sure there are at least a few dozen others. Yes. They are probably in C. Such is life for Swifties. Everything has to be wrapped and then implicity unwrapped again.
                          • A server-based FTP gateway is three times the work. You still need the FTP client. But you also need a web server. And then you need a client to talk to the web service. If the legacy server changes, everything is broken. That's a ton of work to throw in the trash.
                          • There is no inherent security in a server-side tool. Unless that web service is coded very securely, it could potentially expose all FTP credentials for all users. Users and the government would not appreciate accounts and passwords being used and potentially stored in a data centre. Individual devices would be much more secure. This is FTP. Your security is mainly tied to your obscurity. It is better to have X number of ephemeral mobile clients scattered across the world instead of one server you can beat on 24x7.

                           

                          Finally, US government FTP sites don't get updated, they get replaced. A US government FTP server should have been replaced years ago. I don't know how it has lasted this long. I replaced a similar US government FTP server over a decade ago. They have very strict security requirements and are actively trying to consolidate services to reduce their internet footprint. They probably haven't "refused" to upgrade the server. They likely didn't have the funding and/or are still working on it.

                            • Re: FTP client OSS(Library) for iOS
                              AppolyBilly Level 1 Level 1 (0 points)

                              Did you find a good library?

                               

                              I'm having a similar issue at the moment with using FTP and Swift. We have had a proprietary device come in from a client that has it's own wireless access point built in. I've tried to implement FTP natively and I'm now having a go using the FileProvider library linked in the original post.

                               

                              With both solutions I can list directories without issues however I keep getting a connection timed out 1001 error when trying to download the file:

                               

                              Error Domain=NSURLErrorDomain Code=-1001 "(null)"

                               

                              Haven't been able to come up with a viable solution. The aim of the solution is to pull logfiles off of the device and upload them to S3.

                               

                              I've tried pulling files off the device with an app and it works without fuss, so I know this is definitely supported. The app is:

                               

                              https://apps.apple.com/gb/app/ftpmanager-ftp-sftp-client/id525959186

                               

                              Let me know if you find a suitable library for FTP.

                                • Re: FTP client OSS(Library) for iOS
                                  john daniel Level 3 Level 3 (450 points)

                                  I'm not actively searching for such a library. I just had the misfortune once to try to write a funky Mac app that had FTP support. As far as I'm concerned, the security issues are the least of its problems. A bigger problem is that there are so many different FTP implementations and they can behave radically differently. That is why I suggested using cURL. It is one of the oldest libraries with good support for the many different flavours of FTP. I'm sure it doesn't have a native Swift API. Even the C API is funky. But it works and itsn't difficult to use. I think it is the easiest way to go get the widest support for the many different FTP flavours.

                                   

                                  I don't know what that app is using. It really isn't a question of what is "supported" or not. Apple doesn't "support" FTP at all anymore. But it is just a networking protocol. Depending on your networking skills, you could write a FTP client from scatch. I did that at university in Java many years ago. But the problem is that there is no way to predict what kind of funky FTP server you are going to encounter in the real world. If you want to support FTP, you are going to have to track down each one of them, get access to it somehow for testing, and try to make it work. That's just insane. That is why Apple so strongly recommends avoiding. I think the security issue is just a useful red herring because people who haven't tried to write FTP probably wouldn't believe how crazy it can be. But they are more likely to accept the security explanation, which is certainly true. In the end, Apple wants people to be happy and productive. That means avoiding FTP if at all possible.