This is an automated email from the ASF dual-hosted git repository.

manuelbeck pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-file-transfer.git


The following commit(s) were added to refs/heads/master by this push:
     new 7b869a2  fix(ios): cast to `CDVFile` when getting the plugin by 
`getCommandInstance` (#385)
7b869a2 is described below

commit 7b869a2276ae9df13c5ae7dcb6c4385ebc87dd4e
Author: Manuel Beck <[email protected]>
AuthorDate: Mon Jan 19 23:13:59 2026 +0100

    fix(ios): cast to `CDVFile` when getting the plugin by `getCommandInstance` 
(#385)
    
    - `CDVCommandDelegate getCommandInstance` returns a `CDVPlugin` which does 
not know about the selectors of an inherited class like `CDVFile`. If not 
casted, XCode will throw an error like `error: no visible @interface for 
'CDVPlugin' declares the selector 'filesystemForURL:'`.
---
 src/ios/CDVFileTransfer.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 66cb9a1..5dca9a4 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -289,7 +289,7 @@ static CFIndex WriteDataToStream(NSData* data, 
CFWriteStreamRef stream)
     delegate.source = source;
     delegate.target = server;
     delegate.trustAllHosts = trustAllHosts;
-    delegate.filePlugin = [self.commandDelegate getCommandInstance:@"File"];
+    delegate.filePlugin = (CDVFile *)[self.commandDelegate 
getCommandInstance:@"File"];
     delegate.chunkedMode = chunkedMode;
 
     return delegate;
@@ -328,7 +328,8 @@ static CFIndex WriteDataToStream(NSData* data, 
CFWriteStreamRef stream)
     if (sourceURL) {
         // Try to get a CDVFileSystem which will handle this file.
         // This requires talking to the current CDVFile plugin.
-        fs = [[self.commandDelegate getCommandInstance:@"File"] 
filesystemForURL:sourceURL];
+        CDVFile *filePlugin = (CDVFile *)[self.commandDelegate 
getCommandInstance:@"File"];
+        fs = [filePlugin filesystemForURL:sourceURL];
     }
     if (fs) {
         __weak CDVFileTransfer* weakSelf = self;
@@ -430,7 +431,8 @@ static CFIndex WriteDataToStream(NSData* data, 
CFWriteStreamRef stream)
          * Check here to see if it looks like the user passed in a raw 
filesystem path. (Perhaps they had the path saved, and were previously using it 
with the old version of File). If so, normalize it by removing empty path 
segments, and check with File to see if any of the installed filesystems will 
handle it. If so, then we will end up with a filesystem url to use for the 
remainder of this operation.
          */
         target = [target stringByReplacingOccurrencesOfString:@"//" 
withString:@"/"];
-        targetURL = [[self.commandDelegate getCommandInstance:@"File"] 
fileSystemURLforLocalPath:target].url;
+        CDVFile *filePlugin = (CDVFile *)[self.commandDelegate 
getCommandInstance:@"File"];
+        targetURL = [filePlugin fileSystemURLforLocalPath:target].url;
     } else {
         targetURL = [NSURL URLWithString:target];
 
@@ -476,7 +478,7 @@ static CFIndex WriteDataToStream(NSData* data, 
CFWriteStreamRef stream)
     delegate.target = [targetURL absoluteString];
     delegate.targetURL = targetURL;
     delegate.trustAllHosts = trustAllHosts;
-    delegate.filePlugin = [self.commandDelegate getCommandInstance:@"File"];
+    delegate.filePlugin = (CDVFile *)[self.commandDelegate 
getCommandInstance:@"File"];
     delegate.backgroundTaskID = [[UIApplication sharedApplication] 
beginBackgroundTaskWithExpirationHandler:^{
         [delegate cancelTransfer:delegate.connection];
     }];


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to