Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Overview of Xcode

edited March 2020 in General Posts: 2,497

All - any volunteers for introducing Xcode to those forum members who would like to try Xcode but struggle to know what to do beyond the basics. A thread in the Wiki would be very useful on this. I am currently looking for videos to cover the basics. I know that there is an entry on the Wiki for exporting from Codea to Xcode and I have installed Xcode and have transferred and edited a file on my Mac. However, that is not knowing what the scope, limitations and requirements are for doing this frequently.

Also, once you have developed your Xcode app - how do you get it back onto the pad?



  • Posts: 2,497
    OK, I'll post a couple of links that I am pursuing at the moment. Video and tut on beginning Xcode - just to get an idea of scope and approach.

    By Chris Ching. Anyone else have links to resources please post. The above are aimed at Swift but will overlap with Codea needs.

    Quick questions - having exported Codea code how much can you modify in Xcode? Does exported code include the latest runtime engine?
  • SimeonSimeon Admin Mod
    Posts: 5,718

    Exported code includes the latest App Store release (3.0.1) I'll need to update this for 3.1

  • Posts: 2,497
    @Simeon - thanks for the info. Another quick question for anyone using Xcode - are you registered as a developer when you download and use Xcode. At what point do you have to pay is that when you place an app on Apple Store?

    Can you just use Xcode locally on your Mac for your Pads?
  • SimeonSimeon Admin Mod
    Posts: 5,718

    You can use Xcode locally to build to your iPad as long as you register a free developer account. Otherwise you can only build to the simulator

  • Posts: 2,497
    @Simeon - thanks for the update - thought something like that may be the situation. Have played with Xcode on occasion but it fealt like I was playing with the tip pof the iceberg.
  • edited March 2020 Posts: 2,497

    All - a little out of date (refers to Xcode 4) but Reefwing (David Such) included a couple of tutorials on submitting projects to Apple (Xcode) and submitting to Apple Store. The details have probably changed but the principles are outlined. Note - you don’t need to download the Codea engine as it is included in the export from Codea. Anyone with more recent experience please post advice/hints and tips - whatever you can.

    Reefwing Tutorial 1

    Reefwing Tutorial 2

    p.s. these and other tutorials are provided in the wiki - link on the forum header.

  • Posts: 645

    Finally took the plunge and am trying to run my exported code in Xcode on Mac...
    (No developer licenses yet)

    I transferred the export file via icloud to my mac
    Clicking on the .xcodeproj it opens in xcode
    I see the assets folder, frameworks folder and a folder with the project name
    In xcode clicking on the run arrow, it compiles and says build succeeded
    (Although with 50 issues, presumably not fatal)
    The simulator eventually pops up and i see the codea environment on an iphone
    Codea gives an error in the output panel...'failed to load shader Materials Skybox'

    I can't see my Codea code anywhere inside the Xcode environment?
    I don't use materials skybox in my code?
    I must be doing something wrong? - Help!!

  • edited March 2020 Posts: 2,497

    @piinthesky - when I last loaded into Xcode you have the option to specify what device you wish to emulate. That includes iPads of different generations so I think the first thing to do is to set your system up to emulate your iPad and iOS version. I think that is the first stage as you may have to modify your code to suit different simulation models eg screen width and screen height.

    p.s. running a different emulator to the source may be the reason you have 50 issues. Also, I always hit issues but I’m no expert in this.

  • Posts: 2,497

    @piinthesky - link to docs showing how to select a scheme (for scheme read device - iPad etc).

    Xcode docs on scheme

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @piinthesky I think Craft needs some of the built in assets and it doesn't know to automatically include them. In the exporter settings if you go to Included Assets and select "Materials", "Hidden Materials", "Blocks" maybe plus whatever other asset packs you use

  • edited March 2020 Posts: 645

    @Simeon as you suggested manually choosing the assets rather than automatically works, but 'Hidden' and 'Blocks' must be included to keep Craft happy. You should fix it that the automatic selection includes those.

    A strange thing...once inside Xcode i cannot 'see' or edit my codea code, even though it is obviously there somewhere as it compiles (although with 50 issues)? I am using Xcode 11.3.1 and Codea 208. I did try a similar exercise a couple of years ago and i know i could edit the codea code then.

    @Bri_G Once inside Xcode you can select the target device.

  • Posts: 645

    @Simeon what is the recommended way to store persistent variables when in the Xcode environment. I have been using readLocalData/saveLocalData should i be using readProjectData/saveProjectData?

  • SimeonSimeon Admin Mod
    Posts: 5,718

    Local data is better than project when using Xcode. Here's the way it works:

    saveGlobalData writes to NSUserDefaults. This is an iOS app's key-value storage on disk for settings and simple data

    saveLocalData writes to NSUserDefaults but under a dictionary that is prefixed with your project's name, so it's kind of writing to the global store but in a way that's accessible only by your project

    saveProjectData creates a .plist file inside your project's folder (Project.codea/) and writes in there. This is not good for Xcode because your project's own path is read-only when installed on device

  • Posts: 645

    @Simeon ok thanks, i'll stick to localData.

    Any ideas why i cannot see the Codea code when inside the Xcode version of the project? I need to be able to modify it to understand why things are not behaving exactly like as when inside Codea.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    If you look in the left side navigation area of Xcode you should see ".codea" which is the folder containing your Codea code. Unfortunately Xcode treats this like a bundle and doesn't let you edit the source inside, but you can right-click on it, choose "Show in Finder" then right click on it in the finder and choose "Show Package Contents". Inside you can edit the Lua files with any text editor

    I like to use Atom ( — you can just drag the whole .codea folder onto Atom and it will open it as a project

  • edited March 2020 Posts: 645

    @Simeon, Installed Atom and that works nicely, once i installed the language-lua add-on package. Successfully managed to run the app on the simulator. I did have to change the asset stuff back to the old scheme-i guess you have not updated the xcode export stuff yet for that.

    In the simulator, it runs incredibly slow on my MacBook Pro 2014. So slow that it is essentially impossible to use- I need a new MacBook!

    Next step, figure out how to get the standalone executable back onto my ipad. Maybe for that i need to get a free developer account.

  • SimeonSimeon Admin Mod
    Posts: 5,718
    Yes you need a free dev account for that. Sorry about the out of date runtime. I'll be updating it soon
  • edited April 2020 Posts: 645

    So got my Apple developer's account.

    I then proceeded to build to the target of my iphone that was connected to my mac via a usb-lightning cable. I got stuck for a long time because codesign was requesting my login keychain password. It would insist i gave the wrong password while i was sure it was correct. After hours of wasted time resetting keychain and passwords, it turned out that pressing 'always allow' rather than 'allow' made it work-arrgghh!

    The next problem i had was that i needed to add a 'privacy-camera usage description' in the info.plist. (control left click on info.plist panel then add row).Once i did that i was able to get the app running independently of Codea on my phone-hurray!

    The app does not have an icon-will try to figure that out tomorrow.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    The icon can be added in the Images.xcassets bundle in Xcode, if you click on it you will see an array of app icon slots where you can drag icons. I'd recommend using Sketch with an app icon template where you can export one design out at all the right sizes

  • edited April 2020 Posts: 645

    Using it was easy to generate the all icons and for free.
    edit: when doing so, do not activate the alpha channel-the icons should not be transparent.

  • Posts: 645

    @Simeon, i stupidly upgraded to ios 13.4, this then obliged me to upgrade to Xcode 11.4. When i build now i get the error message...

    module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2 compiler: /Users/paschalcoyle/Library/Mobile Documents/com~apple~CloudDocs/Documents/codea apps/evtdisplay200323/Frameworks/RuntimeKit.framework/Modules/RuntimeKit.swiftmodule/

    I guess this means you might have to update the export code, or can i force Xcode to use Swift 5.1.3?

  • SimeonSimeon Admin Mod
    Posts: 5,718

    Yes, sorry about this I will work on getting it upgraded.

    I'll make sure you have access to working export in a beta version soon

  • Posts: 5

    Posted a related question ( before @piinthesky pointed me to this one.
    Not sure if that helps, I was able to get the build working and then install and run the app kinda successfully. Kinda because of the assets issue, which I think is simply a matter of sticking to the 'old' way to addressing assets. Details here in the link above.

  • Posts: 645

    i came across a nice summary of the app submission process here:

  • edited April 2020 Posts: 645

    continuing the app submission (mis)adventure....

    Finally, with the latest Codea beta (215) the app does validate in the archive step and I am allowed to distribute the app to the app store connect. Each time so far it has come back within 10 mins with an email saying i should fix something!

    The second time was that i should increase the bundle version, it cannot be the same as the previous submission. In the info.plist there is a bundle version and bundle version short. I increased them both from 1 to 1.1 and that seemed to work.

    The third time it says the upload was successful, but suggesting that next time the "app's Info.plist file should contain a NSLocationWhenInUseUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data."

    Anyway, it was actually successful and now in the app store connect I can see the 1.1 build listed-that's reasonable progress for today!

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @piinthesky yes a lot of those issues are part of the nature of submitting apps to the App Store, it's significantly more complex than you'd expect (especially with all the privacy-related descriptions you must include, entitlements for particular services, and so on)

    Good work getting this far!

    Do you think it's worth keeping Xcode export as a feature in Codea?

  • Posts: 130

    @Simeon @piinthesky I would like to get my apps in the App Store sometime in the future. Is the Xcode export not working? If the answer is “yes” how else would I get my Codea project to Xcode..,my computer is being repaired atm so I cant find out for myself, but would like to plan for a work around if need be.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @Jarc it works now, but using Xcode can be quite in-depth and you will have to do some work in Xcode (not coding, but in terms of how you package your app, icons, code signing, privacy usage descriptions, and so on) in order to deploy to the App Store

  • edited April 2020 Posts: 645

    @Simeon no question you have to keep the xcode export! Isn't it the dream of every amateur coder to be able to create their app and make their fortune on the appstore!! of course they won't, but nevertheless I suspect it is a strong motivation for many people that purchase Codea. Now the export is working, it should not be so painful for others to go for it. I hope my 'sort of blog' on this thread will help people to do so. Also if xcode comes to the ipad-then things will get even easier and people will not need to have a mac at all.

  • Posts: 2,497
    @Simeon - I've been following this thread picking up a few hints. But, at the moment, not feeling confident enough to launch into the Apple store. So, just to builld up some experience - what do you need to do to build a local app on your Mac (designed for iPad) which you can install on your own iPad. Also what are the steps/issues involved.

    I am sure there are a few other forum members who would be interested in this.
  • SimeonSimeon Admin Mod
    Posts: 5,718

    @Bri_G using Codea 3.2.1 you should be able to export the project and build to your device using the latest version of Xcode. You do need to sign up for a free developer account at, you can then add those account credentials to Xcode's preferences which will allow Xcode to manage the code signing requirements for you

    You will not be able to build to the iOS Simulator — I had to remove that capability (hopefully temporarily) as it was preventing builds from being able to be submitted to the App Store.

  • Definitely interested in the XCode export capability. @Simeon, I will soon be experimenting with this process. As of right now, I do not know what is involved. Is the whole process hidden ‘under the hood’ of Codea? Is there (or going forward, could there) be some way to open source the export process, so the community can develop/maintain that capability? Similar to Shade’s export plugins?

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @brianolive as of version 3.2.1 Xcode export works. You end up with a zip file containing a project that can be built and run on your device with the latest version of Xcode — though it cannot be run on the simulator

    The problems with Xcode export I see most often are:

    • Xcode is a large and complex application
    • Handling code signing, creating the correct icons, adding the correct privacy usage descriptions, and setting up your application metadata is not simple
    • Getting through App Review can be tough
  • Is there any way to use Codea or Shade for part of an application? In other words, does what gets exported from Codea always create a brand new XCode project, or is it possible to combine code developed in Codea (for example, maybe the main gameplay) with code written in XCode (to leverage the Apple API, maybe, for example, for some UI elements)?

    How do most game developers do these things for apps? For example, I believe people develop with Unity, and then get that somehow into an app store app, right? Are most serious game developers using other dev environments and then bringing their code into XCode somehow? I’d like to better understand all of this. Maybe this thread/forum isn’t the place for it, but how Codea and Shade could be part of my larger toolset - that definitely interests me.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    Yes it is possible to combine Codea's engine with a UI layer. This is what we did for Shade

    Shade was written in Codea then exported, then the rest was built on top of it

    However that path is quite tough, you have to be fairly competent in C/Objective-C++/Swift. Because you'd need to write bindings for Lua in C in order to expose the native functionality you want to your Lua code

    There's a starting point in the exported Xcode project called CodeaAddon. This is how we built Shade, it lives as a ShadeAddon with lots of native code bridging the Codea engine to additional functionality and UI that Shade needs

  • Regarding Shade, at this point I’d prefer to use it to write shaders for any native iOS applications I develop (whether Codea is part of it or not). Obviously I’ve been enjoying learning Shade, as you’ve seen on Twitter. Will using Shade in a native iOS app require some export plugin? I’m so early in getting oriented with iOS dev, I don’t even know what frameworks/third party applications people use for graphics in games. Should I just start doing my homework on using Metal?

  • SimeonSimeon Admin Mod
    Posts: 5,718

    Depends on the output. Shade can export to Unity and the latest release adds a SceneKit (Metal) exporter. So if you were using either of those two platforms you could use a Shade file

  • Posts: 645

    @Simeon i wanted to add some missing .mtl files to the .codea package on my mac. I tried to do this by opening the package and copying over the .mtl files to the pacakge. But when i run the app on my ipad it does not work.

    Is there a way to add file to the package on the mac without having to go back to Codea and remake the export?

  • SimeonSimeon Admin Mod
    Posts: 5,718

    Opening the .codea package and copying the files in should be the same as adding them inside Codea. Did you right click on it in the Finder and choose "Show Package Contents"?

  • edited May 2020 Posts: 645

    @Simeon yes i did that. Atom sees the new .mtl files next to the .obj, the build works, but codea on the ipad gives error message 'user data nil'. Without the .mtl files it works. Anything else i should do? I wonder if .mtl files are handled correctly in the exported code?

    I can do a new export from scratch, including the dropbox assets (only place where a .mtl file can exist- you should fix that!!!). But it is painful as one has to set up all the icons/info.plist/signing again.

  • Posts: 645

    @Simeon, i redid the xcode export including my dropbox asset folder. Strangely the .mtl files do not seem to be transferred and are missing in the exported dropbox asset folder!? I was able to add the missing .mtl files into the dropbox assets and then it works. I don't why adding the .mtl files into the .codea package did not work.

  • edited May 2020 Posts: 645

    @Simeon do you know if the final app size will be independent of all the other assets in the dropbox folder which are not used by my app?

    Ans: you should remove all unused assets, otherwise they will contribute to the app size.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @piinthesky thanks for adding the answer there. Yes that is correct, I'd recommend against using Dropbox.assets in the exported project (move them into Project assets)

    I really would prefer to encourage using Project assets for almost everything in the future, and instead show the standard document picker so that assets can be selected from Dropbox or other cloud file providers

  • @Bri_G thanks for the Xcode 11 video, which led me to the Code with Chris site. I have 6 apps in the Apple store, but the new push by Apple for updates has made me realize how much I depended on Codea to package everything I needed in earlier updates so I really didn't need to make many changes in Xcode. I'm needing to learn much more about Xcode and programming now if I want to keep updating in the future. @Simeon thanks for all your work on Codea. I have really appreciated that I could export to Xcode. Would it be helpful to see the kinds of yellow and purple error messages people like me see when we build and run our apps in Xcode? I don't get red errors but a number of warnings about things that are deprecated, etc. I think (but am not sure) some of them may be from the packaging that comes from Codea. The current app builds I'm working with are from the app versions I last uploaded from Codea in 2017, I believe. I could send you screen shots of the kinds of warnings I get if you think this might be useful.

  • Posts: 2,497
    @karenm - good to hear you progressed to several apps in the app store. I picked up on Code with Chris and it looks like a good resource. My problem, as ever, is time and far too many distractions

    I am sure a post with screen shots with errors could be useful, with a little annotation/explanation - as an aid on the website.

    Good luck with your apps and future developments.
  • edited August 12 Posts: 2,497

    @Simeon @dave1707 - All, I started this thread hoping to prepare for a trial with Xcode and using the NoNo game I posted earlier as an example. I have used Xcode before - currently installed Version 11.3.1 (11C504) on my Mojave Mac. I didn't encounter many problems then. But - time and systems move on and I exported the NoNo project for use with Xcode, unzipped it and loaded it into Xcode and - nada !!

    Set up a framework for my iPad within Xcode and all I get is the Hello World message.

    Did find one error when I tried to run the project by double clicking NoNo5.xcodeproject icon (see attached image).

    Question - will I be able to run Xcode on my system for Codea exports, what is the error I have encountered and could someone give a blow by blow list of what I need to do to get Xcode running properly?

  • dave1707dave1707 Mod
    Posts: 9,730

    @Bri_G I’ve never used Xcode and probably never will, so I can’t give you any information about it. I’m sure others will.

  • SimeonSimeon Admin Mod
    Posts: 5,718

    @Bri_G if you just click "Add" does that solve the problem?

    You might find it better to re-export the project with Codea as that looks like an old Xcode project

  • Posts: 2,497

    @Simeon - after going back to Xcode reloaded with smaller project to see if I could duplicate, but couldn't - so I can't answer your question. Here are two images attached - first the listed file that I tried to compile - so it shows the file structure after unpacking. Then after trying to follow your instructions in the exported Codea project (after double clicking on fifteen.xcodeproject but the Download Frameworks wasn't there - tried with Product > Scheme > Download Frameworks but no joy. Ran a Build and it said it was succesful but didn't load up the emulator to display the screen. Second image shows some errors from the error screen.

    Remember I am on Xcode V 11.3.1

    Any suggestions?

  • edited August 21 Posts: 2,497


    Just for info - posting a couple of links related to Xcode. Looks like I need to delve into this further to be able to compile an app from Codea. So here we have:
    Xcode Wikipedia
    Xcode Tutorials

    Hope this helps anyone in need - please post alternative links when you find them.


    @Simeon - most of the above tutorials relate to Apples Swift package. It would be useful if you could briefly outline how Codea exports can be incorporated into Xcode and what we need to be aware of when we do.

Sign In or Register to comment.