OneSignal/onesignal-expo-plugin

[Bug]: Adds new PBXGroup for OneSignalNotificationServiceExtension to project.pbxproj on every prebuild

chriszs opened this issue · 5 comments

What happened?

Additional PBXGroup references to OneSignalNotificationServiceExtension are being added to project.pbxproj every time I run expo prebuild, causing repetition like so:

		83CBB9F61A601CBA00E9B192 = {
			isa = PBXGroup;
			children = (
                                # ...
				D65327D7A22EEC0BE12398D9 /* Pods */,
				D7E4C46ADA2E9064B798F356 /* ExpoModulesProviders */,
				2BFA461EC0B84502B51447BE /* OneSignalNotificationServiceExtension */, # added by first run
				7E9866E5EBC34BC99B916377 /* OneSignalNotificationServiceExtension */, # added by second
				B27B50B397654BE39E23F8C2 /* OneSignalNotificationServiceExtension */, # added by third
			);

This despite some logging indicating the plugin detects the service extension is already generated:

        onesignal-expo-plugin: OneSignalNotificationServiceExtension already exists in project. Skipping...
        onesignal-expo-plugin: OneSignalNotificationServiceExtension target already added to Podfile. Skipping...

Looking at the relevant code, it looks like the PBXGroup is added before this check.

It's a known problem that not all Expo Config Plugins are idempotent, but this plugin does a good job of being almost idempotent and it would great if it was fully so that I don't have to run expo prebuild --clean and reinstall all the pods each time.

Steps to reproduce?

1. Added `onesignal-expo-plugin`
2. Ran `expo prebuild` and staged the result to git
3. Ran `expo prebuild` again and examined the diff

What did you expect to happen?

I expected to see one reference to OneSignalNotificationServiceExtension, instead of one per run.

OneSignal Expo SDK version

1.3.2 because I haven't yet migrated to react-native-onesignal 5.0, but I don't see a fix for this in 2.0.

Platform

iOS

Relevant log output

> expo prebuild --no-install && pod-install

✔ Created native projects | /android, /ios already created | gitignore skipped
✔ Updated package.json and added index.js entry point for iOS and Android
        onesignal-expo-plugin: OneSignalNotificationServiceExtension already exists in project. Skipping...
        onesignal-expo-plugin: OneSignalNotificationServiceExtension target already added to Podfile. Skipping...
✔ Config synced
Scanning for pods...
1.12.1
> pod install
Using Expo modules
[Expo] Enabling modular headers for pod ExpoModulesCore
Auto-linking React Native modules for target: A0Auth0, BVLinearGradient, RNCAsyncStorage, RNCMaskedView, RNGestureHandler, RNReanimated, RNSVG, RNScreens, appcenter-analytics, appcenter-core, appcenter-crashes, react-native-netinfo, react-native-onesignal, react-native-pager-view, react-native-safe-area-context, react-native-sensitive-info, and react-native-webview
Framework build type is static library
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
[Codegen] Found FBReactNativeSpec
[Codegen] Found rncore
Downloading dependencies
Generating Pods project
Setting REACT_NATIVE build settings
Setting CLANG_CXX_LANGUAGE_STANDARD to c++17
Pod install took 9 [s] to run
Integrating client project
expo_patch_react_imports! took 0.1414 seconds to transform files.
Pod installation complete! There are 69 dependencies from the Podfile and 75 total pods installed.

up to date, audited 1790 packages in 26s

Code of Conduct

  • I agree to follow this project's Code of Conduct

@chriszs , thanks very much for this issue report. This should be resolved in the next release.

Thank you!

@rgomezp I'm still experiencing this issue with v2.0.2. Can you confirm whether this should of been resolved? Thanks.

@rgomezp I'm still experiencing this issue with v2.0.2. Can you confirm whether this should of been resolved? Thanks.

Yes, 2.0.2 should have the fix.

Perhaps try re-installing your node_modules. What are your repro steps?

Thanks for the response @rgomezp !
Reinstalling node_modules made no difference but I was able to resolve the issue by reinstalling pods.
Really appreciate you getting back to me :-)