Friday, November 7, 2025

How to deploy a ipa file from a terminal

  •  brew install ios-deploy
  • ios-deploy --bundle /path/to/your/app.ipa




How to Trust the Developer Certificate on iPhone

1. Install the App

  • Use Xcode, Apple Configurator, or another tool to install the .ipa on your iPhone.

2. Open Settings on iPhone

  • Go to Settings → General → VPN & Device Management (or Profiles & Device Management on older iOS versions).

3. Find the Developer Profile

  • Under Enterprise App, you’ll see the developer name or organization that signed the app.

4. Trust the Developer

  • Tap the developer name.
  • Tap Trust “[Developer Name]”.
  • Confirm by tapping Trust again.

Now the app should launch without the “Untrusted Enterprise Developer” warning.

Thursday, November 6, 2025

How can I see logs of a connected phone

  • brew install libimobiledevice
  • idevicesyslog | grep NetworkLog

Tuesday, November 4, 2025

How to enable local Ai assistant with Xcode 26

Install ollama

brew install ollama

Start/Stop ollama as a service

brew services start ollama1

Download a model

ollama pull qwen3:32b

ollama pull qwen2.5-coder:7b


Note the default port it is hosted on

Port: 11434




Wednesday, September 3, 2025

HOW TO: Integrating GraphQL into a SwiftUI App with Apollo iOS

Integrating GraphQL into a SwiftUI App

GraphQL makes it easier to fetch only the data your app needs, and Apollo iOS provides the tools to generate strongly-typed Swift code from your GraphQL schema. Here’s a step-by-step guide to setting up GraphQL in a SwiftUI project.


1. Project Setup

  • Create a GraphQL/ folder in your Xcode project.

  • This folder will hold:

    • schema.graphqls

    • Queries.graphql (and Mutations/Subscriptions if needed)

    • Generated files (API.swift)


2. Install Apollo iOS

  1. In Xcode, go to File → Add Packages…

  2. Add the package:

    https://github.com/apollographql/apollo-ios
  3. Select Apollo and ApolloCodegenLib.


3. Download the Schema

Use the Apollo CLI to download your schema from the GraphQL endpoint:

apollo schema:download --endpoint=https://yourapi/graphql schema.graphqls

4. Define Queries

Create a Queries.graphql file in your GraphQL/ folder. Add operations (queries, mutations, subscriptions):

query GetUser { user { id name } }

5. Code Generation

Add a Build Phase Script in Xcode:

apollo codegen generate \ GraphQL/Queries.graphql \ --schema GraphQL/schema.graphqls \ --output-directory GraphQL/

This generates API.swift with strongly-typed models.


6. Create Apollo Client

Create a Network.swift file for a shared client:

import Apollo class Network { static let shared = Network() private(set) lazy var apollo = ApolloClient(url: URL(string: "https://yourapi/graphql")!) }

7. Build ViewModels

Each feature should have its own ViewModel. Example:

import Foundation class UserViewModel: ObservableObject { @Published var user: GetUserQuery.Data.User? @Published var isLoading = false @Published var errorMessage: String? func loadUser() { isLoading = true Network.shared.apollo.fetch(query: GetUserQuery()) { [weak self] result in DispatchQueue.main.async { self?.isLoading = false switch result { case .success(let graphQLResult): self?.user = graphQLResult.data?.user case .failure(let error): self?.errorMessage = error.localizedDescription } } } } }

8. Connect to SwiftUI Views

Use the ViewModel in your SwiftUI view:

import SwiftUI struct UserView: View { @StateObject private var viewModel = UserViewModel() var body: some View { VStack { if let user = viewModel.user { Text(user.name) } else if viewModel.isLoading { ProgressView() } else if let error = viewModel.errorMessage { Text("Error: \(error)") } } .onAppear { viewModel.loadUser() } } }

9. Mutations (Optional)

You can perform mutations using Apollo:

Network.shared.apollo.perform(mutation: UpdateUserMutation(id: "123", name: "New Name")) { result in // handle response }

10. Async/Await (Optional)

Apollo iOS also supports async/await for cleaner code:

Task { do { let result = try await Network.shared.apollo.fetchAsync(query: GetUserQuery()) self.user = result.data?.user } catch { self.errorMessage = error.localizedDescription } }

Monday, August 25, 2025

How to enable Apple Intelligence Ai Assistance in Xcode 26

  • Install ollama
    • brew install --cask ollama
  • Get a coding model
    • # pick ONE to start
      • ollama pull codellama:7b-instruct
    • # or
      • ollama pull mistral:7b-instruct
    • # or
      • ollama pull phi3:3.8b-mini-instruct
  • Validate that llm is running locally
    • curl http://127.0.0.1:11434/v1/models
      • you should see something like "codellama:7b-instruct"
  • Add this to Xcode
    • Xcode ▸ Settings… ▸ Intelligence
    • add Model Provider 


Monday, February 24, 2025

How to watch USB traffic using Wireshark

 

macOS

Capturing USB traffic on macOS is possible since Wireshark 2.4.0, libpcap 1.9.0, and macOS High Sierra, using the XHC20 interface.

In order to capture on that interface, you will first have to run the command

ifconfig XHC20 up

as root, for example by running

sudo ifconfig XHC20 up

https://wiki.wireshark.org/CaptureSetup/USB

Thursday, February 6, 2025

How to convert a MOV file to a MP4 from a Mac terminal

 

download using python 

brew install yt-dlp ffmpeg

update .bash_profile with this function (remember to source)

convert_to_mp4() {
    if [ -z "$1" ]; then
        echo "Usage: convert_to_mp4 <input_file>"
        return 1
    fi

    input_file="$1"
    output_file="${input_file%.*}.mp4"

    ffmpeg -i "$input_file" -vcodec h264 -acodec aac "$output_file"
    echo "Converted: $input_file -> $output_file"
}

How to save YouTube to mp3

download using python 

brew install yt-dlp ffmpeg

command

yt-dlp -x --audio-format mp3 -o "%(title)s.%(ext)s" "YOUTUBE_URL"

save it to .bash_profile as a function (remember to source)


ytmp3() {
    yt-dlp -x --audio-format mp3 --audio-quality 0K -o "%(title)s.%(ext)s" "$1"
}


Monday, August 26, 2024

Tuesday, June 20, 2023

Wednesday, January 25, 2023

How to align a vstack to the bottom of a scrollview in SwiftUI

 GeometryReader { reader in

    ScrollView {
        VStack {
            /// Spacer() or Color.red will now behave as expected
        }
        .frame(minHeight: reader.size.height)
    }
}

Friday, September 9, 2022

How to get a list of paired bluetooth devices (Mac OS)

 https://gist.github.com/jamesmartin/9847466aba513de9a77507b56e712296

import IOBluetooth
// See https://developer.apple.com/reference/iobluetooth/iobluetoothdevice
// for API details.
class BluetoothDevices {
func pairedDevices() {
print("Bluetooth devices:")
guard let devices = IOBluetoothDevice.pairedDevices() else {
print("No devices")
return
}
for item in devices {
if let device = item as? IOBluetoothDevice {
print("Name: \(device.name)")
print("Paired?: \(device.isPaired())")
print("Connected?: \(device.isConnected())")
}
}
}
}
var bt = BluetoothDevices()
bt.pairedDevices()

How to get access to Bluetooth on Mac OS

 using RFICOMM and iAP2

https://developer.apple.com/documentation/iobluetooth/iobluetoothdevice


Wednesday, September 7, 2022

How to register and use MFi

Apple MFi FAQ:

https://mfi.apple.com/en/faqs.html


View who does not need to join the MFi Program.
  • Developers and manufacturers of non-electronic accessories, including non-MagSafe cases and Apple Watch bands. Get guidelines and resources for designing accessories that do not incorporate MFi licensed technologies.
  • Distributors and resellers that want to source or sell MFi accessories as finished goods. MFi finished goods must be sourced from an authorized MFi manufacturer. The MFi Licensee will be authorized to develop/manufacture goods sold under your company's brand and will take responsibility for all program requirements on your company's behalf. The Licensee will also be authorized to include the correct MFi badge on the product packaging and user guide of your accessory, once it has completed the necessary program requirements.
  • Developers and manufacturers of accessories that connect to an Apple device using only Bluetooth Low Energy, Core Bluetooth, or standard Bluetooth profiles supported by iOS. Learn more about Bluetooth(Note: BLE-enabled HomeKit accessories and BLE-enabled MFi Hearing Aids are part of the MFi Program).
  • Educational organizations that want to use the MFi technical specifications for teaching purposes. The information shared under the MFi Program is Apple Confidential and is not intended to be used in an academic setting.
  • Hobbyists and makers creating smart home accessories can use the non-commercial version of the HomeKit Accessory Protocol Specification.
  • Individuals creating accessories for personal use. We recommend using a third-party hobbyist solution to connect iOS devices to serial devices, and to write apps that communicate with these serial devices.
  • App developers creating apps that communicate with MFi accessories. App developers should join the Apple Developer Program. However, it is up to the accessory developer or manufacturer to determine whether they wish to authorize specific third-party apps to communicate with their MFi accessories through the External Accessory Framework. App developers should consult with the accessory developer to determine whether to proceed with development of an app that communicates with an MFi accessory using the EA framework.

Steps to follow for App developer and Device developer:
https://usermanual.wiki/Pdf/Guide20to20Submitting20Apps20that20Work20with20Accessories20R2.781218596/help


Some Apple forum discussion:

https://developer.apple.com/forums/thread/4905



Tuesday, September 6, 2022

Tuesday, March 15, 2022

NSPredicate example and how to use them

 https://academy.realm.io/posts/nspredicate-cheatsheet/

Format string summary

@"attributeName == %@"

object’s attributeName value is equal to value passed in

@"%K == %@"

pass a string variable to %K, it will be represented as a keypath, then check if it’s value is equal to value passed in

@"%name IN $NAME_LIST"

templated for predicate, checks if the value of key name is in $NAME_LIST. Uses predicateWithSubstitutionVariables

@"'name' IN $NAME_LIST"

checks if the constant value ‘name’ is in $NAME_LIST. Uses predicateWithSubstitutionVariables

[NSPredicate predicateWithFormat: @"title == %@", @"minecraft"]


Tuesday, February 22, 2022

Explain how runloops work

 https://khorbushko.github.io/article/2020/11/29/runloop-in-depth.html


RunLoop is the implementation of well-known EventLoop pattern - * programming construct or design pattern that waits for and dispatches events or messages in a program*.

while (!end) { } 

This pattern has been implemented on many platforms. Thus, the main problems that it should resolve are:

  • receive events/messages
  • work when works exist and sleep when no work available (correct resource management).

Hight level description of Thread:

thread life

Hight level description of EventLoop:

thread life

iOS/macOS RunLoop

Talking about iOS/macOS we always refer to RunLoop. To be more correct - 2 classes implement this behavior:

  • CFRunLoopRef (open source)
  • NSRunLoop (based on CFRunLoopRef)

As you already see, RunLoop is connected to the thread. You can’t create RunLoop directly, instead, it’s can be created at the very start of Thread creating and destroyed at the very end of theThread lifecycle. There are 2 function that provide access to RunLoop - CFRunLoopGetMain()and CFRunLoopGetCurrent()

debug backtrace

Run loops are part of the fundamental infrastructure associated with threads. A run loop is an event processing loop that you use to schedule work and coordinate the receipt of incoming events. The purpose of a run loop is to keep your thread busy when there is work to do and put your thread to sleep when there is none. - Apple.