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

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

Related

Can't add "MidiParser" pod to Podfile

I am trying to add this github project to my project as a pod: https://github.com/matsune/MidiParser
In my PodFile, I have tried
pod 'MidiParser'
and
pod 'MidiParser', :git => 'https://github.com/matsune/MidiParser.git'
but either time I get the error
Unable to find a specification for 'MidiParser'.
I have tried adding other pods like 'https://github.com/daltoniam/SwiftHTTP' just to see if they work, and they do. I notice there are multiple projects on GitHub called MidiParser, so maybe I need to distinguish between them somehow? The installation instructions in the MidiParser README only give instructions for Carthage. It says to add this line to the Cartfile:
github "matsune/MidiParser"
I also have also tried:
pod 'matsune/MidiParser'
I notice I can't find the project when I search for it here: https://cocoapods.org.
Does that mean I simply can't install the project using Cocoapods, and that I have to do it manually?
Edit: I ended up using Carthage.
CocoaPods requires pods to be specified with a podspec to describe its Xcode workspace integration. See https://guides.cocoapods.org/making/making-a-cocoapod.html

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

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

module map file '/Users/"my_flutter_project_path"/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap' not found?

I'm trying to run my flutter project via xcode on real device.But
getting this error module map file '/Users/"my_flutter_project_path"/ios/Pods/Headers/Private/openssl_grpc/BoringSSL-GRPC.modulemap' not found
I browsed for this error and got this_gitHub_issue_solution and followed it but can't get solution.
The CocoaPods 1.9.0, the capability to specify dynamic/static linkage for each pod in the Podfile should get it better. It introduced the use of use_frameworks! :linkage => :static which is an even better approach than use_modular_headers!.

SDK image not found when running OSX UI Tests with Cocoapods

I am trying to add my first automated UI tests to my application and am running into quite a bit of difficultly.
The app will build in its current state and the main application itself runs just fine. However, when I try to run my tests I get the following error:
2016-08-02 19:39:33.340 XCTRunner[17590:966857] Running tests...
2016-08-02 19:39:33.407 XCTRunner[17590:966857] The bundle “MYAPPUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-08-02 19:39:33.407 XCTRunner[17590:966857] (dlopen_preflight(/Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests): Library not loaded: #rpath/HockeySDK.framework/Versions/A/HockeySDK
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests
Reason: image not found)
I've seen that there are a few related questions on SO but none of them see to help me out.
Originally, I was implementing my tests in Swift on top of an Objective C application and thought that might be the problem. However, I discovered after making an Objective-C based test target that I am running into exactly the same issue in Objective C.
Thanks for any help.
EDIT
Some additional information: I have tried this using both Cocoapods 0.39.0 as well as the latest non-beta 1.x release. Both resulted in the same error.
My podfile is listed below (for 0.39.0)
platform :osx, '10.9'
link_with 'MYAPP', 'MYAPP MAS', 'MYAPPUITests'
pod 'AFNetworking', '~> 2.5.0'
pod 'ISO8601DateFormatter'
pod 'CDEvents', :git => 'https://github.com/rastersize/CDEvents'
pod 'MASShortcut', '1.3.1'
pod 'libPusher', '1.6'
pod 'NPReachability', :git => 'https://github.com/Abizern/NPReachability.git', :commit => 'e57753d'
pod 'CocoaLumberjack'
pod 'SocketRocket', :git => 'https://github.com/marianoabdala/SocketRocket.git'
pod 'HockeySDK-Mac'
pod 'INAppStoreWindow', '~> 1.4'
I was able to fix this after spending 2-3 days on this by adding an obscure step to my Build Phases.
I created a Copy Files build step after the Link Binary With Libraries step and before the Embed Pods Frameworks step.
I copied the offending framework ("HockeySDK") into the Products Directory. This solved the issue!
Ultimately this may be related to my app being a StatusBar App, not a regular app, as the solution which finally worked for me was related to a CommandLine application running into the same bug.
Link to Github bug page with the solution that worked for me

Using CocoaPods with Swift

I'm new to Cocoapods and am trying to use a pod named DateTools in my OS X app Swift project.
I installed Cocoapods, created the podfile, added pod 'DateTools' to it, ran pod install and everything seemed to work fine. (I'm a Ruby dev so I think I got this part right).
As asked by Cocoapods, I now opened my project using the new .xcworkspace file created. I correctly see two projects in Xcode: mine and Pods.
I added a sample model file to my project, let's call it SampleModel but in the code, when I do this:
let date = NSDate()
var year = date.year
I get the error: 'NSDate' does not have a member named 'year'. According to DateTools README, this should work.
As I'm new to both Xcode and Cocoapods, I can't figure out what is the likely error: DateTools not working with Swift or did I fail to import something, somewhere?
You need to import module into your source file
import DateTools
Also, by default is CocoaPods building static libraries - to use those you would need to configure bridging header. Easier way is to make it build dynamic framework by specifying so in Podfile (and run pod install):
use_frameworks!
pod 'DateTools'

Resources