paystack-ios icon indicating copy to clipboard operation
paystack-ios copied to clipboard

'Paystack/Paystack-Swift.h' file not found

Open BadMask121 opened this issue 4 years ago • 5 comments

Problem/Motivation

Currently getting this error on build 'Paystack/Paystack-Swift.h' file not found Working with react native and paystack

Screenshot 2021-04-11 at 12 40 21 PM Screenshot 2021-04-11 at 12 41 23 PM

BadMask121 avatar Apr 11 '21 12:04 BadMask121

Is there a solution ?

IyiolaOwabumowa avatar May 25 '21 14:05 IyiolaOwabumowa

@IyiolaOwabumowa @BadMask121 thank you for reporting this. Can you provide more details regarding this issue like cocoapods version, Paystack SDK version, etc.

ravi-paystack avatar May 26 '21 07:05 ravi-paystack

Hi @ravi-paystack,

react-native: 0.63.4 react-native-paystack: ^3.4.0 CocoaPods: 1.10.1

I can send you my pod file as well if you need. I've been on this issue for over a week now.

Thank you 🙏

IyiolaOwabumowa avatar May 26 '21 14:05 IyiolaOwabumowa

@IyiolaOwabumowa What worked for me was more of a downgrade of paystack version running in react-native-paystack;

rm -rf node_modules Delete Pods folder under the ios folder Change paystack version in Podfile.lock file from: - Paystack (3.0.17): - Paystack/Core (= 3.0.17)

  • Paystack/Core (3.0.17)

to: - Paystack (3.0.13): - Paystack/Core (= 3.0.13)

  • Paystack/Core (3.0.13)

run npx pod-install

In case any other packages throw error in the iOS project, remove the package and re-add it.

I hope it works for you.

ThadeusAjayi avatar Jun 17 '21 20:06 ThadeusAjayi

Add this to the pod file to fix the issue:

  post_install do |installer|
    # Run the fixit script for Paystack before building it
    installer.pods_project.targets.each do |target|
      if target.name == 'Paystack'
        puts "Found Paystack! installing fixit script"
        script = target.new_shell_script_build_phase('Fix Paystack')
#        script.shell_script = '${PODS_ROOT}/../scripts/fix_paystack.sh'
        script.shell_script = <<-DESC
REAL_SWIFT_HEADER="${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h"
NEW_SWIFT_HEADER="$TARGET_BUILD_DIR/Paystack.framework/Headers/Paystack-Swift.h"
if [[ ! -e "$NEW_SWIFT_HEADER" ]]; then
  mkdir -p "$(dirname "$NEW_SWIFT_HEADER")" && ln -s "$REAL_SWIFT_HEADER" "$NEW_SWIFT_HEADER"
fi
DESC

        target.build_phases.unshift(target.build_phases.pop)
      end
    end
  end

The problem is that the Paystack target is unable to find the swift header when compiling from cocoapods because it is imported as a global header #import <Paystack/Paystack-Swift.h>. It should have been imported as #import "Paystack-Swift.h" to work in cocoapods. This fix sets up a fake framework in the framework search path and sets up the swift header using a symlink to the real swift header before compiling.

jeshurun-io avatar Jun 25 '24 21:06 jeshurun-io