ReviewOS

craft-native/craft

fix(ios): 0.0.174+ does not compile — `contentPadding` out of scope, `rawAttestationObject` optional, and no PRODUCT_NAME

#354
Closed glennmichael123 opened this 9 days ago ·
9 days ago

craft-native 0.0.174 and 0.0.175 ship iOS templates that do not compile. A clean xcodebuild of a generated project fails with two unrelated errors in craft's own Swift, so no iOS build of any kind is possible on these versions.

Both symbols are new in 0.0.174: neither appears in 0.0.173 or 0.0.158.

0.0.158  contentPadding=0   rawAttestationObject=0
0.0.173  contentPadding=0   rawAttestationObject=0
0.0.174  contentPadding=15  rawAttestationObject=1
0.0.175  (same as 0.0.174)

1. contentPadding used outside the function that declares it

ios/templates/CraftNativeScreen.swift

error: cannot find 'contentPadding' in scope   (1631:37, 1631:76, 1632:37, 1632:106, 1728:53)

It is a local declared at line 1218, inside func layout( which begins at 1208. The uses at 1631–1632 and 1728 are in later functions — the one starting at 1305 and func layoutGrid( at 1642 — where the name does not exist.

// 1218, inside layout(
let contentPadding = effectivePadding

// 1631, inside a different function
? CGRect(x: contentPadding.left + mainPosition, y: contentPadding.top + …)

2. rawAttestationObject is Data?

ios/templates/CraftNativeActions.swift:1245

error: value of optional type 'Data?' must be unwrapped to a value of type 'Data'
"attestationObject": Self.base64url(registration.rawAttestationObject),

ASAuthorizationPlatformPublicKeyCredentialRegistration.rawAttestationObject is optional — it is nil for a registration that produced no attestation. The neighbouring rawClientDataJSON is non-optional, which is probably how it was missed.

3. The generated project has no PRODUCT_NAME

Separate from the two above, and hit first. The generated Wildloop.xcodeproj/project.pbxproj sets PRODUCT_BUNDLE_IDENTIFIER, INFOPLIST_FILE and the rest, but never PRODUCT_NAME, in any of its six buildSettings blocks. Xcode then resolves it to empty and both targets build products with no name:

error: Multiple commands produce '…/Debug-iphonesimulator/.app'
error: Multiple commands produce '…/Debug-iphonesimulator/.appex'

Adding PRODUCT_NAME = "$(TARGET_NAME)" to each block fixes it — the build then proceeds and emplaces Wildloop.app correctly, which is how the two compile errors above became visible. Worth noting the products in derived data from an earlier build were WildLoop.app (capital L) while the current project names its targets Wildloop; on a case-insensitive filesystem those collide, so a stale derived-data directory makes this look like a different bug than it is.

Environment

Xcode with the iOS 26.5 simulator SDK, -configuration Debug, destination platform=iOS Simulator. Verified against a freshly removed derived-data directory, so none of this is stale state.

Impact

0.0.174 is the release that brought the native Map (craft#340) — which is the thing we had been waiting for — and it is not reachable, because nothing built from it compiles. We are pinning back to 0.0.173 to keep a working iOS build; that costs us nothing today only because the Map cannot be fed from data either (stacksjs/stx#2073).

9 days ago

Confirming on 0.0.175, hq.training, Xcode 26 / iOS 26.5 simulator. Tried the bump to see whether it changed anything for #350 and the bar buttons; it does not build:

Sources/CraftNativeActions.swift:1245:70: error: value of optional type 'Data?'
must be unwrapped to a value of type 'Data'

That is "attestationObject": Self.base64url(registration.rawAttestationObject) — ASAuthorizationPlatformPublicKeyCredentialRegistration.rawAttestationObject is optional, and base64url takes a non-optional Data. 25 Swift files compiled, 3 failures, all from that file.

Staying on 0.0.173, which builds and runs.

9 days ago

Correction: the three reported build blockers are fixed on main: generated targets now set PRODUCT_NAME (e93c85b), the native screen template no longer uses an out-of-scope number helper (96bf52a), and passkey registration unwraps rawAttestationObject before encoding it (a0c0cc3). Builder regressions cover the generated project and optional attestation path. This still needs a published version newer than 0.0.175 plus a clean Xcode build; the current CoreSimulator service is unavailable in this environment, so I am leaving the issue open until release/runtime validation.

9 days ago

Fixed somewhere between 0.0.175 and 0.0.187.

HQ builds on 0.0.187 now: four clean xcodebuild runs of a freshly generated project today, 0 errors — including one from a cold start. Both symbols that broke it compile:

0.0.187  contentPadding   in scope
0.0.187  rawAttestationObject  non-optional where the template uses it

Closing on that. If either regresses, the versions in the table above are the ones to bisect from.

Sign in to comment on this issue.