Xcode (NSTask) returns strange values?

Hi,

When i run a build in Xcode it returns strange values as:

rsync: link_stat “/Users/cadat/Library/Developer/Xcode/DerivedData/SynC2USBV2-dtbucmcsoxrvcobcwbzbeamqpalr/Build/Products/Debug/ --progress” failed: No such file or directory (2)

when it should return:

building file list …

74 files to consider

./

AUTHORS
158 100% 0.00kB/s 0:00:00 (xfer#1, to-check=72/74)

I can find no obvious reason for this to happen.

Thanks in advance,

Does such a folder exist on your Mac?

Sorry for the late reply. i couldn’t check if the path worked.
Yes, this folder does exist.
What i don’t understand is that Xcode just changes a variable to a path that i have put absolutely not reference to in my script?

I’m afraid I don’t follow. Can you post the problematic code?

wel, its a long code and you probably don’t want it all. i hope it has to do with these subroutines:


on onsync_(sender)
		debugmode_("Start Syncing to " & sourcefolder)
		debugmode_("Opening and preparing panel")
        
		Loadsheet_()
        ProgressBar's startAnimation_(me)
        
       
        set sourcefolderm to SaR(sourcePath, ":", "/")
        set destfolderm to SaR(destfolder, ":", "/")
        
        set rsyncpathsource to ("/volumes/" & sourcefolderm as text)
        set rsyncpathdest to ("/volumes/" & destfolderm as text)
        set rsstandardsettings to (" --progress")
        set arraylist to {ref rssettings, ref rsstandardsettings, ref rsyncpathsource, ref rsyncpathdest}
        log arraylist
		set currentTask to NSTask's alloc's init()
		set outputpipe to NSPipe's pipe()
		currentTask's setStandardOutput_(outputpipe)
		currentTask's setStandardError_(outputpipe)
		currentTask's setLaunchPath_("/usr/bin/rsync")
		currentTask's setArguments_(arraylist)
		
        
		NSNotificationCenter's defaultCenter()'s addObserver_selector_name_object_(me, "readPipe:", "NSFileHandleReadCompletionNotification", currentTask's standardOutput()'s fileHandleForReading())
        NSNotificationCenter's defaultCenter()'s addObserver_selector_name_object_(me, "endPipe:", "NSTaskDidTerminateNotification", currentTask)
		currentTask's standardOutput()'s fileHandleForReading()'s readInBackgroundAndNotify()
		
        currentTask's |launch|()
        
	end onsync_

And then there is the pipe subroutine:

on readPipe_(aNotification)
        debugmode_("Reading pipe notification")
		set dataString to aNotification's userInfo's objectForKey_("NSFileHandleNotificationDataItem")
		set newstring to ((NSString's alloc()'s initWithData_encoding_(dataString, current application's NSUTF8StringEncoding)))
        debugmode_(newstring as text)
        set olddelims to AppleScript's text item delimiters
        if (newstring as text) is not equal to "building file list ... " then
                set AppleScript's text item delimiters to " "
                set newstring1 to text item 2 of (newstring as text)
                set newstring1 to newstring1 and text item 3 of (newstring as text)
                set newstring1 to newstring1 and text item 4 of (newstring as text)
                display dialog newstring1 as text
                end
             
            set AppleScript's text item delimiters to "to-check="
            set delimited to text item 2 of (newstring as text)
            set AppleScript's text item delimiters to "/"
            set current to text item 1 of delimited
            set total to text item 2 of delimited
            set AppleScript's text item delimiters to ")"
            set total to text item 1 of total
            set percentage to current / total as text
            set percentageBy100 to percentage * 100 as text
            set relativePercentage to character 1 of (percentageBy100 as text)
            set relativePercentage to relativePercentage & character 2 of (percentageBy100 as text)
            log "RELATIVEPERCENTAGE " & relativePercentage
        
            
            set AppleScript's text item delimiters to olddelims
         
		StatusBarText's setStringValue_(newstring as text)

		aNotification's object()'s readInBackgroundAndNotify()
	end readPipe_

I am still working on replacing the applescript’s text item delimiters with componentsSeparatedByString_(“”)
but this should take me anymore than an hour or so…

Don’t convert colon-delimited paths like that; use “POSIX path of”. You also don’t need the “ref” stuff in your array. And you shouldn’t have the space before the --progress parameter. I can’t see what rsstandardsettings is.

Noticed exactly the same things…

For the POSIX path of, I’m sure i read about this somewhere but i forgot, so i just replaced the : with / because terminal would read it as text anyway. and the execution of rsync works, just not the readPipe: subroutine.

I couldn’t get the variable arraylist to work without the ref (or a reference to) i don’t remember what error was returned to me and i can’t remove the ref now because I’m not I’m my macbook.

ill try and remove the space, see if it makes difference

Thanks!

No, I think you have it the wrong way around – that return value suggests a problem with the rsync command. It’s the sort of thing extra spaces or incorrect paths cause.

As you can see in the part where we assign the pipes, that error will be send to the same pipe as standard outputs. This means that when an error occurs the readPipe: handler still is called. So that makes it seems like it is all working to you maybe. The arguments are not send through a CLI with NSTask, but directly to the process (that’s the biggest difference between CLI and NSTask). That means when you have white spaces in your argument, it will be send that way to the process. The advantage if that is that you don’t need to use quoted form with NSTasks or that the string/arguments are altered.