Friday 20 September 2024

Xcode

 Intro

I have been thinking about potential approaches to, and uses for, executing programs on the iPad.  I previously investigated, briefly, the idea of running a webserver on my iPad. Although the idea seems good, I wasn't convinced a webserver provides a good environment.

The preferred Apple route for iPad programming is actually to develop a cross-platform app using the Apple Xcode IDE running on my macBook and to deploy the completed application to the iPad. Apple are restrictive regarding installing iPad apps and this approach avoids such issues.

Installation

Xcode is a large, free application (6GB or more) which provides a range of languages to write programs for different Apple devices.  It can be installed to a macbook from the app store. I included the IOS components as my target environment is an iPad.

macBook PoC

My preferred programming language is C and I found a simple tutorial to get started with C in Xcode. I created a command line project within Xcode and it gave me a skeleton "Hello World" program as a template.  It is easy to build and run this within the IDE, giving output at the bottom of the screen.

You can then run the C executable generated on a macBook terminal session.


IOS PoC

Next I want an app which will run on the iPad.

I found a couple of youtube tutorials to guide me through the process.  The first one, from CodewithChris , provides a detailed intro to the IDE.

The second from IOS Academy goes into less detail and provides a nice simple emoji display app - I followed this tutorial mainly.

Both the tutorials use the SWIFT interface and the SWIFT programming language, which is very powerful and is preferred for Apple development.
An alternative is to use the older Storyboard interface and SWIFT or Objective-C programming language.

Selecting IOS app in the new Project dialog and choosing the SWIFT interface I was presented with a draft hello world app.  I could build and run this app in the built-in simulator to get an idea of how the app will look on an iPhone/iPad.



I followed the IOS Academy tutorial to create a simple app "EmojiLover".  It allows you to choose from a selection of icons and display on the screen.

The code is explained very well to give some understanding of programming using the Swift language.  SWIFT is a powerful Object Orientated language, and it would take a concerted effort to become fluent in it.

There are some interesting features, notably including Emojis as pictures in the code.  The rest of the code is pretty incomprehensible without understanding the objects making up the User Interface and Program.

The result is very good.  You can see a preview of the code whilst programming and can periodically run the simulator to see how it will look on the device.


IOS Download

The IOS Academy tutorial didn't cover testing the app on an iPad/iPhone so I looked at CodeWithChris.

The first step is to connect the iPad and macBook.  My usb-c  to lightning cable didn't appear to work (no device was seen by macBook) so I  purchased a new usb-c adapter cable which worked a treat.

There were a few compatibility / security issues to resolve before the iPad and macBook were working together:
1) My Xcode environment had to be set for IOS16 to match the iPad
2) I had to enable Developer mode on my iPad
3) In iCloud I had to setup a Personal Account and keychain for the macbook to access the iPad.
4) On the ipad I had to allow user j200@helliwell.org on macbook access to the iPad.

Once macBook and iPad were happily communicating I could tell Xcode to build the app for my iPad and after a slight delay the iPad shows my completed app ๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€


At this stage you can disconnect the iPad from macBook.  An icon is created on the iPad home page which you can use to run the app again.

Unfortunately, unless you have an Apple Developer license ($100pa) Apple only allow you to use it for a week - then you have to reinstall.  This negates the purpose of using Xcode so I wont progress further.๐Ÿ˜ญ




No comments:

Post a Comment