klaviyo / klaviyo-react-native-sdk

MIT License
4 stars 3 forks source link

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

Closed yasicmd closed 7 months ago

yasicmd commented 7 months ago

Description

When I run the project using Xcode, I get the following error

'klaviyo_react_native_sdk-Swift.h' file not found

file path /Users/yasi/Appmaker/staging/node_modules/klaviyo-react-native-sdk/ios/KlaviyoReactNativeSdk.mm

I did the pod install and it shows in the Podfile.lock as below

- klaviyo-react-native-sdk (0.1.2):
    - KlaviyoSwift (= 3.0.2)
    - React-Core
- KlaviyoSwift (3.0.2):
    - AnyCodable-FlightSchool

Note
----
This issue happens in both my project and in the example project provided no error showned.

### Checklist

- [ ] I have determined whether this bug is also reproducible in a vanilla project
- [ ] If possible, I've reproduced the issue using the `master` branch of this package.
- [X] This issue hasn't been addressed in an [existing GitHub issue](https://github.com/klaviyo/klaviyo-react-native-sdk/issues) or [pull request](https://github.com/klaviyo/klaviyo-react-native-sdk/pulls).

### Expected behavior

```markdown
It should build the project after the pod install has been successfully done.

Actual behavior

'klaviyo_react_native_sdk-Swift.h' file not found

Steps to reproduce

No response

The Klaviyo React Native SDK version information

0.1.2

Environment Description

System:
  OS: macOS 14.1
  CPU: (8) arm64 Apple M1
  Memory: 92.23 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: ~/.nvm/versions/node/v18.16.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.nvm/versions/node/v18.16.0/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.0/bin/npm
  Watchman:
    version: 2024.01.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2021.3 AI-213.7172.25.2113.9123335
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.17
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.1
    wanted: 0.72.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Note
------
pod version : 1.15.2
ajaysubra commented 7 months ago

@yasicmd this was reported by another developer here and we believe this is a issue with your derived data. Could you please follow the instructions from that comment and let us know if that fixes it for you. Thanks!

evan-masseau commented 7 months ago

Hello, I am unable to reproduce this issue in a fresh clone of our SDK repo. Here are the exact steps I took, and the outcomes. Please note in particular the output from my npx react-native info, as your Environment has discrepancies from the expected environment for the Klaviyo React Native SDK.

Hope this helps. As Ajay referenced, cleaning your build folder and derived data would be a good first step, but I would also look closely at your environment.

bendrobinson1998 commented 6 months ago

Guys this still isn't fixed, It seems to be IOS only. Can you please reopen this and re address it? Ive been trying all the suggestions and my environment is as recceomnded.

ajaysubra commented 6 months ago

@bendrobinson1998 Sorry that you are still facing this issue. Unfortunately, we are unable to reproduce this issue on our end. Just to clarify the steps you've taken - Have you tried this suggestion?

Also, the developer who opened this issue recently notified us that they are all set and hence this issue was closed. If you still believe that this is an issue with the SDK, please open a separate issue with all the details specific to your setup and we will look into it.

bendrobinson1998 commented 6 months ago

Okay, so I have narrowed this down. When installing the package via Yarn or NPM there seems to be multiple methods missing from the package, such as the initialise function. When I clone the example app this is not the case. Please try replicating my bug on a fresh RN project and then install the SDK via yarn or NPM

yasicmd commented 6 months ago

@ajaysubra still the issue is not resolved fully i have to edit the file and use the provided temporary solution every time i install the sdk. Also I tried on a different system today but the issue is on that system also. I had to edit the file in the Klaviyo sdk to fix the issue.

Finally, to fix the issue i had to write a script to replace the import statement with the fixed import statement before every build to ensure smooth run.

So it will be better if you guys can find and fix this issue since other developers also having the issue.

ajaysubra commented 6 months ago

Thanks both for your response. @bendrobinson1998 I will try your steps to reproduce today and report back. In the meantime can you help me understand what you mean by,

multiple methods missing from the package, such as the initialise function

Since in the latest release 0.1.2 those methods are not available on the react native side.

@yasicmd can you please elaborate on what you mean by "provided temporary solution"?

bendrobinson1998 commented 6 months ago

Ah I see, so initialisation can only be done in the native code, not via Klaviyo.initialize? The README.md still states you can initialise via react native layer:

import { Klaviyo } from 'klaviyo-react-native-sdk';
Klaviyo.initialize('YOUR_KLAVIYO_PUBLIC_API_KEY');

Regardless, initialisiation or not I cannot get the project to build for IOS when using yarn/npm install, it is building fine for android. IOS outputs the missing swift file error.

ajaysubra commented 6 months ago

You are right in that the latest release of the react native SDK 0.1.2 can't do initialize from the react native layer but we are in the process of making a new release 0.2.0 that allows react native developers to initialize and setToken from the react native code. This is why you are seeing that instructions in the readme. Once this release this to NPM soon, you'll be able to use those methods by pulling in the SDK via NPM/Yarn. I know this can be confusing, one suggestion I can make is to refer the NPM page instead of the repo readme for the exact state of the SDK since the repo will be in active development most of the times where as the NPM page will be static to a given release.

However, this is seperate from the issue you are facing with the header and we will look into it and let you know if we are able to reproduce it on our end. At the moment, our best suggestion is this.

yasicmd commented 6 months ago

@yasicmd can you please elaborate on what you mean by "provided temporary solution"?

https://github.com/klaviyo/klaviyo-react-native-sdk/pull/78/files

bendrobinson1998 commented 6 months ago

However, this is seperate from the issue you are facing with the header and we will look into it and let you know if we are able to reproduce it on our end. At the moment, our best suggestion is this.

I have attempted this but it does not fix my issue.

ajaysubra commented 6 months ago

@yasicmd Just to be clear the PR you referenced isn't a solution we provided. The developer who opened that PR isn't a Klaviyo developer.

ajaysubra commented 6 months ago

@bendrobinson1998 We've tried to reproduce this on our end building a new app and installing the SDK like you suggested but still we are not able to reproduce this. Here are the commands I used if it's helpful -

npx react-native@latest init AwesomeProject1
cd AwesomeProject1
npm install klaviyo-react-native-sdk
cd ios
pod install
open AwesomeProject1.xcworkspace // will open xcode for you
npm start
// run the app on xcode 15.0

Unfortunately, at this point there are no indications that this is an issue with the SDK. One thing that we did discover is that there is an issue with cocoapods version 1.15.0 so if you are on this version please consider updating. Sorry we couldn't be of much help here. Good luck!

CC: @yasicmd

yasicmd commented 6 months ago

My pod version: 1.15.2

And my Xcode version: 15.0.1

The other system versions are pod : 1.15.0 Xcode: 15.2

youcefswoo commented 6 months ago

what worked for me is to replace #import <klaviyo_react_native_sdk-Swift.h> by #import <klaviyo_react_native_sdk/klaviyo_react_native_sdk-Swift.h>

ajaysubra commented 6 months ago

FYI folks, please look at this issue for info on the fix for this issue. TLDR- use release 0.2.1 (our latest at the time of writing this comment) to resolve this issue.