Description
Cannot Run arm64 Binary on Simulator
The printer library is maintained by the vendor and has not been updated to run natively on Apple Silicon. There are a workarounds such as running in Rosetta or only building for x86_64, but each come with their own downsides.
I was able to get the project building but not running by following along with these two articles Arm to Sim Static, ... Dynamic and this Spotify PR.
The app builds and launchs, but crashes due to a code signing issue.
Steps
- Folder Structure
- Info.plist
- Set Build Version
- Code Signing
- ???
- EXC_BAD_ACCESS
Folder Structure
% tree ~Desktop/BRPtouchPrinterKit.xcframework
├── Info.plist
├── _CodeSignature
│ ├── CodeDirectory
│ ├── CodeRequirements
│ ├── CodeRequirements-1
│ ├── CodeResources
│ └── CodeSignature
├── ios-arm64_armv7
│ └── BRPtouchPrinterKit.framework
│ ├── BRPtouchPrinterKit
│ ├── Headers
│ ├── Info.plist
│ ├── Modules
│ │ └── module.modulemap
│ ├── _CodeSignature
│ │ └── CodeResources
│ └── ...
└── ios-arm64_x86_64-simulator
└── BRPtouchPrinterKit.framework
├── BRPtouchPrinterKit
├── Headers
│ └── ...
├── Info.plist
├── Modules
│ └── module.modulemap
├── _CodeSignature
│ └── CodeResources
└── ...
Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_armv7</string>
<key>LibraryPath</key>
<string>BRPtouchPrinterKit.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>armv7</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>BRPtouchPrinterKit.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Set Build Version
xcrun vtool -arch arm64 \
-set-build-version 7 10.0 10.0 \
-replace \
-output BRPtouchPrinterKit.framework/BRPtouchPrinterKit.reworked \
BRPtouchPrinterKit.framework/BRPtouchPrinterKit
Verify
xcrun vtool -arch arm64 \
-show \
BRPtouchPrinterKit.framework/BRPtouchPrinterKit.reworked
Code Sign
xcrun codesign --sign - BRPtouchPrinterKit.xcframework/ios-arm64-x86_64-simulator/BRPtouchPrinterKit.framework/BRPtouchPrinterKit
Says it is already signed. After verifying I change the name to just BRPtouchPrinterKit
EXC_BAD_ACCESS
`Thread 1: EXC_BAD_ACCESS (code=50, address=0x105fa0000)`
Signing Error
This looks like a code signing issue, but I'm not certain where I went wrong.
...
Exception Type: EXC_CRASH (SIGKILL (Code Signature Invalid))
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: CODESIGNING 2
Triggered by Thread: 0
...
References
Hacking native ARM64 binaries to run on the iOS Simulator
Hacking native ARM64 binaries to run on the iOS Simulator
Hacking native ARM64 binaries to run on the iOS Simulator - the dynamic framework edition