/r/iOSProgramming

Photograph via snooOG

A subreddit to discuss, share articles, code samples, open source projects and anything else related to iOS, macOS, watchOS, tvOS, or visionOS development.

FAQ

About

There is an extensive FAQ for beginners. Please browse it first before asking questions that are answered there.

If you are looking to get started (iOS programming in general or some specific area), here are more relevant links for you:

  • Swift or Objective-C? if you don't know which language to choose. (New posts asking this will be removed)

Related Subreddits

Related Links

There's too many to list them all, however here's a convenient link to all programming guides at apple.com

Take note that this list is live and based on most frequent questions in posts will be updated with "quicklinks".

/r/iOSProgramming

146,480 Subscribers

1

Incredibly simple question, too specific for the discord.

Hi, simply need to find the url scheme to open the album current playing/most recently played on Apple Music. Much appreciated!

0 Comments
2024/10/04
09:25 UTC

0

How to add a simple ASTextNode(UILabel) to a ASDKViewController(UIViewController)?

I am learning AsyncDisplayKit(Texture), and I am learning how to layout things, I want to add a simple ASTexNode(UILabel) to ASDKViewController(UIViewController) and the text node is showing up please find the code below.

This is basic TextVC class

import AsyncDisplayKit

class TextVC: ASDKViewController<BaseNode> {
    
    let textNode = ASTextNode()
    
    override init() {
        super.init(node: BaseNode())
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        textNode.automaticallyManagesSubnodes = true
        textNode.backgroundColor = UIColor.red
        textNode.maximumNumberOfLines = 1
        textNode.attributedText = NSAttributedString(string: "This is a sample string",
                                                     attributes: [NSAttributedString.Key.foregroundColor: UIColor.white,
                                                                  NSAttributedString.Key.font: UIFont.systemFont(ofSize: 25)])
        node.addSubnode(textNode)
        node.layoutSpecBlock = { [unowned self] node, constrainedSize in
            return ASWrapperLayoutSpec(layoutElement: textNode)
        }
//        node.layoutSpecBlock = { [unowned self] node, constrainedSize in
//            return ASCenterLayoutSpec(centeringOptions: ASCenterLayoutSpecCenteringOptions.XY, sizingOptions: ASCenterLayoutSpecSizingOptions.minimumXY, child: textNode)
//        }
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        print(String(describing: TextVC.self) + " viewWillAppear called")
    }
    
}

This is BaseNode

import AsyncDisplayKit

class BaseNode: ASDisplayNode {
    
    override init() {
        super.init()
        self.automaticallyManagesSubnodes = true
        self.view.backgroundColor = UIColor.red
    }
    
}
6 Comments
2024/10/04
09:10 UTC

1

App Attest Issues in iOS: Some Users Facing 401 Errors

Hi guys!

I'm a backend software engineer, and we develop a mobile game. Our tech stack includes C#, Unity, TypeScript, Node.js, and Firebase.

We recently started using Firebase App Check to protect our Firebase Cloud Functions. Specifically, we’re using Google Play Integrity for Android and App Attest for iOS. We enforced App Check for Android, and it works great. However, after enabling App Check for iOS, it works for some users, while other legitimate users are getting 401 errors in Cloud Functions logs. Honestly, we don’t know why this is happening — it might be due to App Attest limits.

We reached out to Apple Tech Support, and they responded with the following:

To avoid encountering attestKey(_:clientDataHash:completionHandler:) rate limits, we generally recommend that your apps call this method fewer than 100 request per second across all installations of your apps. The rate limit threshold may fluctuate dynamically to protect Apple’s certificate signing infrastructure. Be prepared to handle these errors and to have a mechanism to pull back on requests from your apps if this occurs.

The challenge is that we don’t write native iOS code (we use C# for our client code). How can we see logs of our iOS game and be certain that these issues are related to App Attest limits?

0 Comments
2024/10/04
07:27 UTC

2

Is it safe to perform this? "Remove Embed Swift Standard Libraries Setting"

Suddenly Xcode presented this to me as "Update to recommended settings".
Is it safe to accept this?
I posted this here because this is the first time I have experienced not finding a single article on Google regarding such a recommendation.

https://preview.redd.it/lqho3agbdosd1.png?width=1158&format=png&auto=webp&s=2f0cbe08b95338c6ea7be74a89030db651edccec

0 Comments
2024/10/04
05:25 UTC

1

Creating a second organization developer account

I have a few side projects that I'm thinking of publishing on the App Store, but I would like to keep them separate from my business' official developer account. I want the freedom to experiment with more innovative/creative apps without affecting my main business' brand.

While I could create an account under my personal name, I'd like to keep the protection of an LLC. Is there any way to create a second developer account without creating a second LLC? I see that Apple does not accept DBAs, but before I start the filing process for a new company, I thought I'd check if anyone has any other ideas for accomplishing this.

Thank you!

0 Comments
2024/10/04
04:11 UTC

10

iOS Indie Dev/ Freelancing dead in 2024 ? New to this

Hey guys. Software engineer here working in angular mainly.

I really have had a passion for iOS dev. Primarily since I was a kid being inspired by Steve Jobs and I’ve always wanted to develop iPhone apps.

I learned Swift and been doing SwiftUI right now but I realized from Reddit how painful it is for people WITH experience to find iOS dev jobs. My goal honestly was to either become an indie dev and or take on iOS free lancing roles. Are these still active? Just wondering as I do not want to continue if it’s a dying field and people are moving to flutter. I really do enjoy iOS dev but I also don’t want to waste my time

13 Comments
2024/10/04
03:01 UTC

1

ChatGPT in Automations

I created an automation to respond to certain people in a text message with ChatGPT, except for some reason, the automation doesn’t work if my phone is unlocked. Any ideas on how to fix?

3 Comments
2024/10/03
23:20 UTC

0

Need Advice: iOS App Rejection for Saturated Category – Unique App Features

Hey fellow developers,

I recently submitted my app, Moonlit Tarot, to the App Store, which features astrology, horoscopes, and fortune-telling. Unfortunately, it was rejected due to being in a saturated category. While I understand the concern, I believe my app offers some unique features that distinguish it from the standard apps in this space.

  • For example, AI-Powered Personalized Tarot Readings: Our app uses AI to generate highly personalized interpretations based on user input, making each reading unique.

Given these features, I respectfully believe that Moonlit Tarot offers a fresh experience in this space. Has anyone else faced a similar rejection due to saturation? Any tips for handling this or adding more distinctive features?

Thanks for any advice!

9 Comments
2024/10/03
22:57 UTC

1

Learning how Apple builds apps

Does anyone know if it's possible to look under the hood on how Apple developers some of their app.
For example the Phone and Health app.

I know I won't be able to see the exact code, but I'm curious about their architecture as well as when they make network calls vs storing things on local storage. For example, the Health app doesn't have any loading indicators which make the app seem seamless and I am trying to better understand how they achieved that? I tried using Charles Proxy to sniff out the network layer, but didn't see any network requests (maybe it's hidden)

As I started growing my career, the best way for me to learn is through other people's example and experiences.

3 Comments
2024/10/03
22:41 UTC

16

What do you think about the current job market, and do you believe it’s being affected by the impact of AI?

17 Comments
2024/10/03
21:42 UTC

1

Is Bank details required before doing sales in the app

Does Apple require Bank details before adding paid subscription to the app or they only require these details when someone withdraws money from Apple account?

I'm asking this because I want to add paid subscription to the app and don't want to bother with Bank stuff until there are sales. The reason is setting up Bank stuff will be a little hard at my country.

2 Comments
2024/10/03
19:57 UTC

5

Cheapest option for ios programming MacBook

Hi! I want to get into ios development but unfortunately I have windows laptop. My laptop is perfectly fine and it’s a gaming laptop which I paid $2000 for so I am hoping I can get a secondhand MacBook for under $1000. From what I’ve seen, people recommend 16 ram and min 500 gb for ssd but I am not sure about m1/2/3 or cpu requirements. What would be the cheapest option in this case? I’ve been browsing facebook marketplace and cheapest ones are from 2015 or older. Would it be okay to get MacBook from 2015? Or should I get the ones with M1?

17 Comments
2024/10/03
19:27 UTC

3

Is these stats good for a 5 days old app?

Hello everyone,

I launched HydrateMate 5 days ago and here are the stats, what do you guys think?

15 Comments
2024/10/03
18:26 UTC

4

How does iOS app compiles?

Just started my career as iOS developer and I am always curious how does an app actually compiles. There are a lot of jargons like dsyms, object files etc but I really don't understand any of them. Any resources that will help to deep dive will also help

12 Comments
2024/10/03
18:02 UTC

2

Survey: UIKit, SwiftUI, and TCA

Hi everyone!

I’m conducting a quick survey to gather insights into how iOS developers' experience with UIKit and SwiftUI relates to their usage and opinions of The Composable Architecture (TCA).

If you’re an iOS dev with experience in either or both frameworks, I’d love to get your input! The survey has only 5 questions and will take about a minute.

Survey questions:

  1. Which UI framework did you learn first?
  2. How would you describe your experience level with UIKit?
  3. How would you describe your experience level with SwiftUI?
  4. Do you have TCA experience?
  5. What is your opinion of TCA?

👉 Link to Google Forms Survey (Anonymous!)

Thanks in advance for your help!

I’ll be sure to share the results once I’ve collected enough data.

6 Comments
2024/10/03
17:54 UTC

3

RTF Editor in iOS - Component or Library.

Hello,

I am looking for component that supports full RTF (Rich Text Format) for editing RTF Files in my app. Open source is preferable and in absence of the same commercial works too.

I couldn't find any such components. Any ideas?

2 Comments
2024/10/03
17:02 UTC

5

ReviewKit is now open-source and available for Hacktoberfest

I wrote ReviewKit a while back to quickly and easily display my app’s review rating. It got a fair bit of support so, inspired by Hacktoberfest, I opened it up. My hope is that as a community we can work together to round over any rough edges and make a utility that everyone can use. People have already started submitting PRs but there are plenty left. They cover features and bugs in the code, graphic design, localization, and a few others so you don’t even need to know code. If you have any questions I’m happy to answer!

https://github.com/ordinaryindustries/ReviewKit

0 Comments
2024/10/03
15:45 UTC

7

I wrote my first package, would love to hear feedback

Dear r/iOSProgramming ,

I just published my first ever swift package replicating the screenshot and making it adaptable to other apps. I'd love to hear general feedback and please roast my code.

Link to repo is here: https://github.com/FPST-08/NotificationView

Screenshot of the Fitness App asking for notification permission

8 Comments
2024/10/03
14:49 UTC

1

Accessing Image Recognition Metadata in iOS App

Hello!

Is there any way in iOS app to get image recognition information about photos processed by iPhone?

Context: I want to solve an image classification or object recognition problem (in my business case, both solutions will be identical). The algorithms on the iPhone process all my photos for people, objects, etc. Is there any way I can extract this metadata in the app, instead of reprocessing the photos with machine learning models?

Thanks!

0 Comments
2024/10/03
06:19 UTC

2

How to test iOS app subscriptions in a sandbox environment without using an actual credit card or developer account?

Hi all,

I'm currently working on an iOS app that includes subscriptions, and I want to test the in-app subscriptions without using an actual credit card. I’ve read about Apple’s sandbox test environment, but I have a few questions:

  1. Is it possible to test subscriptions in the sandbox environment without needing a developer account?
  2. If I do buy a developer account, can I still test subscriptions without using an actual credit card for purchases (e.g., using sandbox accounts or other methods)?
  3. Any tips or advice for testing in-app purchases/subscriptions in an internal environment would be much appreciated!

Here are the links I found helpful, but I still need some clarification:

Thanks in advance!

1 Comment
2024/10/03
09:04 UTC

1

<5.5" screen display sizes removed from App Store Connect distribution Previews and Screenshots?

Today I went to upload a new version of my app to see 5.5" and smaller screen sizes (as well as iPad 12.9") were removed from the front page preview and screenshots, however they still appear in the media manager. For creating product page optimizations this seems very inconvenient that I need to click view more to use the media manager for every treatment, for every locale, why did they remove 5.5" sizes from the initial list of previews but still require them? Is this happening for anyone else?

https://preview.redd.it/luo8au2m8jsd1.png?width=846&format=png&auto=webp&s=391d66983e51b0c46fd8c4d2cf5d758093f9cfd6

https://preview.redd.it/fhzkur1m8jsd1.png?width=1414&format=png&auto=webp&s=c454b377a7480a238aa963c8518c8bc575d7741d

5 Comments
2024/10/03
12:11 UTC

4

Millisecond Precision Timer in SwiftUI

Hello everyone, for a very long time, I believed Apple had a hidden Timer API with millisecond precision in their Clock app. While I still don’t know the exact implementation, I’m pretty confident it’s something similar to SwiftUI’s TimelineView. Today, I’ll show you how simple it is to build your own precise timer in SwiftUI, just like in the Clock app!

https://youtu.be/9wX7K7OYrIU

0 Comments
2024/10/03
08:32 UTC

0

Hi, I have been given a task for interview assignment, to clone telegram ios source code and add custom features to it, please suggest any guides/tutorials to understand the code.

I have been able to clone and set up environment to run the app on the device, but I cannot understand where the code begins and where it ends... some guidance will be appreciated.

20 Comments
2024/10/03
08:24 UTC

9

Drawing SwiftUI

WWDC’19

If you want to understand how this beauty from WWDC is working "Building Custom Views with SwiftUI" works. I can recommend checking out Paul Hudson's Mini-course “Drawing SwiftUI” (it’s free)

Duration: ~2 hours (10 short videos)
Recommended speed: 1x (to enjoy Paul's posh British pronunciation)
My rating: 10/10

It will allow you to understand the CoreGraphic and a small sip of Metal framework to move forward with a more advanced and rich UI. Enjoy!

2 Comments
2024/10/03
08:00 UTC

1

How to resize a StickyNote properly?

I'm currently trying out a small note app. I would like to add a sticky note to the drawing pad. I want to be able to move and resize the sticky note. Moving already works, but changing the size does not work in a controlled way. Can you help me with this? Either it doesn't work at all to change the size, or it changes completely uncontrolled. Here is the code

import SwiftUI
import PencilKit

struct NotesView: View {
    @State private var canvasView = PKCanvasView()
    @State private var toolPicker = PKToolPicker()
    @State private var isToolPickerVisible = false
    @State private var stickyNotes: [StickyNoteView] = [] // Array für die Sticky Notes
    @State private var selectedColor: Color = .yellow // Standardfarbe für Sticky Notes

    var body: some View {
        VStack {
            // Werkzeugleiste mit zusätzlichen Optionen
            HStack {
                Button(action: toggleToolPicker) {
                    Image(systemName: isToolPickerVisible ? "pencil.circle.fill" : "pencil.circle")
                }
                Button(action: createStickyNote) {
                    Image(systemName: "note.text")
                }
                Button(action: addShape) {
                    Image(systemName: "square.on.circle")
                }
                Button(action: addTextField) {
                    Image(systemName: "textformat")
                }
                Button(action: addPhoto) {
                    Image(systemName: "photo")
                }
                Button(action: undoLastAction) {
                    Image(systemName: "arrow.uturn.backward")
                }
                Menu {
                    // Farbauswahl für Sticky Notes
                    Button(action: { selectedColor = .yellow }) {
                        Text("Gelb")
                        Image(systemName: "circle.fill").foregroundColor(.yellow)
                    }
                    Button(action: { selectedColor = .green }) {
                        Text("Grün")
                        Image(systemName: "circle.fill").foregroundColor(.green)
                    }
                    Button(action: { selectedColor = .blue }) {
                        Text("Blau")
                        Image(systemName: "circle.fill").foregroundColor(.blue)
                    }
                    Button(action: { selectedColor = .pink }) {
                        Text("Pink")
                        Image(systemName: "circle.fill").foregroundColor(.pink)
                    }
                } label: {
                    Label("Farbe", systemImage: "paintpalette")
                }
            }

            // Zeichenfläche (Canvas) für das Zeichnen
            ZStack {
                PKCanvasRepresentable(canvasView: $canvasView)
                    .onAppear {
                        toolPicker.setVisible(isToolPickerVisible, forFirstResponder: canvasView)
                        toolPicker.addObserver(canvasView)
                        canvasView.becomeFirstResponder() // Setze die Canvas als First Responder
                    }
                    .onChange(of: isToolPickerVisible) { newValue in
                        toolPicker.setVisible(newValue, forFirstResponder: canvasView)
                        if newValue {
                            canvasView.becomeFirstResponder()
                        }
                    }
                    .gesture(DragGesture(minimumDistance: 0).onChanged { _ in
                        // Werkzeugleiste aktivieren, wenn der Apple Pencil benutzt wird
                        if !isToolPickerVisible {
                            isToolPickerVisible = true
                            toolPicker.setVisible(true, forFirstResponder: canvasView)
                        }
                    })

                // Sticky Note-Ansicht auf der Zeichenfläche hinzufügen
                ForEach(stickyNotes) { stickyNote in
                    stickyNote
                }
            }
        }
        .padding()
    }

    // Sichtbarkeit des Werkzeugpickers umschalten und das Symbol ändern
    func toggleToolPicker() {
        isToolPickerVisible.toggle()
        toolPicker.setVisible(isToolPickerVisible, forFirstResponder: canvasView)
    }

    // Sticky Note erstellen und zur Liste hinzufügen
    func createStickyNote() {
        let newStickyNote = StickyNoteView(color: selectedColor) // Verwende die ausgewählte Farbe
        stickyNotes.append(newStickyNote)
    }

    func addShape() {
        // Funktion, um eine Form hinzuzufügen
    }

    func addTextField() {
        // Funktion, um ein Textfeld hinzuzufügen
    }

    func addPhoto() {
        // Funktion, um ein Foto hinzuzufügen
    }

    func undoLastAction() {
        canvasView.undoManager?.undo()
    }
}

// Canvas-Representable zum Verbinden von UIKit's PKCanvasView mit SwiftUI
struct PKCanvasRepresentable: UIViewRepresentable {
    u/Binding var canvasView: PKCanvasView

    func makeUIView(context: Context) -> PKCanvasView {
        let newCanvasView = PKCanvasView()
        newCanvasView.drawingPolicy = .anyInput
        return newCanvasView
    }

    func updateUIView(_ uiView: PKCanvasView, context: Context) {
        uiView.tool = canvasView.tool
    }
}

import SwiftUI

struct StickyNoteView: View, Identifiable {
    let id = UUID()
    @State private var position: CGSize = .zero // Position der Sticky Note
    @State private var lastPosition: CGSize = .zero // Letzte bekannte Position
    @State private var text: String = "" // Inhalt der Sticky Note
    @State private var size: CGSize = CGSize(width: 200, height: 200) // Größe der Sticky Note
    @State private var isSelected: Bool = false // Ob die Sticky Note ausgewählt ist
    @State private var isResizing: Bool = false // Ob gerade eine Größenänderung durchgeführt wird
    @State private var lastSize: CGSize = CGSize(width: 200, height: 200) // Letzte Größe
    let color: Color

    var body: some View {
        ZStack(alignment: .topLeading) {
            // Sticky Note Hintergrund
            color
                .frame(width: size.width, height: size.height)
                .cornerRadius(10)
                .overlay(
                    RoundedRectangle(cornerRadius: 10)
                        .stroke(isSelected ? Color.blue : Color.clear, lineWidth: 3) // Markierungsrahmen, wenn ausgewählt
                )
                .overlay(
                    // Resize-Griffe nur anzeigen, wenn die Sticky Note ausgewählt ist
                    isSelected ? resizeHandles : nil, alignment: .bottomTrailing
                )

            // Textfeld innerhalb der Sticky Note
            TextField("Notiz", text: $text)
                .padding()
                .background(Color.clear)
                .frame(width: size.width - 20, height: size.height - 20)
                .multilineTextAlignment(.leading)
                .disabled(!isSelected) // Nur bei Auswahl kann geschrieben werden

        }
        .offset(x: position.width, y: position.height) // Position der Sticky Note
        .gesture(
            DragGesture()
                .onChanged { value in
                    // Sticky Note verschieben, wenn nicht resized wird
                    if !isResizing {
                        self.position = CGSize(width: lastPosition.width + value.translation.width,
                                               height: lastPosition.height + value.translation.height)
                    }
                }
                .onEnded { _ in
                    self.lastPosition = self.position
                }
        )
        .onTapGesture {
            // Sticky Note auswählen oder abwählen
            isSelected.toggle()
        }
    }

    // Resize-Griffe an allen Ecken
    var resizeHandles: some View {
        Group {
            resizeHandle(position: .bottomRight) // Rechts unten
            resizeHandle(position: .bottomLeft)  // Links unten
            resizeHandle(position: .topRight)    // Rechts oben
            resizeHandle(position: .topLeft)     // Links oben
        }
    }

    // Einzelne Resize-Griffe basierend auf der Position
    func resizeHandle(position: ResizePosition) -> some View {
        ZStack {
            Circle()
                .fill(Color.blue)
                .frame(width: 15, height: 15)
                .gesture(
                    DragGesture()
                        .onChanged { value in
                            // Basierend auf dem Griffpunkt die Größe und Position anpassen
                            switch position {
                            case .bottomRight:
                                self.size.width = max(100, lastSize.width + value.translation.width)
                                self.size.height = max(100, lastSize.height + value.translation.height)
                            case .bottomLeft:
                                self.size.width = max(100, lastSize.width - value.translation.width)
                                self.size.height = max(100, lastSize.height + value.translation.height)
                                self.position.width = lastPosition.width + value.translation.width
                            case .topRight:
                                self.size.width = max(100, lastSize.width + value.translation.width)
                                self.size.height = max(100, lastSize.height - value.translation.height)
                                self.position.height = lastPosition.height + value.translation.height
                            case .topLeft:
                                self.size.width = max(100, lastSize.width - value.translation.width)
                                self.size.height = max(100, lastSize.height - value.translation.height)
                                self.position = CGSize(width: lastPosition.width + value.translation.width, height: lastPosition.height + value.translation.height)
                            }
                            self.isResizing = true
                        }
                        .onEnded { _ in
                            self.lastSize = self.size
                            self.lastPosition = self.position
                            self.isResizing = false
                        }
                )
        }
        .position(x: (position == .topLeft || position == .bottomLeft) ? 0 : size.width,
                  y: (position == .topLeft || position == .topRight) ? 0 : size.height)
    }
}

// Positionen für die Resize-Griffe
enum ResizePosition {
    case topLeft, topRight, bottomLeft, bottomRight
}
0 Comments
2024/10/03
06:22 UTC

1

Testing consumable in app purchase on TestFlight

How do folks test consumables on TestFlight? I provide a service that costs money and am putting it behind an in app purchase. But am not sure how to limit users on TestFlight from overusing it by purchasing the consumables for free over and over again.

0 Comments
2024/10/03
04:20 UTC

0

Help with missing apps

Hello. I need to present a project with an idea for my future app, but I still haven't come up with it. I read some advices that you can find problems in your life and find solutions (but I don’t have any) Help please!!

0 Comments
2024/10/02
22:35 UTC

8

Do 6.9” app previews get scaled down to 6.3”?

I know they get scaled down to 6.5” but it’s unclear to me if they scale it down further for smaller devices.

2 Comments
2024/10/02
22:52 UTC

Back To Top