PaystackHQ / paystack-ios

Paystack SDK for iOS. Accept Payments on iOS
http://paystack.com
MIT License
26 stars 31 forks source link

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

Open BadMask121 opened 3 years ago

BadMask121 commented 3 years ago

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
IyiolaOwabumowa commented 3 years ago

Is there a solution ?

ravi-paystack commented 3 years ago

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

IyiolaOwabumowa commented 3 years ago

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 🙏

ThadeusAjayi commented 3 years ago

@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):

to: - Paystack (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.

jeshurun-io commented 2 months ago

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.