Fixing Expo + React Native iOS Build Failures
Two blocking build issues: hundreds of modulemap errors from opening .xcodeproj instead of .xcworkspace, and an Axios crypto import that doesn't exist in React Native.
Two separate issues blocked iOS builds for days. Both had misleading error messages that led me down wrong paths.
Issue 1: Hundreds of Modulemap Errors
After running npx expo prebuild, Xcode showed hundreds of Clang errors:
Module map file '.../Build/Pods/Headers/module.modulemap' not found
Every CocoaPods dependency failed. I tried cleaning build folders, reinstalling pods, deleting derived data -- nothing helped.
The fix was embarrassing:
# WRONG: opens the project without CocoaPods workspace
open ios/PlanPalAI.xcodeproj
# RIGHT: opens the workspace that includes pods
open ios/PlanPalAI.xcworkspace
.xcodeproj doesn't include the CocoaPods workspace configuration. Every pod dependency is invisible. The error messages point at modulemaps rather than saying "you opened the wrong file."
Issue 2: Axios Crypto Import
After fixing the build, a runtime crash:
Error: Unable to resolve module crypto from axios/lib/helpers/formDataToStream.js
Axios v1.6+ imports Node's crypto module for multipart form data streaming. Node's crypto doesn't exist in React Native.
The fix: replace Axios with React Native's built-in fetch:
// BEFORE: Axios
const response = await axios.post('/api/walks', data, {
headers: { Authorization: `Bearer ${token}` },
});
return response.data;
// AFTER: fetch (no Node dependencies)
const response = await fetch(`${baseUrl}/api/walks`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(data),
});
return await response.json();
Both issues share a lesson: the error messages didn't point at the actual problem. Modulemap errors meant "wrong project file." Crypto import errors meant "this HTTP library assumes Node.js."
Built while working on PlanPal.
Back to danielships ->