Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable install in expo #129

Open
kunsachdeva opened this issue May 4, 2023 · 16 comments
Open

Unable install in expo #129

kunsachdeva opened this issue May 4, 2023 · 16 comments

Comments

@kunsachdeva
Copy link

kunsachdeva commented May 4, 2023

Steps to repro:

  1. Init a new expo project
  2. npx expo prebuild to expose native code
  3. Install react-native-mparticle yarn add react-native-mparticle
  4. Add mParticle to Podfile pod 'mParticle-Apple-SDK', '~> 8'
  5. npx expo run:ios to run in iOS simulator

This leads to a buildtime error:
Screenshot 2023-05-04 at 1 29 36 PM


› Planning build
› Compiling Pods/mParticle-Apple-SDK » MPUploadBuilder.mm
› Compiling Pods/mParticle-Apple-SDK » MPStateMachine.mm
› Compiling Pods/mParticle-Apple-SDK » MPSurrogateAppDelegate.m
› Compiling Pods/mParticle-Apple-SDK » MPTransactionAttributes.m

❌  (node_modules/expo-modules-core/ios/Swift.h:5:9)

  3 | // The generated swift header may depend on some Objective-C declarations,
  4 | // adding dependency imports here to prevent declarations not found errors.
> 5 | #import <ExpoModulesCore/EXDefines.h>
    |         ^ 'ExpoModulesCore/EXDefines.h' file not found
  6 | #import <ExpoModulesCore/RCTComponentData+Privates.h>
  7 | 
  8 | // When `use_frameworks!` is used, the generated Swift header is inside ExpoModulesCore module.

› Compiling Pods/mParticle-Apple-SDK » MPSearchAdsAttribution.m
› Compiling Pods/mParticle-Apple-SDK » MPSession.m
› Compiling Pods/mParticle-Apple-SDK » MPResponseConfig.m
› Compiling Pods/mParticle-Apple-SDK » MPPromotion.mm
› Compiling Pods/mParticle-Apple-SDK » MPResponseEvents.mm
› Compiling Pods/mParticle-Apple-SDK » MPProduct.mm

Am I missing a step?

@mazenchami
Copy link

@kunsachdeva were you able to solve this? we're running into the same issue but we're not in an expo managed project (using expo packages) (cc: @morganick)

@kunsachdeva
Copy link
Author

Yes, you need specify an older version
pod 'mParticle-Apple-SDK', '~> 8.12.0'
Let me know if this helps @mazenchami

@morganick
Copy link

@kunsachdeva That worked! 🎉

🙇 I was banging my head on this for hours last week.

@einsteinx2
Copy link

Quick update on this. We're tracking this internally as https://go.mparticle.com/work/SQDSDKS-5410

Version 8.13.0 was the first version where we added Swift support, which seems to be causing the incompatibility here. We never actually officially supported Expo, it just happened to work before when we were pure Objective-C. We recognize that some people are using Expo and are working to officially support it.

For now, please pin to version 8.12.0 as was mentioned above, and I'll update this ticket when we have a new release out that is compatible with Expo, then you can begin using the latest 8.x.x versions again. Apologies for the frustration.

@rikur
Copy link

rikur commented Dec 13, 2023

@einsteinx2 are the new versions expo compatible?

@dylmye
Copy link

dylmye commented Jan 24, 2024

Bumping this, would appreciate an update @BrandonStalnaker (as It seems Ben is no longer at mParticle)

@dylmye
Copy link

dylmye commented Mar 19, 2024

I'm pretty close to completing a config plugin - will share it here when done

@BrandonStalnaker
Copy link
Contributor

@dylmye I would greatly appreciate that. Compatibility with our latest versions is currently being looked into. Though as Ben said Expo has never been officially supported.

@dylmye
Copy link

dylmye commented Mar 21, 2024

Thank you @BrandonStalnaker - currently Android is working perfectly (though users will need to fork the package to add kits eg Appboy), iOS my only blocker is mParticle/mparticle-apple-sdk#265.

I'm planning to maintain this expo plugin (which I have made public now: https://github.com/dylmye/config-plugin-react-native-mparticle - do you need me to add a disclaimer that it's unofficial or anything?) but if y'all ever want to take it over I will be more than happy to transfer ownership!

@dylmye
Copy link

dylmye commented Mar 26, 2024

It's looking good, thanks for your help again Brandon. I'm still stuck using v8.12.0 of the iOS SDK but I'm going to chase up the specific error encountered by OP with Expo to see if they can shed any further light.

edit: tracking here expo/expo#27875

@dylmye
Copy link

dylmye commented Apr 2, 2024

Expo have replied: expo/expo#27875 (comment)

They suggest that importing Swift.h is causing namespace conflict issues. Is this something you think your team would be willing to fix or does that cause further issues?

@tsalama
Copy link

tsalama commented Apr 22, 2024

Official support for this would be extremely helpful; I assume most production apps that utilize mParticle for analytics are using expo nowadays.

@dylmye Thanks for your contribution with the config plugin. Is it currently stable and working with SDK 50?

@dylmye
Copy link

dylmye commented Apr 23, 2024

@tsalama I've got the plugin working, give the sample app a spin and let me know if you come in to any issues :)

@tsalama
Copy link

tsalama commented Apr 23, 2024

@dylmye It's working for me! Thanks for your contributions 🙏

@mikeduminy
Copy link

mikeduminy commented Jun 4, 2024

According to Expo and my own testing all that is needed is to replace all Swift.h imports with the following:

#import <mParticle_Apple_SDK/Swift.h>

@einsteinx2 @BrandonStalnaker would you be open to a PR to that effect?

@brunofurmon
Copy link

brunofurmon commented Jul 3, 2024

I was able to make it work dynamically using this idea of import replacement using a post_install command here -> expo/expo#27875 (comment).

(As discussed above, this is not a fix)

I'm copying it here

post_install do |installer|
  require 'fileutils'

  # Directory where the mParticle-Apple-SDK files are located
  mp_dir = File.join(installer.sandbox.root, 'mParticle-Apple-SDK')

  # Ensure we can write to the directory and its files
  FileUtils.chmod_R('u+w', mp_dir)
  
  # Recursively search for all files and replace "Swift.h"
  Dir.glob(File.join(mp_dir, '**/*')).each do |file|
    next unless File.file?(file) # Skip directories
    
    # Read the content of the file
    text = File.read(file)
    new_text = text.gsub('#import "Swift.h"', '#import <mParticle_Apple_SDK/Swift.h>')
    
    # If there are changes, update the file
    if text != new_text
      # Write the new content back to the file
      File.open(file, 'w') { |f| f.puts new_text }
    end
  end

  # Restore original permissions
  FileUtils.chmod_R('u+w', mp_dir)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants