Fix iOS device/simulator cache-key collision in build hook - #27
Open
HamzaZahid29 wants to merge 1 commit into
Open
Fix iOS device/simulator cache-key collision in build hook#27HamzaZahid29 wants to merge 1 commit into
HamzaZahid29 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When I archived my Flutter app and tried to upload it to App Store Connect, it kept getting rejected with two errors:
"The binary is invalid... this binary does not seem to have been built with Apple's linker" (code 90125)
"references an unsupported platform in the arm64 slice... Simulator platforms aren't permitted" (code 91169)
i created this script that checks for
#!/bin/bash
set -e
IPA=$(ls build/ios/ipa/*.ipa | head -1)
TMPDIR=$(mktemp -d)
unzip -q "$IPA" -d "$TMPDIR"
BINARY="$TMPDIR/Payload/Runner.app/Frameworks/fllama.framework/fllama"
PLATFORM=$(xcrun vtool -show-build "$BINARY" | grep platform | awk '{print $2}')
rm -rf "$TMPDIR"
if [ "$PLATFORM" != "IOS" ]; then
echo "fllama binary is tagged $PLATFORM, not IOS — do not upload!"
exit 1
fi
echo "fllama binary correctly tagged for device (IOS)"
After digging into it, I found that the fllama binary in my final IPA was actually built for the iOS Simulator, not for a real device — even though I ran flutter build ipa specifically for release/device.
I traced it to hook/build.dart. fllama caches its compiled library on disk under ~/.cache/fllama//, and the cache key is based on os + arch. The problem is that on Apple Silicon Macs, iOS Simulator and real iOS devices both report os = ios and arch = arm64 — the Simulator runs arm64 natively now, so there's nothing in the key that tells them apart.I traced it to hook/build.dart. fllama caches its compiled library on disk under ~/.cache/fllama//, and the cache key is based on os + arch. The problem is that on Apple Silicon Macs, iOS Simulator and real iOS devices both report os = ios and arch = arm64 — the Simulator runs arm64 natively now, so there's nothing in the key that tells them apart.
I added the iOS SDK type (iphoneos vs iphonesimulator) into the cache key, so Simulator and device builds get separate cache entries and can never overwrite each other. I also bumped the cache schema version so anyone upgrading gets a clean cache automatically, instead of needing to manually clear it themselves.
I don't know much about this library so i would recommend going through my implementation.