Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12740] iOS: iTunes script intermittently fails to initiate sync

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-17T17:54:22.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API, Release 3.1.3, Release 3.2.0
ComponentsTooling
Labelsqe-3.1.3, qe-sdk3.0.2, tooling
ReporterOlga Romero
AssigneeMatt Langston
Created2013-02-14T21:23:39.000+0000
Updated2013-11-25T20:55:26.000+0000

Description

Description: Having 2 devices plugged in and trying to install app on device intermittently fails to initiate iTunes. However it does auto sync app on one of devices. Disconnecting one of the devices and trying to install app on it works fine. Actual result in 3.0.0.GA [WARN] :   An error occurred running the iOS Package Application tool (it does initiate iTunes and sync works fine, this message appears every time) Actual result in 3.0.2: [INFO] :   Installing application into iTunes [INFO] :   Initiating iTunes sync [ERROR] :  Failed to initiate iTunes sync [ERROR] :  /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.0.2.v20130207164659/iphone/itunes_sync.scpt: execution error: Can’t make name of *4* into type Unicode text. (-1700) [ERROR] :   [ERROR] :  Project failed to build after 20s 423ms Tested with: Titanium Studio, build: 3.0.2.201302141201 Titanium SDK, build: 3.0.2.v20130207164659 iTunes 11.0.1 One device and One cord plugged in to Mac 10.8.2 Mountain Lion Actual result: [INFO] :   Initiating iTunes sync [ERROR] :  Failed to initiate iTunes sync [ERROR] :  /Users/oromero/Library/Application Support/Titanium/mobilesdk/osx/3.0.2.v20130207164659/iphone/itunes_sync.scpt: execution error: Can’t make name of *3* into type Unicode text. (-1700) [ERROR] :   [ERROR] :  Project failed to build after 17s 73ms I noticed iTunes sync usually fails after importing projects.

Comments

  1. Eric Merriman 2013-08-20

    Occurs with 3.1.2 Studio and SDK 3.1.2.GA
       [ERROR] :  Failed to initiate iTunes sync
       [ERROR] :  /Users/emerriman/Library/Application Support/Titanium/mobilesdk/osx/3.1.2.GA/iphone/itunes_sync.scpt: execution error: Can’t make name of 4 into type Unicode text. (-1700)
       [ERROR] :  
       [ERROR] :  Project failed to build after 1m 25s 638ms
       
  2. Eric Merriman 2013-08-23

    Try this:
       tell application "iTunes"
       	repeat with n in sources	
       		if (kind of n is iPod) then
       			try
       				update n
       			on error errorStr number errorNumber
       				log "The device " & name of source n & " was unable to sync (" & errorStr & ":" & errorNumber & ")"
       			end try
       		end if
       	end repeat
       end tell
       
  3. Eric Merriman 2013-08-23

    Part of the problem was the existing line:
       on error errorStr number errorNumber
       				log "The device " & name of n & " was unable to sync (" & errorStr & ":" & errorNumber & ")"
       
    It should be "name of source n". Fixing this generates another error, which looks like this for our device "aquaman":
       (*The device aquaman was unable to sync (iTunes got an error: 5 doesn’t understand the update message.:-1708)*)
       
    Changing the lines:
       repeat with n from 1 to the count of sources
       		if the kind of source n is iPod then
       
    to this:
       repeat with n in sources	
       		if (kind of n is iPod) then
       
    Sorts out that problem.
  4. Olga Romero 2013-08-30

    Another sample:
       if not checkItunesIsActive() then return
       tell application "iTunes"
       	try
       		set theSources to (every source whose kind is iPod)
       		repeat with src in theSources
       			try
       				with timeout of 600 seconds
       					tell src to update
       				end timeout
       			on error errorStr number errorNumber
       				log "The device " & name of n & " was unable to sync (" & errorStr & ":" & errorNumber & ")"
       			end try
       		end repeat
       	end try
       end tell
       to checkItunesIsActive()
       	tell application id "sevs" to return (exists (some process whose name is "iTunes"))
       end checkItunesIsActive
       
  5. Eric Merriman 2013-08-30

    After some additional testing the 2 sample scripts above will fail with an error when Itunes is already syncing. I have not accounted for this. The error returned is -1708.
  6. Matt Langston 2013-08-30

    PR: https://github.com/appcelerator/titanium_mobile/pull/4629
  7. Matt Langston 2013-08-30

    Backport PR: https://github.com/appcelerator/titanium_mobile/pull/4630
  8. Matt Langston 2013-08-30

    This was the proper fix for itunes_sync.scpt, which I paste below since the actual file that is checked into the repo is a binary file AppleScript file.
       
       tell application "iTunes"
       	repeat with iTunesSource in sources
       		if (kind of iTunesSource is iPod) then
       			try
       				update iTunesSource
       			on error errorStr number errorNumber
       				log "The device " & name of iTunesSource & " was unable to sync (" & errorStr & ":" & errorNumber & ")"
       			end try
       		end if
       	end repeat
       end tell
       
  9. Ingo Muschenetz 2013-09-07

    This _is_ merged to 3.1.3, but still _remains to be merged_ for 3.2.0 (master)
  10. Eric Merriman 2013-09-09

    To test the fix: 1) Connect 3 iOS devices 2) Build with 3.1.2.GA to see fail case. (this ticket) 3) Build with 3.1.3.v2013090714460 or later - pass if no error presented on sync step 4) If using iTunes 11, set app to install and sync all devices 5) Make a change to project in studio - re-build for device 6) After sync, ensure all devices see the update you made 7) Additional test - try to time a manual sync via iTunes to occur when the build sync starts (potential error generation) 8) Additional test - launch the script via applescript editor, set bottom tab to "events" and run script. Ad-hoc test
  11. Anshu Mittal 2013-09-09

    I Executed above 1-7 steps successfully with no intermittent fail or crash. But could not execute the 8th step.
  12. Eric Merriman 2013-09-17

    8th Step verified. Closing as fixed.
  13. Ingo Muschenetz 2013-10-08

    Note that this has still not been merged to master.
  14. Wilson Luu 2013-10-21

    As Ingo stated, this still occurs on: Titanium Studio, build: 3.2.0.201310181940 OS: Mac OS X Mountain Lion (10.8.5) SDK build: 3.2.0.v20131018154951 Ti CLI: 3.2.0 (72f7426b4ee6c2d2883c666d5b7e03906a16012f)
  15. Matt Langston 2013-10-22

    [~emerriman], can you try again testing and merging this with master/3.2.0 please? You couldn't do this before because master was broken, but I don't think this is still the case.
  16. Wilson Luu 2013-10-23

    [~mlangston], I still see this issue on the latest master/3.2.0 Tested on: Titanium Studio, build: 3.2.0.201310230548 OS: Mac OS X Mountain Lion (10.8.5) SDK build: 3.2.0.v20131023140842 Ti CLI: 3.2.0 (72f7426b4ee6c2d2883c666d5b7e03906a16012f)
  17. Ingo Muschenetz 2013-10-23

    It's not merged. It still has a merge-3.2.0 label on it.
  18. Wilson Luu 2013-11-22

    Was able to still reproduce the issue on: Titanium Studio, build: 3.2.0.201311211626 SDK build: 3.2.0.v20131121163252 CLI: 3.2.0-alpha Alloy: 1.3.0 (it://github.com/appcelerator/alloy.git#1_3_X) Xcode: 5.0.2 Device: ipad 2 (7.0.2), iphone 5 (6.1.3), iphone 5 (7.0.2) Note: If using 3.2.0 SDK, you will get a different error message, but the bug is still the same: [TRACE] : ** BUILD SUCCEEDED ** [INFO] : Installing application into iTunes [INFO] : Initiating iTunes sync [ERROR] : Project failed to build after 15s 565ms And the ~/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/iphone/itunes_sync.scpt will fix this issue.
  19. Wilson Luu 2013-11-25

    Closing ticket as fixed. Verified iTunes script does not intermittently fail to initiate sync. Also, verified the same script from ~/Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/iphone/itunes_sync.scpt is in the 3.2.0 SDK. Tested on: Titanium Studio, build: 3.2.0.201311221859 SDK build: 3.2.0.v20131122172908 CLI: 3.2.0-alpha Alloy: 1.3.0-alpha6 Xcode: 5.0.2 Device: ipad 3 (7.0.2), iphone 5 (6.1.3), iphone 5 (7.0.2)

JSON Source