Ben Fox
About Archive Also on Micro.blog
  • Expand all large diffs in a GitHub pull request

    document.querySelectorAll('button.load-diff-button').forEach(button => button.click());
    

    via

    → 11:59 AM, May 29
  • UIImage orientation enum cases

    UIImage.Orientation case labels and integer values:

    case up = 0
    case down = 1
    case left = 2
    case right = 3
    
    case upMirrored = 4
    case downMirrored = 5
    case leftMirrored = 6
    case rightMirrored = 7
    
    → 1:57 PM, Apr 8
  • How do I checkout a PR from a fork?

    You don’t need access to the fork. Just fetch it from the main repo using the PR ref. If the PR ref (number) is #3, then fetch pull/3/head like this:

    git fetch origin pull/3/head:my_new_branch
    git checkout my_new_branch
    

    (via)

    → 2:55 PM, Sep 12
  • NSSecureCoding and transformable properties in Core Data

    Fixes:

    One or more models in this application are using transformable properties with transformer names that are either unset, or set to NSKeyedUnarchiveFromDataTransformerName.

    → 11:55 AM, Jul 11
  • Workaround: Xcode deletes Package.resolved file and produces ‘missing package product’ errors

    I didn’t implement the suggested workaround, but this post did convince me to stop trying to fix this bug myself.

    → 12:46 PM, Jun 24
  • OpenAI API: image_url is only supported by certain models.

    This OpenAI API error message:

    Error: {
       "param": "messages.[1].content.[1].type",
        "message": "Invalid content type. image_url is only supported by certain models.",
        "code": null,
        "type": "invalid_request_error"
    }
    

    … is a (mistaken) catchall that’s likely covering up something else. The API returns this whenever there’s a problem in the image_url field, regardless of your model choice. (Try sending it garbage image data as base64 to test it.)

    → 5:39 PM, Jun 19
  • Command CompileAssetCatalog failed with a nonzero exit code

    In Xcode 15.3, gaussian blurs in SVGs are no longer supported and cause a failure at compile time. If you’re getting this error when building, check for SVG files in your asset catalog that include a gaussian blur. Some apps (Sketch) use gaussian blurs for their inner / outer shadows. Discussion

    → 9:59 PM, Mar 16
  • → 1:35 PM, Mar 5
  • How to detect when your app moves to the background or foreground with scenePhase

    → 7:05 PM, Feb 27
  • Use persistentSystemOverlay to hide the Window Bar on visionOS apps

    → 12:48 PM, Feb 27
  • How to create an HTTP GET request in Swift Playground

    → 6:42 PM, Feb 26
  • How to Create a Realistic Pressed Leather Effect in Photoshop (archived)

    → 8:21 PM, Nov 27
  • How to install the Windows version of Steam on macOS Sonoma

    We will install the x86 version Homebrew in order to be able to use Apple’s modified version of Wine and to install the Windows version Steam.

    We will make sure that our existing environment (and the Apple silicon version of Homebrew we need for ‘serious’ work) remains undisturbed.

    works on my machine ¯\_(ツ)_/¯

    → 4:53 PM, Nov 25
  • Keep tags when forking a GitHub repository

    Forking a repository with GitHub doesn’t bring its tags (or releases) along. Here’s how to update your fork with the upstream’s tags. Releases will still be missing. (Adapted from Update git fork with tags.sh)

    # Clone your fork of the upstream repo
    git clone https://github.com/my_team/my_fork.git
    cd my_fork
    # Add your fork's upstream as a remote
    git remote add upstream https://github.com/upstream_team/upstream_repo.git
    
    # Fetch from upstream
    git fetch upstream
    # Rebase onto upstream
    git rebase upstream/main
    
    # Push to your fork's remote
    git push
    git push --tags
    
    → 11:39 AM, Oct 10
  • Weval: synth GOAT

    → 10:30 AM, Sep 29
  • Logging all UIAccessibility capabilities

    Logging all available accessibility traits (as of iOS 17):

    let accessibilityTraits: [String: Bool] = [
        "a11y_isAssistiveTouchRunning":  UIAccessibility.isAssistiveTouchRunning,
        "a11y_isBoldTextEnabled":  UIAccessibility.isBoldTextEnabled,
        "a11y_isClosedCaptioningEnabled": UIAccessibility.isClosedCaptioningEnabled,
        "a11y_isDarkerSystemColorsEnabled": UIAccessibility.isDarkerSystemColorsEnabled,
        "a11y_isGrayscaleEnabled": UIAccessibility.isGrayscaleEnabled,
        "a11y_isGuidedAccessEnabled": UIAccessibility.isGuidedAccessEnabled,
        "a11y_isInvertColorsEnabled": UIAccessibility.isInvertColorsEnabled,
        "a11y_isMonoAudioEnabled": UIAccessibility.isMonoAudioEnabled,
        "a11y_isOnOffSwitchLabelsEnabled": UIAccessibility.isOnOffSwitchLabelsEnabled,
        "a11y_isReduceMotionEnabled": UIAccessibility.isReduceMotionEnabled,
        "a11y_isReduceTransparencyEnabled": UIAccessibility.isReduceTransparencyEnabled,
        "a11y_isShakeToUndoEnabled": UIAccessibility.isShakeToUndoEnabled,
        "a11y_isSpeakScreenEnabled": UIAccessibility.isSpeakScreenEnabled,
        "a11y_isSpeakSelectionEnabled": UIAccessibility.isSpeakSelectionEnabled,
        "a11y_isSwitchControlRunning": UIAccessibility.isSwitchControlRunning,
        "a11y_isVideoAutoplayEnabled": UIAccessibility.isVideoAutoplayEnabled,
        "a11y_isVoiceOverRunning": UIAccessibility.isVoiceOverRunning,
        "a11y_shouldDifferentiateWithoutColor": UIAccessibility.shouldDifferentiateWithoutColor,
        "a11y_buttonShapesEnabled": UIAccessibility.buttonShapesEnabled,
        "a11y_prefersCrossFadeTransitions": UIAccessibility.prefersCrossFadeTransitions
    ]
    
    → 1:42 PM, Sep 25
  • Adding Apple Universal Links to Webflow

    I’d like to add /.well-known/apple-app-site-association to my website, but I can’t, because Webflow doesn’t support it, and I went all-in on Webflow during a Lottie-fueled scrollspy bender a few years ago.

    Here’s how to host your AASA file for universal links while using Webflow - by using a worldwide distributed highly javascript available cloud edge application to replace a 355 byte static plaintext file that is requested about once a week by Apple’s CDN.

    Use Cloudflare

    1. Use Cloudflare for DNS
    2. Disable SSL in your Webflow site’s settings - Cloudflare will handle SSL for you now.
    3. Enable Cloudflare’s proxying for the apex A record and www CNAME pointing to your Webflow site

    Create a route

    Allowing Cloudflare to proxy your website means you can intercept and work on requests at specific paths. They call these “routes”.

    1. Click your domain
    2. Click “Workers Routes”
    3. Click “Add route”
    4. Enter your route - probably mycoolapp.com/.well-known/*.
    5. Leave Worker set to “None” and press “Save”

    Create a worker

    Still in the Workers Routes screen:

    1. Click “Manage Workers”
    2. Click “Create Application”
    3. Pick one of the templates - doesn’t matter, we’re going to empty it
    4. Give it a useful name (“well-known”)
    5. Click “Deploy”

    Give your worker a script

    1. Copy and paste this worker script I made into the Cloudflare editor
    2. Edit the appleAppSiteAssociationJSON object - you need to replace the appIDs and add/replace the components
    3. Click “Save and deploy”

    Assign the worker

    1. Tap the Cloudflare logo
    2. Tap your domain
    3. Tap “Workers Routes”
    4. Tap “Edit” next to the route you crated earlier
    5. In the “Worker” dropdown, select the “well-known” worker you just created

    Testing the route

    1. Tap “well-known” in the Worker column
    2. Tap “Quick Edit”
    3. In the right half of the screen, enter the URL your apple-app-site-association file should live - it’s probably https://mycoolapp.com/.well-known/apple-app-site-association/
    4. If you get a 200 OK response, and you can see your AASA JSON content in the response payload, you’re probably good!
    → 3:30 PM, Sep 19
  • Testing iOS universal links

    Your apple-app-site-association file needs to include a list of appIDs. These app IDs take the form of app-id-prefix.app-bundle-id. You can get the App ID prefix in your Apple Developer account, in “Certificates, Identifiers, & Profiles”. Tap your app’s identifier and you’ll see “App ID Prefix” at the top of the screen.

    If you’re setting up Universal Links, you can make debugging easier:

    TN3155: Debugging universal links | Apple Developer Documentation

    1. Turn on Developer Mode in Settings.
    2. In Settings > Developer, scroll to the section labeled Universal Links and turn on Associated Domains Development.
    3. Open Diagnostics and type in your full URL. You will receive feedback on whether this link is valid for an installed app.

    You can force your app to re-request your apple-app-site-association file every run (or install?), so you don’t have to wait for Apple’s CDN to re-cache it. In your Associated Domains capability, replace your domain definition applinks:mycoolapp.com with applinks:mycoolapp.com/?mode=developer. Documentation: Associated Domains Entitlement

    → 2:10 PM, Sep 19
  • Testing some deep links:

    Create notebook

    → 2:05 PM, Sep 19
  • What I Learned Writing My Own CloudKit Syncing Library

    CloudKit implements rate limiting. It has a special CKError code for this, requestRateLimited, but I’ve actually never seen an error with this code. In practice, rate limiting is indicated by serviceUnavailable (CKError 6, HTTP code 503).

    → 9:06 AM, Sep 8
  • CloudKit CKErrors: Raw values and case names

    While troubleshooting CloudKit bugs, I came across the excellent post General Findings about NSPersistentCloudKitContainer. I followed their lead and added an observer to NSPersistentCloudKitContainer, and was able to log a lot (a LOT) of CKErrors, but somehow only caught the raw Int values and not the case names.

    Raw value Case name Cause
    1 internalError A nonrecoverable error that CloudKit encounters.
    2 partialFailure An operation completed with partial failures.
    3 networkUnavailable The network is unavailable.
    4 networkFailure A network is available, but CloudKit is inaccessible.
    5 badContainer You used an unknown or unauthorized container.
    6 serviceUnavailable CloudKit is unavailable.
    7 requestRateLimited CloudKit is rate-limiting requests.
    8 missingEntitlement The app is missing a required entitlement.
    9 notAuthenticated The user is unauthenticated.
    10 permissionFailure The user doesn’t have permission to save or fetch data.
    11 unknownItem The specified record doesn’t exist.
    12 invalidArguments The request contains invalid information.
    13 resultsTruncated (Deprecated) CloudKit truncated a query’s results.
    14 serverRecordChanged CloudKit rejected a record because the server’s version is different.
    15 serverRejectedRequest CloudKit rejected the request.
    16 assetFileNotFound The system can’t find the specified asset.
    17 assetFileModified The system modified an asset while saving it.
    18 incompatibleVersion The current app version is older than the oldest allowed version.
    19 constraintViolation The server rejected the request because of a unique constraint violation.
    20 operationCancelled An operation cancelled.
    21 changeTokenExpired The change token expired.
    22 batchRequestFailed The system rejected the entire batch of changes.
    23 zoneBusy The server is too busy to handle the record zone operation.
    24 badDatabase The operation can’t complete for the specified database.
    25 quotaExceeded Saving a record exceeded the user’s storage quota.
    26 zoneNotFound The specified record zone doesn’t exist.
    27 limitExceeded The request’s size exceeds the limit.
    28 userDeletedZone The user deleted a record zone using the Settings app.
    29 tooManyParticipants A share has too many participants.
    30 alreadyShared CloudKit attempted to share a record with an existing share.
    31 referenceViolation CloudKit can’t find the target of a reference.
    32 managedAccountRestricted CloudKit rejected a request due to a managed-account restriction.
    33 participantMayNeedVerification The user isn’t a participant of the share.
    34 serverResponseLost CloudKit is unable to maintain the network connection and provide a response.
    35 assetNotAvailable The system can’t access the specified asset.
    36 accountTemporarilyUnavailable The user’s iCloud account is temporarily unavailable.
    → 5:58 PM, Sep 7
  • Today, I am grateful for Joe Kay and Soulection.

    → 8:43 PM, Apr 28
  • RSS
  • JSON Feed
  • Surprise me!