diff --git a/Sources/Site/Posts/2024/10/2024-10-02-arm64_32-PSA.md b/Sources/Site/Posts/2024/10/2024-10-02-arm64_32-PSA.md new file mode 100644 index 0000000..113da0e --- /dev/null +++ b/Sources/Site/Posts/2024/10/2024-10-02-arm64_32-PSA.md @@ -0,0 +1,27 @@ +# Reminder: Apple Watches use 32 bit pointers + +> Since the Series 4 was introduced in 2018, all new Apple Watches have been arm64_32. The last +> Apple Watch to be armv7k was the Series 3. + +Source: https://forums.developer.apple.com/forums/thread/759363 + +What is arm64_32? It's a 64 bit operating system that runs on 32 bit pointers. + +When you test on the watchOS simulator, you're typically going to be testing with 64-bit pointers, +so you'll get a 64 bit Int when testing in sim and a 32 bit Int when testing on hardware. + +Something as simple as + +```swift +print(String(Int(Date.now.timeIntervalSince1970 * 1000))) +``` + +can work fine in the simulator but causes a runtime crash on hardware. Be mindful of your use of Int +and CGFloat types when deploying code to the Apple Watch. + +Here's the output of Int.max on each platform: + +| Simulator | Hardware (oh no!) | +|:---------:|:-------------------:| +| ![64 bit pointers on Apple Watch simulator](/gfx/pointers/64bit.png) | ![32 bit pointers on Apple Watch hardware](/gfx/pointers/32bit.png) | + diff --git a/site/gfx/pointers/32bit.png b/site/gfx/pointers/32bit.png new file mode 100644 index 0000000..4b9f768 Binary files /dev/null and b/site/gfx/pointers/32bit.png differ diff --git a/site/gfx/pointers/64bit.png b/site/gfx/pointers/64bit.png new file mode 100644 index 0000000..0a44b72 Binary files /dev/null and b/site/gfx/pointers/64bit.png differ