Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11599] CLI: Using XCode to run app on device won't work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-08-11T21:10:59.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.0.2, Release 3.1.0, 2012 Sprint 23 JS, 2012 Sprint 23, 2013 Sprint 01 JS
ComponentsCLI
Labelscli, device, ios, node, qe-manualtest, xcode
ReporterMartin Guillon
AssigneeChris Barber
Created2012-10-23T15:15:26.000+0000
Updated2014-08-11T21:10:59.000+0000

Description

use xcode a lot to debug on device. I need this especially when i use motion sensors, gps .... Since the integration of node as the build system, i am facing quite a problem, XCode wont correctly launch the app on my device. I think that what s really happening is that the app package is not correctly done an maybe even not correctly copied remove the app from your device clean * build in ti studio * launch the xcode project * run on device Then you get this error
[DEBUG] Loading: /var/mobile/Applications/92E009DA-982E-4BED-8857-525A93A84EE0/Pif Paf.app/app.js, Resource: app_js [ERROR] Error loading path: file://localhost/var/mobile/Applications/92E009DA-982E-4BED-8857-525A93A84EE0/Pif%20Paf.app/app.js, Error Domain=NSCocoaErrorDomain Code=260 "The operation couldn’t be completed. (Cocoa error 260.)" UserInfo=0x522b730 {NSFilePath=/var/mobile/Applications/92E009DA-982E-4BED-8857-525A93A84EE0/Pif Paf.app/app.js, NSUnderlyingError=0x522d850 "The operation couldn’t be completed. No such file or directory"} [ERROR] Script Error = Could not find the file app.js. 

Comments

  1. Chris Barber 2012-11-08

    Master pull request: https://github.com/appcelerator/titanium_mobile/pull/3397 3.0.x pull request: https://github.com/appcelerator/titanium_mobile/pull/3398
  2. Aaron K. Saunders 2013-01-03

    I am still seeing this issue in 3.0, should I be using 3.1?
  3. Jeff Haynie 2013-01-08

    Looks like still happens. Please reverify
  4. Chris Barber 2013-01-08

    @Jeff We're seeing all sorts of interesting issues with building from Xcode for both simulator and device that I'm actively investigating. Not sure exactly what's going on yet.
  5. Eric Merriman 2013-01-09

    @Martin Could you please clarify: When you build in studio, are you building for "run on device" or for simulator?
  6. Aaron K. Saunders 2013-01-09

    @Eric I am seeing this problem when I attempt to build in xcode when I build to device. After further investigation I found that in fact, there is no app_js file present anywhere in the xcode project directory. If I manually copy the files to the appropriate directory everything works fine. I am working now, but later this evening I can rollback my environment to use the CLI and test on both devices and simulator
  7. Eric Merriman 2013-01-09

    Thanks Aaron. Understood. Since in Studio you have no Xcode project until you build, I was wondering if "build to device" or "build to sim" was used within studio prior to launching Xcode. There will be dramatic differences in the contents of the build folder in each case. I am working to reproduce this and we will be considering our options here once we know more. BTW: After speaking with Chris, we think the git commit attached to this bug was not meant to fix this so shouldn't have been attached.
  8. Martin Guillon 2013-01-09

    @Eric: I have been working with this "bug" for a few weeks now. Actually it s not a bug but more of a consequence of the new CLI. This is what happens. Lets say you start with a clean build When you build for simulator from tistudio, cli is actually called twice. The first time the xcode project is built then cli call xcodebuild which calls cli once again with a "--xcode parameter". For the second cli call to know what target to build for etc, the first run creates a buildManifest with those variables. The second run (which i ll call the xcode cli run) reads this manifest to get the correct settings (target, deploytype ... ) After that if you launch the xcode project and try to run, only the xcode cli run is done which means that it will directly read the manifest, without taking in account the target you selected IN XCODE. So in our example: You build and run for the simulator in TiStudio, it works fine. In the meantime a buildManifest is created with target=simulator and deploytype=development Then if you run from xcode you get the same target/deploytype. So why the "no app_js" error? Well simply because when using target=simulator only symlinks are created for the js files, which in the case of device will simply not work. There is a workaround from TiStudio right now, which i am using every day. Simply clean/debug on device. Wait a little (or go to the end). Then if you run xcode project and run on device it will work. Well you'll have to cancel the debug alert but that s it. Why does it work? because the buildManifest contains target=device @chris: Now about the right way to do it. I think the xcode cli run shouldn't rely on a "buildManifest" but on environment variable. So when [called from CLI](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/cli/commands/_build.js#L956) you could set the correct target and deploytype environment variables. Then when cli [wants to set those variables](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/cli/commands/_build.js#L736) there are correctly set. The great thing about this is that when run from xcode directly, those variables wont be set and thus you can add a test and set those variables depending on XCODE ENV.
  9. Chris Barber 2013-01-10

    @Martin, you're dead on. We worked all afternoon/evening to fix this and we think we got it. Feel free to try the following pull request and see if it works now for you. Whichever the result, please let me know. Master pull request: https://github.com/appcelerator/titanium_mobile/pull/3691 3.0.x pull request: https://github.com/appcelerator/titanium_mobile/pull/3692
  10. Martin Guillon 2013-01-10

    @chris: do you think this pull request is gonna be merged soon? I mean can i wait to make a merge from master or do you want me to test it directly from your branch?
  11. Chris Barber 2013-01-10

    @Martin, yeah, I hope it gets merged soon, but I need to track down people that have the problem, get them to try my fix, and sign off on it before it gets merged.
  12. Martin Guillon 2013-01-16

    I am sorry to tell you that the fix did not fix it. Reset your simulator Clean everything run(not debug!) on simulator. It works Now open the built xcode project. Change the simulator target To make sure we build a new app on the simulator You will get the no app.js error
  13. Martin Guillon 2013-01-16

    It s even wrse than that. i Cant even debug anymore in eclipse :s
  14. Martin Guillon 2013-01-16

    It s even wrse than that. i Cant even debug anymore in eclipse :s
  15. Chris Barber 2013-01-16

    @Martin, I'll take a peek at this again. There could be something funky with your setup. I wonder if you're seeing what I was seeing where building from Xcode for different simulator versions would break (app_js not found) due to symlinks not being properly copied. I'm not even sure how to consistently reproduce it or debug it.
  16. Martin Guillon 2013-01-16

    @Chris: yes i am investigating my setup right now. For the app_js yes that s the problem i am seeing when running from xcode. As i mentionned as i choose a different ios sdk simu from xcode, the compilation has to recreate the app dir. What i am seeing is that no sym link is created. Now for the debugger not working anymore, i think it s related to another commit: https://github.com/appcelerator/titanium_mobile/commit/63a8f65fac6a8149ff841f72c300698e2d24524a
  17. Martin Guillon 2013-01-16

  18. Chris Barber 2013-01-17

    @Martin, the debugger isn't working and you think it has to do with the localized splash screen change from last week? How can this be? BTW, I just merged a fix for when the CLI builds iOS Simulator apps in the copy files function where it would copy relative symlinks and now it will recreate the symlink using a full path. That might solve the Simulator issue.
  19. Martin Guillon 2013-01-17

    @Chris: yes i am sure actually. If you look at the commit you'll that the commit suppress debugger.plist from the copy bundle ressources. I fixed it in my branch. Actually i dont really get the modification to the xcode project related to the localised splash screen. Thanks for the pull request. Will try it
  20. Chris Barber 2013-01-17

    @Martin, what commit are you referring to? What did you do to fix it? What file?
  21. Chris Barber 2013-01-17

    @Martin, oooooooooooooh. Nevermind. I totally got you. We'll get this fixed right away.
  22. Martin Guillon 2013-01-17

    @Chris: https://github.com/appcelerator/titanium_mobile/commit/1eb9914025a69ea6c3414bc09240f195173e59de#L1L903 look at this line, it deletes debugger.plist. In my branch i actually reverted all modifications to "iphone/iphone/Titanium.xcodeproj/project.pbxproj". Even the one related to Default.png. I need to fix it as only Default.png needs to be removed from the xcode proj as it will be handled by cli. I cant show my commit as it is drown in a merge :s sorry
  23. Chris Barber 2013-01-17

    Don't worry about the diff. I know what we need to do. We'll have this sorted out tomorrow. I wonder if we need the stylesheet.plist in there too or is that safe to remove.
  24. Martin Guillon 2013-01-17

    i think you need to keep it in the xcode proj. Before my fix there was no stylesheet.plist either
  25. Chris Barber 2013-01-18

    All debugger related discussion in this issue has moved to the appropriate ticket: TIMOB-12313.
  26. Paras Mishra 2013-01-22

    Using Xcode, application executed successfully on iphone 5 with SDK version : 3.1.0.v20130111163212. But for SDK version 3.0.2.v20130121140213, build fails in studio as bug is logged as TIMOB-12358.
  27. Olga Romero 2013-01-22

    Closing as fixed. Tested and verified with: Mac OSX 10.8.2 Mountain Lion Xcode Version 4.5.2 Titanium Studio, build: 3.0.1.201212181159 Titanium SDK, build: 3.0.2.v20130122123204 Titanium SDK, build: 3.1.0.v20130114171802 iPhone 6.0 Simulator iPhone4S 5.0.1
  28. Martin Guillon 2013-01-23

    @Olga: i am sorry but i dont think it is. As explained above i still got errors in certains situations. Though i think i finally fixed it for good in a my branch https://github.com/Akylas/titanium_mobile/commit/ddc24830bf45af87f1742e6d60b749889569211e @chris:If you are ok with it, i ll create a pull request
  29. Chris Barber 2013-01-23

    @Martin, give me this week to review your changes. I'll be working on TIMOB-12348 this week and it's all about getting Titanium to work from Xcode. Seems like a good time to investigate and fix these issues.
  30. Martin Guillon 2013-01-23

    @Chris: no problem, take your time. For my commit(possible pull request) i just want to mention that the idea is to fully separate the build FROM xcode inside a if scope, and not to have a test per variable. Makes this clearer. Also in the build FROM xcode, the buildManifest shouldn't be used at all.
  31. Chris Barber 2013-01-23

    @Martin, agreed, I've been trying to reduce dependency on the buildManifest.json. It has caused more problems than I can count. Appreciate your help on this.
  32. Chris Barber 2013-01-25

    @Martin, the commit you shared is good stuff. I'm doing major surgery to the iOS build command and have updated the code to reflect what you did. This hopefully will work better for you. Thanks!
  33. Martin Guillon 2013-01-25

    @Chris: thanks a lot. Much appreciated. I only have one problem left now. If running on the sim from xcode, symlinks are not created. I remember you telling me about fixing something about this. Was it in the cli node module or in titanium_mobile sources? (dont really want to update node cli module if not really necessary). Thanks
  34. Chris Barber 2013-01-25

    @Martin, I'm working on the iOS build script a bunch this week. Actually, I found a few more issues when building directly from Xcode. i18n files and JSS are never generated during Xcode builds [TIMOB-12348]. Give me a couple days, then you can take a peek at the latest and greatest.
  35. Martin Guillon 2013-01-25

    @chris: take your time. It s gonna be an android week for me anyway ;) Still you had me hooked, wil take a peek for sure ;)
  36. Mike Matan 2013-01-30

    Hi, I've also encountered this problem, it's just as Martin describes it. I do ios module dev and debugging on device is often essential, looking forward to a getting a fix. Confirming steps to reproduce: Create fresh mobile project in titanium studio (build id 3.0.1.201212181159) Execute on iphone simulator Open project in xcode by going to project root directory and executing command line statement: open build/iphone/ProjectName.xcodeproj/ Attempt to run on device from xcode. Get Application Error: "Could not find the file app.js" Console error message: [ERROR] Script Error = Could not find the file app.js.

JSON Source