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 15 in General Posts: 1,605

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: 1,605
    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,202

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

  • Posts: 1,605
    @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,202

    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: 1,605
    @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 19 Posts: 1,605

    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: 471

    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 19 Posts: 1,605

    @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: 1,605

    @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,202

    @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 21 Posts: 471

    @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: 471

    @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,202

    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: 471

    @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,202

    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 22 Posts: 471

    @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,202
    Yes you need a free dev account for that. Sorry about the out of date runtime. I'll be updating it soon
  • Posts: 471

    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. 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,202

    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

  • Posts: 471

    Using it was easy to generate the all icons and for free.

  • Posts: 471

    @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,202

    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: 4

    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.

Sign In or Register to comment.