klaviyo / klaviyo-react-native-sdk

MIT License
2 stars 3 forks source link

'klaviyo_react_native_sdk-Swift.h' file not found #129

Closed niklavsBariss closed 4 months ago

niklavsBariss commented 4 months ago

Checklist

Description

Using version klaviyo-react-native-sdk 0.2.0 and React Native 0.71.13

After a successful `pod install` trying to launch an app on Xcode(15.2) simulator results in: 

../node_modules/klaviyo-react-native-sdk/ios/KlaviyoReactNativeSdk.mm:2:9 'klaviyo_react_native_sdk-Swift.h' file not found

Steps to reproduce

  1. yarn add klaviyo-react-native-sdk

  2. Add code to Podfile

    MIN_IOS_OVERRIDE = '13.0'
    if Gem::Version.new(MIN_IOS_OVERRIDE) > Gem::Version.new(min_ios_version_supported)
    min_ios_version_supported = MIN_IOS_OVERRIDE
    end
  3. pod install

  4. Run from XCode or yarn ios

I tried doing the same with a clean react native 0.71.13 project, but didn't have the same issue.

The Klaviyo React Native SDK version information

0.2.0

Environment Description


OS: macOS 14.3
CPU: (10) x64 Apple M1 Pro
Node: 18.19.0
Yarn: 1.22.17
CocoaPods: 1.15.2
Xcode: 15.2/15C500b
react: 18.2.0
react-native: 0.71.13
ajaysubra commented 4 months ago

Hey @niklavsBariss thanks for reporting this issue to us. We have had other users report this as well and we've tried extensively to reproduce this on our end and we've not succeeded. Based on our research we believe this is probably something to do with derived data with xcode local dev setup. Here's a suggestion we've been making to our developers since we are not able to reproduce it ourselves. Please let us know if the above suggestion works for you. Good luck!

niklavsBariss commented 4 months ago

Thank you for responding @ajaysubra but no success - I tried Clean Build Folder, fully restarting Xcode, completely deleting Derived data of the project, but the issue persists.

To help me troubleshoot: which file should be imported by #import <klaviyo_react_native_sdk-Swift.h>?

bendrobinson1998 commented 4 months ago

Just to note I’m still getting the same error, albeit I use expo.

niklavsBariss commented 4 months ago

The fix proposed by youcefswoo in #78 works for me

raynox commented 4 months ago

I'm facing the same issue on React Native 0.73.2 and klaviyo-react-native-sdk 0.2.0. I tried Clean Build Folder, closing xCode and reinstalling the package, but still the same issue. Any other ideas how to fix it?

raynox commented 4 months ago

I think in my case the issue is related to using additionally @react-native-firebase/messaging as mentioned in the documentation to handle requesting permissions and collecting push tokens. When installing just klaviyo-react-native-sdk the issue does not occur in my case. Any ideas why there is that issue together with the firebase package?

bendrobinson1998 commented 4 months ago

I think in my case the issue is related to using additionally @react-native-firebase/messaging as mentioned in the documentation to handle requesting permissions and collecting push tokens. When installing just klaviyo-react-native-sdk the issue does not occur in my case. Any ideas why there is that issue together with the firebase package?

My project also uses @react-native-firebase , maybe a clash is happening with this library when building?

package.json below if helps:

{ "name": "...", "version": "1.0.0", "main": "expo-router/entry", "scripts": { "start": "expo start", "android": "expo run:android", "ios": "expo run:ios", "web": "expo start --web" }, "dependencies": { "@apollo/client": "^3.9.5", "@react-native-firebase/app": "^18.5.0", "@react-native-firebase/functions": "^18.5.0", "@react-native-picker/picker": "2.6.1", "@react-navigation/material-bottom-tabs": "^6.2.16", "@react-navigation/native": "^6.1.7", "@react-navigation/stack": "^6.3.17", "@rneui/base": "^4.0.0-rc.7", "@rneui/themed": "^4.0.0-rc.8", "@shopify/flash-list": "1.6.3", "apollo-link-rest": "^0.9.0", "expo": "50", "expo-blur": "~12.9.2", "expo-build-properties": "~0.11.1", "expo-constants": "~15.4.5", "expo-crypto": "~12.8.1", "expo-dev-client": "~3.3.8", "expo-device": "~5.9.3", "expo-linking": "~6.2.2", "expo-localization": "~14.8.3", "expo-notifications": "~0.27.6", "expo-router": "~3.4.7", "expo-splash-screen": "~0.26.4", "expo-status-bar": "~1.11.1", "expo-system-ui": "~2.9.3", "firebase": "^10.4.0", "graphql": "^16.8.1", "native-notify": "^3.0.6", "onesignal-expo-plugin": "^2.0.2", "qs": "^6.11.2", "react": "18.2.0", "react-native": "0.73.4", "react-native-dropdown-picker": "^5.4.6", "react-native-gesture-handler": "~2.14.0", "react-native-marquee": "^0.5.0", "react-native-mmkv": "^2.10.2", "react-native-onesignal": "^5.0.6", "react-native-paper": "^5.10.1", "react-native-reanimated": "~3.6.2", "react-native-reanimated-carousel": "^3.5.1", "react-native-safe-area-context": "4.8.2", "react-native-screens": "~3.29.0", "react-native-toast-message": "^2.1.6", "react-native-vector-icons": "^10.0.0", "react-native-webview": "13.6.4", "zustand": "^4.4.1" }, "devDependencies": { "@babel/core": "^7.20.0" }, "engines": { "node": ">= 18.0.0" }, "private": true }

ajaysubra commented 4 months ago

Thank you for responding @ajaysubra but no success - I tried Clean Build Folder, fully restarting Xcode, completely deleting Derived data of the project, but the issue persists.

To help me troubleshoot: which file should be imported by #import <klaviyo_react_native_sdk-Swift.h>?

Hi @niklavsBariss sorry that didn't work. klaviyo-react-native-sdk-Swift.h is a xcode generated file that exposes swift interfaces to objective-c code. In our case that's KlaviyoBridge.swift that is imported by KlaviyoReactNativeSDK.mm

I've been looking into this and I may have stumbled upon some official apple docs which suggests to use what #78 suggests but in the meantime can either of you please check what Generated Header Name for klaviyo-react-native-sdk is in your Pods target? When I check our react native test project it says klaviyo-react-native-sdk-Swift.h.

Just to be clear, I'm not suggesting any fixes yet just still in the discovery process and trying to understand why our test app succeeds while some of our customers have reported failures.

image

niklavsBariss commented 4 months ago

@ajaysubra same as yours

image
niklavsBariss commented 4 months ago

We decided to use #78 with patch-package for now with some heavy, test enforced TODO check after updating

niklavsBariss commented 4 months ago

I think in my case the issue is related to using additionally @react-native-firebase/messaging as mentioned in the documentation to handle requesting permissions and collecting push tokens. When installing just klaviyo-react-native-sdk the issue does not occur in my case. Any ideas why there is that issue together with the firebase package?

We are also using firebase messaging I would add firebase to my clean test app to test this theory, but the installation is quite involved

raynox commented 4 months ago

It's the same for both cases, when klaviyo-react-native-sdk is installed alone or with @react-native-firebase/messaging

Zrzut ekranu 2024-03-5 o 18 22 16
raynox commented 4 months ago

@ajaysubra would you need anything else from our side to help you investigate the issue?

ajaysubra commented 4 months ago

Hey folks, we have narrowed down the issue to firebase react native, specifically this step in the setup. Adding use_frameworks! :linkage => :static to your podfile makes importing our SDK as a framework as well and hence the import that we have needs to be #import <klaviyo_react_native_sdk/klaviyo_react_native_sdk-Swift.h> as some of you have pointed out. The reason we were unable to reproduce was we were not importing our SDK as a framework and when you do that your import statement has to be #import <klaviyo_react_native_sdk-Swift.h>.

The good news is we know what the issue is and are able to reproduce it. As I mentioned this is related to using firebase react native SDK and how it has some instructions that change the way our SDK is imported by cocoapods. The bad news is we have users who do not use frameworks and we also need to support them as well. We are exploring solutions and will update once we have one. Unfortunately, I don't have an exact timeline of when we'll have a solution but know that we are actively working on this. Thanks!

ajaysubra commented 4 months ago

As an update, created #132 PR to address this issue. Totally optional, but if any of y'all want to test it out below are the steps.

  1. npm install git@github.com:klaviyo/klaviyo-react-native-sdk.git#38fb354a34da1b6e8edaa7f25e98f48daf0b73de in the root directory of your project
  2. pod install in the ios directory of your project.
  3. Open Xcode and try to run your iOS project.

We will go through the review process and merge the PR in and we are working through another issue so we might batch the release. Will keep y'all posted when we release the fixes. Thanks for your patience with this issue.

bendrobinson1998 commented 4 months ago

Totally optional, but if any of y'all want to test it out below are the steps.

Tested and working great, thank-you!

ajaysubra commented 4 months ago

This issue is now fixed and is part of release 0.2.1. Thanks for all your patience with this.