4

For further information

Summarizing the problem

  • The problem I am having is that I have configured a react-native package (react-native-square-in-app-payments) in Xcode, but I am getting an error saying that 'module xxx not found'.

The question, is:

  • Why doesn't Xcode find the 'missing' module? What is not configured properly? Where should I look to check?

The error is the following

Module 'SquareInAppPaymentsSDK' not found

enter image description here

My podfile:

platform :ios, '11.0'

target 'myproject' do
  use_frameworks!

  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNSquareInAppPayments', :path => '../node_modules/react-native-square-in-app-payments'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == 'React'
        target.remove_from_project
      end
    end
  end

end

My project.pbxproj file (couldn't attach it here, but you can access it in github):

https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-625333601

Update: Linking (following the 1st comment and @DenisTsoi answer) below

I tried automatic linking (as noted, I need it since I am using RN 0.59.9), and then I started again and tried manual linking, for both I have the same error. You can see my comments about this in https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-625330210

BTW, under 'link binary with libraries' I have two entries of the package:

Comment to @MuhammadNuman answer below:

I tried your podfile in a new react-native project (created by react-init). When I add

import { SQIPCore } from 'react-native-square-in-app-payments';

I get the error described in https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-629762613

You may find my repo in https://github.com/rahamin1/square_with-podfile

Yossi
  • 5,577
  • 7
  • 41
  • 76
  • If you’re running rn 0.60+ the app should auto Link most rn dependencies, however pre 60+ you need to link it manually. – Denis Tsoi May 10 '20 at 11:22
  • I know and I did, thank you! – Yossi May 10 '20 at 14:53
  • did it help or no? - also did the answer below help? – Denis Tsoi May 10 '20 at 14:56
  • Didn't. Just added few lines about it in the bottom of my question. – Yossi May 10 '20 at 15:04
  • can you do us a favour and make a minimal repo (nothing else, just be able to reproduce this error on a separate example repo please) - it'll take us forever to set something up that wont be the same as your RN settings – Denis Tsoi May 10 '20 at 15:10
  • I did create a minimal repo with 0.59.9 and it didn't have any problems... :( Sure, upvoted. I appreciate the effort and your time. My feeling, BTW, that an answer to the question written here may lead to the solution. Just a feeling... https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-625898377 – Yossi May 10 '20 at 15:13
  • did you follow this step 3a or 3b? https://github.com/square/in-app-payments-react-native-plugin/blob/master/docs/get-started.md#step-3a-add-the-in-app-payments-sdk-to-your-ios-project-without-cocoapods https://github.com/square/in-app-payments-react-native-plugin/blob/master/docs/get-started.md#step-3b-add-the-in-app-payments-sdk-to-your-ios-project-with-cocoapods – Denis Tsoi May 10 '20 at 15:14
  • you might have to pod install if you haven't already – Denis Tsoi May 10 '20 at 15:15
  • looks like youve installed it as well... hmmmmm – Denis Tsoi May 10 '20 at 15:21
  • Right you are :) I have been doing almost everything in the last 2 weeks. I am looking for a wizard who will find the problem in one of my configuration files (e.j project.pbxproj) and help. – Yossi May 10 '20 at 16:40

3 Answers3

3

I have faced this type of error in the past. Because some configuration things were missing or broken which leads these type of issues. So my suggestion for you is to create a new react-native project install all the library in the package.json one by one from the NPM or GitHub document of there library. and then copy the code from src (React Code) into the new project. If you have any changes inside the ios and android folder then only copy the changes from the file and paste to the file of the new project android/ios folder. (If nothing works then apply this solution. it always works for me)

Pankaj Negi
  • 1,558
  • 1
  • 16
  • 23
  • Seems that this is best advise I got so far. I will try it and update here. I am marking this as the accepted answer, since the other one is something that I tried before posting the question (and it didn't work). – Yossi May 14 '20 at 14:02
  • And, indeed, this solved the problem, but I am facing now another problem: https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-629762613 – Yossi May 26 '20 at 18:01
  • @Yossi I think square app-payments-react-native-plugin have an issue with there library I was also getting the same issue.in. – Pankaj Negi May 27 '20 at 14:00
  • Waiting for their response in the above github issue – Yossi May 27 '20 at 20:09
2

According to your github issue link,

You’re running react 0.59.x. This means you’ll be required to run

react-native link

For native libraries to be linked in iOS XCode.

An alternative method is linking the dependency in XCode, which can be found on the react native docs

Excerpt

Step 1 If the library has native code, there must be an .xcodeproj file inside its folder. Drag this file to your project on Xcode (usually under the Libraries group on Xcode);

step 1

Step 2 Click on your main project file (the one that represents the .xcodeproj) select Build Phases and drag the static library from the Products folder inside the Library you are importing to Link Binary With Libraries

step 2

Step 3 Not every library will need this step, what you need to consider is: Do I need to know the contents of the library at compile time? What that means is, are you using this library on the native side or only in JavaScript? If you are only using it in JavaScript, you are good to go! If you do need to call it from native, then we need to know the library's headers. To achieve that you have to go to your project's file, select Build Settings and search for Header Search Paths. There you should include the path to your library. (This documentation used to recommend using recursive, but this is no longer recommended, as it can cause subtle build failures, especially with CocoaPods.) 

step 3

For RN 0.60+ linking is done automatically.

Edit:

You can also install the SDK with cocoapods via the command in the directory <YOUR_PROJECT_DIRECTORY>/ios

pod install
Denis Tsoi
  • 9,428
  • 8
  • 37
  • 56
1

You can also clone and test boilerplate for react-native 0.59.9

https://github.com/nomi9995/in-app-payments-0.59.9.git

change your podfile

platform :ios, '11.1'

target 'myproject' do
  use_frameworks!

  rn_path = '../node_modules/react-native'
  pod 'React', path: rn_path, subspecs: [
  'CxxBridge',
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket',
  'RCTAnimation',
  'RCTActionSheet',
  'RCTGeolocation',
  'RCTImage',
  'RCTSettings',
  'RCTVibration',
  'RCTLinkingIOS'
  ]
  pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'RNSquareInAppPayments', :path => '../node_modules/react-native-square-in-app-payments'


end

and install podfile againt

pod install
Muhammad Numan
  • 23,222
  • 6
  • 63
  • 80
  • Thanks @MMuhammadNuman ! But I used the same RNSquareInAppPayments pod. – Yossi May 16 '20 at 16:34
  • are you using pod 'React', path: rn_path, subspecs: [ 'CxxBridge', 'RCTText', 'RCTNetwork', 'RCTWebSocket', 'RCTAnimation', 'RCTActionSheet', 'RCTGeolocation', 'RCTImage', 'RCTSettings', 'RCTVibration', 'RCTLinkingIOS' ] – Muhammad Numan May 16 '20 at 18:15
  • can you check my boilerplate? – Muhammad Numan May 16 '20 at 18:16
  • First of all, I would like to say that I appreciate your reply. Thank you! For 1st question: I am not using them. For the 2nd: I didn't, since my problem is not with boilerplates. I have a boilerplate with the 2 square plugins which is working. The problem is making it work with my app. – Yossi May 16 '20 at 20:18
  • @Yossi please pod 'React', path: rn_path, subspecs: [ 'CxxBridge', 'RCTText', 'RCTNetwork', 'RCTWebSocket', 'RCTAnimation', 'RCTActionSheet', 'RCTGeolocation', 'RCTImage', 'RCTSettings', 'RCTVibration', 'RCTLinkingIOS' ]try this – Muhammad Numan May 16 '20 at 21:13
  • See comment to this in my question, at the bottom. – Yossi May 17 '20 at 16:52