How good is Codea at wrapping Lua to Xcode?

@Zoyt None of the .lua files relating to my app are being exported, from what you said this sounds like a issue with codea, do you think a re-installation would fix it?

@Luatee - I would suggest reinstalling it (backup first!) if reexporting doesn’t work.

Ill back it up and re install and see if that changes anything, its quite odd though how its not exporting the lua files…

@Luatee can you export a really simple project (just make a brand new project and export it) then host the zip file somewhere so I can download it and take a look?

Sure @Simeon, @Zoyt I just tried reinstalling and exporting from Codea with no luck.

@Simeon here: https://www.dropbox.com/s/69zaaxmrj863k1i/TestProject.zip

@Luatee thanks for that. That is very odd, the export process is not working as it should. Has it ever worked for you in the past?

@Simeon I know I wasn’t sure if it was normal to begin with but obviously its not. I can’t be too sure I haven’t previously had a mac this is the first time I’ve come to export a project properly, I had a fiddle with it when it was first released and I didn’t get any crashes/errors but then I didn’t explore the files it created so I couldn’t tell you.

Luatee lent me his project to fix. Here’s how I fixed it:

  1. Take the project directly from the Codea app by using iExplorer. Copy the entire thing onto your computer.
  2. Export the project in Codea.
  3. Replace the folder in the export called “MyProject.codea” with the folder you took from Codea with iExplorer.
  4. Rename the folder (in the project navigator) call “MyProject” to your project name.
  5. Look for any red files in the project navigator (other than “libcodea.a” and “libtoos.a”) and replace it with the corresponding file in the actual file in Finder. Every time you replace a red file, delete the red file. That way, Xcode know only to look for the new one you placed in the project, and not the old one.
  6. Make sure you’ve replaced the file called “MyProject-Prefix.pch” with “[your project name]-Prefix.pch”. If that’s done, go to Project Settings > MyProject (the target) > Build Settings > Apple LLVM 5.0 - Language > Prefix Header and change that to “[your project name]/[your project name]-Prefix.pch”.
  7. In AppDelegate.mm, change MyProject.codea in NSString* projectPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Paint.codea"]; to [you project name].codea
  8. Run it.
    Make sure that [your project name].code and your sprite pack and shader packs folder are all references, not group (has a blue file icon).
    I hope that helps!

@Simeon - I can’t seem to figure it out. saveImage seems to crash the Codea runtime. I’m wondering if this is an issue with my manual configuration of the engine or a Codea issue. Here’s the crash log:

2013-11-12 18:12:32.226 MyProject[93075:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: Documents:DrawIt-slkjsadlfkjasdflkjsdf)'
*** First throw call stack:
(
	0   CoreFoundation                      0x0301a5e4 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x02c398b6 objc_exception_throw + 44
	2   CoreFoundation                      0x030a4578 -[__NSDictionaryM setObject:forKey:] + 888
	3   CoreFoundation                      0x030a923f -[NSMutableDictionary setObject:forKeyedSubscript:] + 47
	4   MyProject                           0x000ab43b -[SpriteManager spriteFileFromString:] + 921
	5   MyProject                           0x000a93f9 readImage + 311
	6   MyProject                           0x000e7a75 luaD_precall + 499
	7   MyProject                           0x000f6dfe luaV_execute + 1563
	8   MyProject                           0x000e7e93 luaD_call + 103
	9   MyProject                           0x000e05d4 f_call + 33
	10  MyProject                           0x000e7628 luaD_rawrunprotected + 59
	11  MyProject                           0x000e80e7 luaD_pcall + 69
	12  MyProject                           0x000e0598 lua_pcall + 110
	13  MyProject                           0x0004d7e3 -[LuaState callSimpleFunction:] + 171
	14  MyProject                           0x00005274 -[RuntimeViewController glkView:drawInRect:] + 700
	15  GLKit                               0x00519c26 -[GLKView _display:] + 303
	16  GLKit                               0x0051a274 -[GLKView display] + 41
	17  GLKit                               0x0051b0ad -[GLKViewController _updateAndDraw] + 661
	18  libobjc.A.dylib                     0x02c4b7d2 -[NSObject performSelector:] + 62
	19  GLKit                               0x0051a5fa -[GLKDisplayLinkMessenger message] + 52
	20  QuartzCore                          0x018a9b8a _ZN2CA7Display15DisplayLinkItem8dispatchEv + 48
	21  QuartzCore                          0x018a9a46 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 310
	22  QuartzCore                          0x018a9f6b _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
	23  CoreFoundation                      0x02fd8bd6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	24  CoreFoundation                      0x02fd85bd __CFRunLoopDoTimer + 1181
	25  CoreFoundation                      0x02fc0628 __CFRunLoopRun + 1816
	26  CoreFoundation                      0x02fbfac3 CFRunLoopRunSpecific + 467
	27  CoreFoundation                      0x02fbf8db CFRunLoopRunInMode + 123
	28  GraphicsServices                    0x039679e2 GSEventRunModal + 192
	29  GraphicsServices                    0x03967809 GSEventRun + 104
	30  UIKit                               0x019a7d3b UIApplicationMain + 1225
	31  MyProject                           0x0000285d main + 141
	32  MyProject                           0x000027c5 start + 53
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

@Zoyt I’ve done some debugging on Xcode and I’ve found the, well what I think is the problem, obviously saving images in Xcode doesn’t work using saveImage and leads to that error. At the top of the draw function you’ll see imgload, I commented these imgload parts (3 parts) at the top of draw function and now it loads up, the problem l think is that using saveImage saves a path of an image to one of the directories but not the image so it’s loading nothing, I’m thinking this is caused by the crash with saveImage. I haven’t been able to locate the save file but if I take out the image loading script for the menu then it runs fine :slight_smile:

I had an issue with saveImage in the runtime before, to fix it what I had to do was delete the documents (or Dropbox) folder that I was trying to save to from the Xcode project. Perhaps Simeon has fixed that particular issue, but it’s worth a try.

Well I’m just doing saveImage(“Documents:blah”) and spriteList(“Documents”) but saveImage causes a crash and then when I look for the documents folder its not there, I have documents.spritepack which is in the project but that stores all needed images so I don’t want to delete that!

The user and all related content has been deleted.

The user and all related content has been deleted.