GeometryReader in SwiftUI is a container view that provides access to its size and position within the parent view. Although you won’t always need to use it, it’s available when you’d like to know more about the views you’re working with. This is for you if you need to work more precisely, particularly with different screen sizes.
[Read more…]Xcode 16 beta Launched
It’s WWDC24 this week and with it, lots of new updates to download and become familiar with.
Xcode 16 has launched in beta and can be downloaded from the Apple Developer website. As with previous Xcode updates, this latest version adds even more features to help you build apps. These include the following:
Predictive Code Completion
A new coding model has been added that is trained for Swift and Apple SDKs. It runs locally on your Mac, allowing it to work while you are offline. As you begin writing code, it predicts what you need and pre-populates the rest of the line, which can then be used and accepted. This dramatically speeds up coding by allowing you to offload some of your work.
[Read more…]How to Use Swift Charts with SwiftUI in Your iPhone App
Many apps use charts to represent data to the user. This is especially so for apps such as weight tracking, step counting, and anything else that is HealthKit related. Thankfully, Apple has created the Swift Charts framework to help you build these charts.
In today’s tutorial, we’ll look at extracting step count data from HealthKit and representing that in a chart within a SwiftUI application. We will have two charts, the first being a bar chart showing today’s step counts broken into hours and the second showing daily step counts for the last thirty days.
This tutorial will cover fetching information from HealthKit, processing that data and formatting it to make it easier to pass values to the charts framework. It will cover creating the views and the prompt needed to grant the necessary permissions.
[Read more…]Building a SwiftUI Note-Taking App with ChatGPT Integration for iPhone – Tutorial
In a recent tutorial, I took you through the basics of creating a chat app where you could ask a question and then receive an answer using the ChatGPT from OpenAI. That tutorial covered basic HTTP post requests and responses and included the structs that allowed a request to be encoded and a response to be decoded. It also had a simple view that allowed you to enter your API key from OpenAI and a TextField to ask a question.
In this tutorial, we will take this in the direction of a note-taking app for meetings with ChatGPT integration. The app will allow you to take notes and then have ChatGPT to do several things, such as extract action points, summarise lengthy notes, extract dates and times and put them into a bullet list. With AI, there are many options. I’ve only touched on a tiny amount of them here.
[Read more…]Integrating DALL-E to Generate Images in Your SwiftUI iPhone App
In the last tutorial, we looked at ChatGPT chat conversations and added a simple user interface to a SwiftUI app. Today we will look at integrating DALL-E into your SwiftUI app, using the image generations endpoint that allows you to provide a prompt and generate one to ten images. The app will be similar to what was created yesterday. The difference is that instead of receiving an answer in text form, we’ll receive it as a URL that can then be processed to display on the view.
[Read more…]ChatGPT Integration: Building a SwiftUI Chatbot for Your iPhone App
In the past year, ChatGPT has brought AI to the limelight. ChatGPT 3 was the model in use when I first heard of it last year. Just like it did with me, It has captured the interest of many people and businesses.
ChatGPT can be used for many things, such as finding answers to daily questions, solving maths problems, writing blog posts, and writing code, to name a few.
In this tutorial, we’ll connect a SwiftUI app to OpenAI’s ChatGPT API to provide a chatbot for your mobile app. The tutorial will briefly cover how to create a simple user interface and connect to OpenAI’s API to receive answers to questions you ask within the app.
The application here is just a chatbot, but you can use what you learn here to add value to any kind of app such as a note-taking app where a user can write some notes and then use AI to either add, summarise or correct what has been written.
OpenAI’s API is very similar to many other APIs on the internet in that you create an HTTP request, such as a POST request, add the bearer to the header, add items to the body, and then post it. The API then passes back a result that contains the answer you need.
[Read more…]Learning C# and .NET
I started DevFright in 2013. I was new to programming at that time. I had done a class in the mid-90s learning Pascal, but that only scratched the surface. I dabbled a bit with PHP on some WordPress installs that I had, but it wasn’t until 2012 that I started being more serious about programming. I began with iTunes-U content from Stanford, and in 2013 I started writing about what I was learning.
I created DevFright to write about what I was learning about creating iPhone apps. I had been learning Objective-C and felt I could share my learning.
Most of my work until late 2019 was with Objective-C and Swift. That year, I became more involved with PHP, using a custom framework to create an API. Shortly after that, I worked in Lumen and then switched to Laravel.
Things changed again when I began working in Python with a few friends so that we could learn the language together. We built the beginnings of a chess game and tried to engineer it so that the classes and relationships between them made sense. It was a great few months spending a few hours together each week.
In 2021 I began moving more to using Python with some JS and TS as well. I helped build an API that used Python and FastAPI. The team changed, and suddenly we discussed building something more reliable, perhaps using native code to create a separate iPhone and Android app rather than a PWA that was causing grief.
We decided to switch to C# and .NET using MAUI, which was still in beta then.
Surprisingly to me, I like C#. It has been great to work with. I am still very new at using it
[Read more…]Learning SwiftUI
I have written a handful of tutorials about SwiftUI, but since it was announced in 2019, I’ve done very little with it. At the end of 2019, I stepped away from iOS dev work and, for several months, worked with PHP, a custom framework, and the Laravel and Lumen frameworks to do some backend work.
In late 2020, I took a break due to an injury. In 2021, I did some work in JavaScript, VueJS, and Python and then moved on to C# in 2022. Mobile dev is where I prefer to work. Although I do some mobile dev work in .NET MAUI, it isn’t quite the same experience as a full native experience, in my opinion, although MAUI is good. I might write about that over on my dev site.
[Read more…]How to add a Map to a SwiftUI App
Many iPhone apps use maps to display helpful information to the user, often showing the current location. Uses include maps for navigation, finding nearby places, adding location to notes, reminders, and so on. This short tutorial will teach us two ways to add a map to an app.
Using MapKit
The MapKit framework makes adding a map to your app simple. You can first begin by importing MapKit into your view as follows:
import MapKit
How to Use Local Notifications
There are two categories of notifications on iOS devices. One type is a push notification sent by a server, and the other is a local notification scheduled on-device that appears at a particular time or location.
This tutorial focuses on local notifications. An example of a local notification can be seen in your calendar. You add an appointment, set it to remind you 15 minutes before, and 15 minutes before the meeting begins, you see a notification on your lock screen. Let’s take a look at how these work.
[Read more…]- 1
- 2
- 3
- …
- 12
- Next Page »