expo-cli icon indicating copy to clipboard operation
expo-cli copied to clipboard

[ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path')

Open schematis opened this issue 2 years ago • 3 comments

Summary

There is a mismatch in the pbxProject.js file between what's in expo-cli and the cordova-node-xcode project.

Line 1682 of the version in the cordova-node-xcode project looks like:

if (project.pbxGroupByName(group) && project.pbxGroupByName(group).path)

But the same line in the expo-cli looks like:

if (project.pbxGroupByName(group).path)

Which means that if the group is not found, it will automatically error out instead of just skipping the check. This blocks other code in the file that focuses on creating the group if it's not found.

Environment

expo-env-info 1.0.2 environment info: System: OS: macOS 12.3.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node Yarn: 1.22.18 - /usr/local/bin/yarn npm: 8.6.0 - ~/.nvm/versions/node/v16.13.2/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8092744 Xcode: 13.3/13E113 - /usr/bin/xcodebuild npmPackages: expo: ~44.0.4 => 44.0.5 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: eas-cli: 0.48.2 expo-cli: 5.3.0 Expo Workflow: bare

Please specify your device/emulator/simulator platform, model and version

n/a

Error output

✖ Config sync failed [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path') TypeError: [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path') at correctForPath (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:1682:38) at correctForResourcesPath (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:1672:12) at pbxProject.addResourceFile (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:258:9)

✖ Config sync failed [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path') TypeError: [ios.xcodeproj]: withIosXcodeprojBaseMod: Cannot read properties of null (reading 'path') at correctForPath (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:1682:38) at correctForPluginsPath (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:1668:12) at pbxProject.addPluginFile (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:106:5) at pbxProject.addHeaderFile (/Users/brendanvinson/.nvm/versions/node/v16.13.2/lib/node_modules/expo-cli/node_modules/xcode/lib/pbxProject.js:214:21)

Reproducible demo or steps to reproduce from a blank project

expoConfig = withXcodeProject(expoConfig, (config) => {
    const target = IOSConfig.XcodeUtils.getApplicationNativeTarget({
      project: config.modResults,
      projectName: config.modRequest.projectName,
    });

    config.modResults.addResourceFile('PluginSDK/RCTPlugin.m', {
        target: target.uuid,
    });

    return config;
  });

schematis avatar Apr 07 '22 20:04 schematis

can you please share a minimal reproducible example?

brentvatne avatar Apr 11 '22 19:04 brentvatne

I've added one to the original post. 👍

schematis avatar Apr 19 '22 19:04 schematis

thanks @schematis - can you open a pr to resolve this?

brentvatne avatar May 31 '22 22:05 brentvatne

hello, this is blocking indeed. it seems the fix that landed into cordova-node-xcode has never been published to npm.

In my particular use case, I circumvented the error by creating the Resources group before using addResourceFile, something like this:

const xcodeProject = config.modResults;
xcodeProject.pbxCreateGroup("Resources");
xcodeProject.addResourceFile(iosStoreKitConfigurationPath);

But to be honest, I don't know what I'm doing 😅

What I don't get is why the Resources group don't exist in the first place in the pbxproj template used in expo prebuild?

(PS: this would be great to have proper TS support around XCodeProject type 🤩)

xseignard avatar Oct 07 '22 06:10 xseignard

Our plan to fix this is to migrate to xcparse but I don't have much time to work on the migration at the moment. It is possible to use xcparse today by implementing a config plugin in user space.

EvanBacon avatar Oct 27 '22 22:10 EvanBacon

+1

cubesmeta avatar Dec 10 '22 00:12 cubesmeta

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

github-actions[bot] avatar Mar 10 '23 01:03 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale. Please open a new issue if you believe you are encountering a related problem.

github-actions[bot] avatar Mar 17 '23 02:03 github-actions[bot]

any news on this? , currently running in to the same issue

jb-san avatar Apr 05 '23 19:04 jb-san

Still getting this issue.

maguid28 avatar May 25 '23 21:05 maguid28

+1

mihaibulic2 avatar Jan 02 '24 20:01 mihaibulic2