Cannot find type 'AWSS3TransferManagerUploadRequest' in scope

2.1k views Asked by At

I am new in Swift. Since I update podfile I am facing issue in AWSS3

Cannot find type 'AWSS3TransferManagerUploadRequest' in scope
Cannot find type 'AWSS3TransferManagerDownloadRequest' in scope

There is also import AWSS3 in ViewController.

I am not understanding the problem. Did someone face the same issue?

I also check this https://stackoverflow.com/questions/32659346/awss3transfermanageruploadrequest-in-xcode-7

But it does not help.

    var uploadRequests = Array<AWSS3TransferManagerUploadRequest?>()
    var uploadFileURLs = Array<URL?>()    
    var downloadRequests = Array<AWSS3TransferManagerDownloadRequest?>()
    
        func download(_ downloadRequest: AWSS3TransferManagerDownloadRequest) {
            switch (downloadRequest.state) {
            case .notStarted, .paused:
                let transferManager = AWSS3TransferManager.default()
                transferManager.download(downloadRequest).continueWith(block: { (task) -> AWSTask<AnyObject>? in
                    if let error = task.error {
                        if error.domain == AWSS3TransferManagerErrorDomain as String
                            && AWSS3TransferManagerErrorType(rawValue: error.code) == AWSS3TransferManagerErrorType.paused {
                            print("Download paused.")
                        } else {
                            print("download failed: [\(error)]")
                        }
                    } else if let exception = task.error {
                        print("download failed: [\(exception)]")
                    } else {
                        DispatchQueue.main.async(execute: { () -> Void in
                            print("downloaded file url: \(downloadRequest.downloadingFileURL)")
    //                        if let index = self.indexOfDownloadRequest(self.downloadRequests, downloadRequest: downloadRequest) {
    //                            self.downloadRequests[index] = nil
    //                            self.downloadFileURLs[index] = downloadRequest.downloadingFileURL
    //                            
    //                            let indexPath = NSIndexPath(forRow: index, inSection: 0)
    //                            self.collectionView.reloadItemsAtIndexPaths([indexPath])
    //                        }
                        })
                    }
                    return nil
                })
                
                break
            default:
                break
            }
        }
        func downloadAll() {
            for (_, value) in self.downloadRequests.enumerated() {
                if let downloadRequest = value {
                    if downloadRequest.state == .notStarted
                        || downloadRequest.state == .paused {
                        self.download(downloadRequest)
                    }
                }
            }
            
    //        self.collectionView.reloadData()
        }

func listObjects() {
        let s3 = AWSS3.default()
        
        let listObjectsRequest = AWSS3ListObjectsRequest()
        listObjectsRequest?.bucket = "dice-ios"
        s3.listObjects(listObjectsRequest!).continueWith { (task) -> AnyObject? in
            if let error = task.error {
                print("listObjects failed: [\(error)]")
            }
            if let exception = task.error {
                print("listObjects failed: [\(exception)]")
            }
            if let listObjectsOutput = task.result {
                if let contents = listObjectsOutput.contents {
                    for s3Object in contents {
                        
                        let downloadingFileURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("download").appendingPathComponent(s3Object.key!)
                        let downloadingFilePath = downloadingFileURL.path
                        
                        if FileManager.default.fileExists(atPath: downloadingFilePath) {
                            self.downloadRequests.append(nil)
                            self.downloadFileURLs.append(downloadingFileURL)
                        } else {
                            let downloadRequest = AWSS3TransferManagerDownloadRequest()
                            downloadRequest?.bucket = "dice-ios"
                            downloadRequest?.key = s3Object.key
                            downloadRequest?.downloadingFileURL = downloadingFileURL
                            
                            self.downloadRequests.append(downloadRequest)
                            self.downloadFileURLs.append(nil)
                        }
                    }
                    
                    DispatchQueue.main.async(execute: { () -> Void in
//                        self.collectionView.reloadData()
                    })
                }
            }
            return nil
        }
    }

My code is like this I am getting issue since I update the podfile.I am facing issue in AWS3 as it is updated. I need to know what to replace.

3

There are 3 answers

0
dozer On

You need to downgrade your AWSS3 pod version. Check the pod folder to see if the tool you're using is there (In my case, AWSS3TransferManager.h was missing from current version, downgraded to a version that had it).

0
Michael Scarn On

If you're using Swift package manager to add the package, make sure you use the github url https://github.com/aws-amplify/aws-sdk-ios-spm.git, not https://github.com/awslabs/aws-sdk-swift.git.

0
Changlin An On

I coped with the same problem when I was integrating the pod named AWSS3.

I fixed it by installing the specific version of these pods. Please check this URL https://cocoapods.org/pods/AWSS3#changelog

In my case, I installed the v2.16.0.

I think it is concerning with the Xcode version.

pod 'AWSS3', '~> 2.16.0'

I hope this helps you.