React-native/iOS app: Module 'SquareInAppPaymentsSDK' not found, although it has been added to the project - xcode

For further information
I have posted this also in https://github.com/square/in-app-payments-react-native-plugin/issues/66#issuecomment-623619907 - you can find more details there.
The installation instructions of the package I am having problems with are in https://github.com/square/in-app-payments-react-native-plugin/blob/master/docs/get-started.md
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
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:
SquareInAppPaymentsSDK.framework (as requested in https://developer.squareup.com/docs/in-app-payments-sdk/installation#option-3-install-the-in-app-payments-sdk-manually)
libRNSquareInApppayments.a (part of linking)
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

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)

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 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 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.) 
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

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

Related

No podspec found for `FBReactNativeSpec` in `../node_modules/react-native/Libraries/FBReactNativeSpec`

I have upgrade react-native to 0.64 and I'm getting this error after I run pod install.
No podspec found for `FBReactNativeSpec` in `../node_modules/react-native/Libraries/FBReactNativeSpec`
I have tried to remove the node_module, remove the pod file, deintegrate, but still got this issue.
Any help?
The newer version of ReactNative (starting from 0.64) store FBReactNativeSpec in another folder.
You will need to replace the legacy FBReactNativeSpec path with the new one in the Pod declaration.
Open your Podfile and find this line :
pod 'FBReactNativeSpec', :path => "./node_modules/react-native/Libraries/FBReactNativeSpec"
And fix the path by replacing with this one :
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/React/FBReactNativeSpec"
While I am updating to the new react-native version 0.64.1,then I got the above-mentioned error when I tried pod install.I have fixed the issue by replacing the content on my podfile like the following
https://raw.githubusercontent.com/react-native-community/rn-diff-purge/release/0.64.1/RnDiffApp/ios/Podfile
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'RnDiffApp' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
target 'RnDiffAppTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
I changed my podfile like the above.Then I tried pod install on my terminal.Its working fine.
Try npx react-native-clean-project
Input 'Y' for all the prompts asked.
I had the same question these days and found out it was because of the command npm audit fix i ran. It automatically updated react native version, which made podfile somehow confused. Downgrade your rn package or reset your version control should work

Why do I get this error: 'import of module appears within namespace' on xcode with react-native?

I got this react-native project and I had to use use_modular_headers! on Podfile. I suppose I needed that because this pod MercadoPagoSDK is some sort of dynamic library (╯°□°)╯ which I don't really know what that means on iOS development world.
Now I'm getting this error during build on xcode!
import of module 'glog.glog.log_severity' appears within namespace 'google'
I am not finding a solution to this user_modular_headers! thing. I already tried all ideas from here https://github.com/google/glog/issues/393 but I am afraid none of them worked.
Make sure to add the following code to your podfile, including the modular_headers part:
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
for more information check out the full thread here: https://github.com/facebook/react-native/issues/26217

Unable to install AFNetworking and Google-Maps-iOS-Utils together

I need to use Afnetworking and google-maps-ios-utils both in my project but using pods it is not possible. because Afnetworking don't work if I comment # use framework! in my pod file and google-maps-ios-utils don't work if I uncomment it.
I tried manually installing google-maps-ios-utils but it still give me error related to bridging header.
Is there any way to use both library together.
Or how to install AFnetworking or google-maps-ios-utils manually to avoid this clash.
I need some alternative for google-maps-ios-utils because it is only works if I comment #use_frameworks! in pod file , and if I comment it most of other library such as FBSDKLoginKit and SDWebimage get error.
Xcode 10, swift 4.
Have you try this on your pod file like below,
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
def share_pods
# Pods for your target name
pod 'AFNetworking', '~> 3.0'
pod 'GoogleMaps'
end
target 'your target name' do
share_pods
end
Hope it's help you:)

"No such module 'Firebase'" when add Firebase into a library

I just created new Framework and added Firebase via CocoaPods, when combine the library it success.
But when I add that library to other project via CocoaPods as well, then combine that project, and it raise an error: No such module 'Firebase'
Anyone faced a problem like this?
You need to add the follwing to your POD file:
pod 'Firebase'
After that, you need to type in your terminal
pod install (to refresh the pod file)
I solve my problem using just the specific import that I'm using, for example.
In my SDK I'm using FirebaseCore and FirebaseAnalytics.
Into my class I just import:
import FirebaseCore
import FirebaseAnalytics
And in my .podspec I needed to set static_framework property to true, so my .podspec it's seems like code below:
s.static_framework = true
s.dependency 'Firebase'
s.dependency 'Firebase/Core'
It works for me!
Do you open the workspace file after installed with cocoa pods ?
Check if the library is added in "Linked Frameworks" or "Embedded Binaries"
If it didn't work, add this pod file
platform :ios, '8.0' use_frameworks! target ‘Your Project’ do
pod 'Firebase', '>= 2.5.1'
pod ‘Firebase/Auth’
pod ‘Google/SignIn’
pod ‘Firebase/Database’
pod 'Firebase/Storage' end
and then type pod deintegrate and after that run pod install.
tried all these..
I was stuck in this situation for more than 2weeks.
finally resolved by adding "excluded architectures = arm64"
this is the easiest solution nowadays
Everything was setup fine and was working before but..
My Problem:
What's was wrong with me?
I was using older name of pod, eg. - pod 'Firebase/Analytics', pod 'Firebase/Crashlytics'
New pod names are pod 'FirebaseAnalytics', pod 'FirebaseCrashlytics' (Problem with / )
Solution:
Use new pod name to integrate pod 'FirebaseAnalytics', pod 'FirebaseCrashlytics' (Install pod with new pod name)
Import import FirebaseCore, import FirebaseAnalytics instead just import Firebase
import FirebaseAnalytics - I'm using for log events
Hi today i fix same problem
1 : open podfile from xcode than add " pod 'Firebase' "
save and close it
2 : open vscode or any editor using, open new terminal than write " cd ios " to open ios file than " pod install " when you install it showing problem need to add search path
so now open ios file from xcode and go to : runner > target runner > build settings > all > search paths
and add this " $(inherited) " into framework search path and header search path
that's all
For me I had to change the version specified in the Podfile as it was above what my app supported. Specifically in the Podfile I changed: 'platform :ios, '11.0' to platform :ios, '10.0' which corresponds with Deployment Info in the General Tab for my app I'm working on.
For Flutter folks adding Firebase to their apps, make sure you follow the steps in Add Firebase to your iOS Project as well as those in the SDK setup steps in the Firebase Console:
In summary:
Run pod init if you don't have a pod file
Add the necessary pods to the bottom of the podfile. All possible Firebase pods can be found here.
pod 'Firebase/Analytics'
pod 'Firebase/Firestore'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
Run pod install
This issue can be caused by incorrectly set-up schemes:
If you have multiple schemes (e.g. 'Dev', 'QA', 'Production' etc.) in your project, check you have the build configurations set correctly.
Further guidance in this answer here:
https://stackoverflow.com/a/65453578/12322900
Then run pod deintegrate and pod install and make sure you're using the .xcworkspace file.
My failure was that I downloaded modules to
target 'YourProjectUITests' do
# Pods for testing
pod 'FirebaseCore'
And the right one is
# Pods for YourProject
pod 'FirebaseCore'
(Without UITests)
It is because you don't have added pod dependency in Podfile.
you will find below line in Podfile
Uncomment this line to define a global platform for your project
#platform :ios, '9.0'
follow the below steps.
1)just remove the # .so it will be like.
platform :ios, '9.0'
2)add the below dependencies.(Do not add all ,you just need to add whatever used in you app ,if you have used Firebase/Core only then add that line only)
#Pods for app name
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
3)clean the build
flutter clean
4)run Command :
flutter run (It will automatically adds a required pods).
that's it.
The same thing happened to me last week. I solved it by:
1. pod deintegrate
2. Open Xcode and delete any instance of pod.
3. pod install

Kiwi and CocoaPods with a static shared library

I have a workspace with 3 projects:
MyApp
Common
Pods
Common is a common library that MyApp depends on. I'd like to setup CocoaPods and Kiwi to work correctly in this project. How do I go about this?
I found https://stackoverflow.com/a/16472563/62, but when I try to follow this approach, I get an error when building MyApp before I even try adding Kiwi:
ld: library not found for -lPods
Here's the repo on GitHub: https://github.com/lyahdav/cocoapods_kiwi_shared_library
My Podfile is:
workspace 'MyApp.xcworkspace'
platform :ios, '7.0'
target 'Common' do
xcodeproj 'Common/Common.xcodeproj'
pod 'AFNetworking'
pod 'Reachability'
target 'MyApp', :exclusive => true do
xcodeproj 'MyApp.xcodeproj'
end
end
I finally found a working solution for this. Here's the Podfile:
platform :ios, '7.0'
workspace 'MyApp.xcworkspace'
xcodeproj 'MyApp'
pod 'CupertinoYankee', '~> 1.0'
target :MyAppTests, :exclusive => true do
pod 'Kiwi/XCTest'
end
target :Common, :exclusive => true do
xcodeproj 'Common/Common'
pod 'CupertinoYankee', '~> 1.0'
end
target :CommonTests, :exclusive => true do
xcodeproj 'Common/Common'
pod 'Kiwi/XCTest'
end
This example Podfile shows both MyApp and Common configured to use Kiwi for tests and they can both use pods (CupertinoYankee in this example).
I did manually have to configure in Xcode that MyApp links with Common with these steps:
In MyApp project settings > MyApp target > Build Phases > Link
Binary With Libraries > add libCommon.a
In MyApp project settings > Build Settings > User Header Search Paths > add ${SRCROOT}/Common/Common/**
This repo has a working example: https://github.com/lyahdav/cocoapods_kiwi_shared_library
The only slightly annoying thing I didn't manage to figure out was if there's a way to not duplicate each pod that I want to use both in MyApp and Common. If anyone has a solution that does all of what my solution does and solves that, I'll gladly mark it the accepted answer.
Posted as an edit by anonymous user. Here's his answer:
I have forked the repository and made few changes for new cocoapods versions to make it still working.
platform :ios, '8.0'
workspace 'MyApp.xcworkspace'
project 'MyApp'
target :MyApp do
pod 'CupertinoYankee', '~> 1.0'
end
target :MyAppTests do
pod 'Kiwi/XCTest'
end
target :Common do
project 'Common/Common'
pod 'CupertinoYankee', '~> 1.0'
end
target :CommonTests do
project 'Common/Common'
pod 'Kiwi/XCTest'
end
https://github.com/chrishunterkiller/cocoapods_kiwi_shared_library
I'm not sure how to fix the setup you have, but if I were you I would make Common into its own Pod. Pods can be private and just stored in GitHub as a repo. Of course, you need a podspec for Common but I built a sample to test that setup for our build service and it took me less than 30 mins to get it right.
Then in your Podfile for MyApp, you do something like this:
pod 'Common', :git => 'git#github.com:lyahdav/Common.git', :commit => 'a1b2c3d'
And AFNetworking and Reachability can be referenced in the podspec of Common (assuming that's the right dependency).
This setup also allows you to include Common in whatever other apps you're building without having to embed the code. Again, making assumptions about what you're trying to achieve, so add more detail to the question if that's not right.
You could hack a solution that may get broken again, or better yet as Common is your library, start using CocoaPods for your Common library as well.
It will show up as a local "Dvelopment Pod", which means that you can directly edit the library code as well.
To begin easily just create a Common.podspec at the root folder:
$ pod lib create Common
Then just edit the minimum required parameters, such as platform, source_files, requires_arc and dependency if any.
You can take a look at how your library looks as you change it (and compare it to what you had with your manually created Common library):
$ pod lib lint --no-clean Common.podspec
Finally remove the no-longer needed Common from your workspace and add this to your Podfile:
pod 'Common', :path => '../Relative/Path/To/CommonSources/'
It will take you no more than 30 minutes and you'll learn many things in the process.
Next you could take a look at making private pod repositories.

Resources