It looks like you're new here. If you want to get involved, click one of these buttons!
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?
Comments
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.
https://codewithchris.com/xcode-tutorial/
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?
Exported code includes the latest App Store release (3.0.1) I'll need to update this for 3.1
Can you just use Xcode locally on your Mac for your Pads?
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
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.
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!!
@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.
@piinthesky - link to docs showing how to select a scheme (for scheme read device - iPad etc).
Xcode docs on scheme
@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
@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.
@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?
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
@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.
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 (atom.io) — you can just drag the whole .codea folder onto Atom and it will open it as a project
@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.
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.
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
Using https://appicon.co/ 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.
@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?
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
Posted a related question (https://codea.io/talk/discussion/10449/incompatibility-xcode-11-4-swift-5-1-3-cannot-be-imported-by-the-swift-5-2-compiler) 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.
i came across a nice summary of the app submission process here:
https://codewithchris.com/submit-your-app-to-the-app-store/
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!
@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?
@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.
@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
@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.
I am sure there are a few other forum members who would be interested in this.
@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 https://developer.apple.com, 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?
@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:
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.
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 aShadeAddon
with lots of native code bridging the Codea engine to additional functionality and UI that Shade needsRegarding 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?
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
@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?
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"?@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.
@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.
@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.
@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.
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.