I’m writing an iPhone app in Objective-C with Xcode and I have some Lua scripts that run on the device.
I’m having an issue where if I edit a Lua script, save, flick over to Xcode and Build and Run (⌘Y) the latest version of that Lua script is copied into the app bundle but not copied to the device.
The scripts aren’t in the Xcode project, I edit them in Textmate. I have a build step which copies the scripts into the app bundle and touches the files, this is being run fine and the latest script version is in the app bundle when I run the app. The files have all been touched, but for some reason when copying the bundle to the device Xcode decides not to copy the latest.
If I stop the app and then Build and Run (⌘Y) again, the latest version is copied across.
My workaround is to save the Lua file, then in Xcode do a Build (⌘B) and then Build and Run (⌘Y), so build the app twice. This always seems to copy the latest version to the device.
Update:
As many have noted, one solution is to clean the targets and rebuild. You can do this, you could also build twice as I have noted above. This problem is easily reproducible (in my setup it happens every time, regardless of how recently the targets were cleaned). I’m hoping for a more reliable/permanent solution
You should definitely add those files to your Xcode project. You can still edit them in your other editor, but Xcode will include them in your bundle automatically if you add it to the project. If they aren’t getting copied when you build, this is how I resolve it:
Right click on the file in Xcode and choose "Touch" which updates the timedate stamp on the file, so it looks "new".
On the simulator, choose Reset Content and Settings from the File Menu.
In Xcode, do a Build Clean
When you build and run after that it should install the file just fine.
EDIT:
To add external folders to your project that will get included in your bundle and preserve the folder structure intact, all you need to do is:
Click on the project icon at the top of the file list on the left.
Click the Project menu and Add to Project.
Select the folder you want to include and click Add.
Unchecked the Copy checkbox and change "Recursively create groups for any added folders" to "Create Folder References for any added folders".
When the target is built, open up the bundle and your directory structure will exist inside fully intact.