fix(ios): resolve app target name for Expo pre-55 patch#239
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Expo config plugin’s iOS “Expo pre-55” patching logic to correctly resolve the app target name instead of assuming a fixed target name, so the patch can locate the correct CocoaPods support file.
Changes:
- Add
ios.appTargetNameplugin option (with fallback auto-detection from the Xcode project). - Update the pre-55 patch template to use the resolved app target name in the CocoaPods support-file path.
- Add Xcode project helper logic to locate an application target by
productType.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-brownfield/src/expo-config-plugin/withBrownfield.ts | Adds appTargetName into resolved iOS plugin config defaults. |
| packages/react-native-brownfield/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.ts | Documents the new appTargetName option in the iOS config type. |
| packages/react-native-brownfield/src/expo-config-plugin/template/ios/patchExpoPre55.sh | Uses {{APP_TARGET_NAME}} when building the CocoaPods support-file path. |
| packages/react-native-brownfield/src/expo-config-plugin/ios/xcodeHelpers.ts | Resolves app target name dynamically and injects it into the patch template render. |
| packages/react-native-brownfield/src/expo-config-plugin/ios/withBrownfieldIos.ts | Wires appTargetName through to the pre-55 patch build phase creation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/react-native-brownfield/src/expo-config-plugin/ios/xcodeHelpers.ts
Outdated
Show resolved
Hide resolved
packages/react-native-brownfield/src/expo-config-plugin/ios/xcodeHelpers.ts
Outdated
Show resolved
Hide resolved
packages/react-native-brownfield/src/expo-config-plugin/types/ios/BrownfieldPluginIosConfig.ts
Outdated
Show resolved
Hide resolved
| "@callstack/react-native-brownfield", | ||
| { | ||
| "ios": { | ||
| "appTargetName": "MyApp", |
There was a problem hiding this comment.
in Expo apps, there should be appName available in the app.json config, isn't it?
There was a problem hiding this comment.
can it be different in Expo projects than the Xcode project name?
There was a problem hiding this comment.
I think it should be the same for generated project. I will verify with using the name option. @artus9033 - is also taking a look on how Expo uses the name to auto generate iOS project.
There was a problem hiding this comment.
yeah. because maybe we don't need that change after all, or make it simpler
There was a problem hiding this comment.
I modified the auto-detection algorithm as we established with @hurali97 . Now instead of relying on the config field, we're doing the following (the below is in the docs as of now):
- Common for all cases: scan the iOS targets for ones of type
com.apple.product-type.application- Use the first matching strategy:
- CNG-derived name from mod compiler (
modRequest.projectName) - only if it exists in the filtered application-type list of Xcode project targets- Unambiguous first application-type target - if there is exactly one
- PBX "first native target" fallback - last resort fallback that selects the first native target of any type
The third fallback is desperate and if the first 2 don't work, it's very unlikely anything will work, but we may keep it. If I were to guess, I'd foresee that it's unlikely we ever fall out of the 1st strategy, and even if so (for whatever reason, e.g. due to another config plugin modding the native project) the 2nd should work at all times.
18b0dab to
0d119fe
Compare

Summary
This resolves the app target name for Expo pre-55 patch by:
appTargetNamecom.apple.product-type.applicationBy default, if user does not provide the
appTargetNamewe resolve it dynamically, if the name is not found, we throw an error to pass it explicitly.Test plan
CI passes - 🟢