Codea Runtime: build fails with 'could not read CFBundleIdentifier'

Hello all,

Codea newbie here: loving it so far.

I tried to build a standalone app using the Runtime Library, and I followed the instructions in README.md precisely. However the build fails with the following error message:

error: could not read CFBundleIdentifier from Info.plist (null)
Command builtin-productPackagingUtility failed with exit code 1

I changed CFBundleIdentifier in CodeaTemplate/Info.plist to com.karanvasudeva.${PRODUCT_NAME:rfc1034identifier} and the Summary tab in CodeaTemplate.xcodeproj correctly reflects Bundle Identifier as com.karanvasudeva.Test where ‘Test’ is the default Product Name.

I’m not sure what I’m doing wrong. Is the incorrect Info.plist being picked up by Xcode, or have I not set up Bundle ID correctly?

Thanks
Karan

Could be an old Xcode version. Which version of Xcode are you using?

Xcode Version 4.3.2 (4E2002) on OS X 10.7.3.

OK, I fixed it. This is probably an Xcode bug.

I renamed CodeaTemplate/Info.plist to CodeaTemplate/CodeaTemplate-Info.plist and in .xcodeproj → Targets → ‘Test’ → Build Settings → Packaging changed the ‘Info.plist File’ value to ‘CodeaTemplate/CodeaTemplate-Info.plist’. Then I cleaned the project, restarted Xcode and rebuilt, but I still got the same error, i.e. could not read CFBundleIdentifier from Info.plist, which indicates that Xcode is still looking in a file called Info.plist, not CodeaTemplate-Info.plist.

On a hunch I added “CFBundleIdentifier
com.karanvasudeva.${PRODUCT_NAME:rfc1034identifier}” to CodeaTemplate/Project.codea/Info.plist, and the build went through successfully. It might mean something that this Info.plist appears before CodeaTemplate-Info.plist in the Xcode Project navigator view, so Xcode is looking for CFBundleIdentifier there.

Now that I can run my Codea project as a standalone app, there is a more interesting issue: it appears that the setup() and draw() functions are not being called. I get the following console output in Xcode while running the app:

2012-04-26 07:35:29.219 Test[2105:707] draw is not a Lua function

2012-04-26 07:35:29.235 Test[2105:707] draw is not a Lua function

2012-04-26 07:35:29.251 Test[2105:707] draw is not a Lua function
… etc.

Egad, it turns out I had failed to select ‘Create folder references for any added folders’ as outlined in README.md while adding my .codea folder.

Doing that again turns the Project.codea icon in Project Navigator from yellow to blue and fixes both the build issue and the setup()/draw()-not-found issue.

How embarrassing. Sorry for wasting your time.

And this is a classic example of why I prefer writing code in Codea to trying to use the Apple tools, language aside. It shouldn’t be that easy to make one teensy mistake that blows everything up.

@karanvasudeva yes the Project.codea is important to add by folder reference. This ensures that Xcode builds the actual folder inside the .app package (and doesn’t just dump the files in as a flat file system). However Xcode is pretty stupid about folder references, it won’t copy new changes to the folder reference unless you clean your build or “touch” the folder reference.

We will probably add a shell script to touch the Project.codea folder on build to ensure this happens, but for now you will have to do it manually.