Environment info
"react": "17.0.2",
"react-native": "0.66.3"
"react-native-maps": "^0.29.4"
XCode Version 13.1 (13A1030d)
macOS 12.0.1
Target Platform iOS 15.1 Phone using GoogleMaps
Steps to reproduce
Create new project
Add config = use_native_modules! in the Podfile
Add in the Podfile:
react-native-maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
pod install
Add in AppDelegate.m:
#import "AppDelegate.h"
#import <GoogleMaps/GoogleMaps.h>
#import <GooglePlaces/GooglePlaces.h>
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
[GMSServices provideAPIKey:#"xxxx"];
[GMSPlacesClient provideAPIKey:#"xxxx"];
}
Build in XCode
Describe what you expected to happen:
Build successful
Describe what you actually happens:
/ios/UbiWalkerReactNat/AppDelegate.m:2:9: 'GoogleMaps/GoogleMaps.h' file not found
you need to first import import <GoogleMaps/GoogleMaps.h> in AppDelegate.m see here.
Seems to be solved, there was a WARNING on pod install:
[!] The xxx [Debug] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-xxx-xxx/Pods-xxx-xxx.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the $(inherited)` flag, or
Remove the build settings from the target.
I've SOLVED with $(inherited) flag on Build Settings.
Related
This is app on react-native for ios, I want improve it with push-notifications using firebase. But it's crushes when i build project by command "react-native run-ios" or by xcode. I looked for solutions, but answer:
( - Open the terminal and go to your project ios directory
Type in pod init (If it doesn't exist) and then pod install
Open the workspace project and delete the build from ios folder
Run react-native run-ios from terminal.) - does not work for my project, also I tried command "pod update" it's also didn't help me.
I attach content of two files Podfile and AppDeligate.h, it might be problem with them.
#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 'appName' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
pod 'RNFBApp', :path => '../node_modules/#react-native-firebase/app'
pod 'RNFBMessaging', :path => '../node_modules/#react-native-firebase/messaging'
target 'appNameTests' 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 these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'appName-tvOS' do
# Pods for appName-tvOS
target 'appName-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
##AppDeligate.h
#import <React/RCTBridgeDelegate.h>
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
#property (nonatomic, strong) UIWindow *window;
#end
Your podfile deployment target is 10.0, Can you verify if thats the same target set in the project in Xcode. At times we run in this issue due to mismatch of the deployment target.
I started a new react native application using :
react-native init myApplication
I started with splash screen so i used this library react native spalsh screen
I linked the library to generate native code using this command :
react-native link react-native-splash-screen
And i added files using Xcode like this :
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-splash-screen and add SplashScreen.xcodeproj
In XCode, in the project navigator, select your project. Add libSplashScreen.a to your project's Build Phases ➜ Link Binary With Libraries
To fix 'RNSplashScreen.h' file not found, you have to select your project → Build Settings → Search Paths → Header Search Paths to add: $(SRCROOT)/../node_modules/react-native-splash-screen/ios
I build the app using Xcode in a real Iphone and i get this error in RNSplashScreen.h :
/**
* SplashScreen
* 启动屏
* from:http://www.devio.org
* Author:CrazyCodeBoy
* GitHub:https://github.com/crazycodeboy
* Email:crazycodeboy#gmail.com
*/
#import <React/RCTBridgeModule.h> // <------'React/RCTBridgeModule.h' file not found
#import <UIKit/UIKit.h>
#interface RNSplashScreen : NSObject<RCTBridgeModule>
+ (void)showSplash:(NSString*)splashScreen inRootView:(UIView*)rootView;
+ (void)show;
+ (void)hide;
#end
'React/RCTBridgeModule.h' file not found
the Podfile :
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
...... # other libaries
pod 'react-native-splash-screen', :path => '../node_modules/react-
native-splash-screen'
AppDelegate.m :
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNSplashScreen.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.... <------- other code
[RNSplashScreen show];
return YES;
}
Instead of
#import <React/RCTBridgeModule.h>
use
#import "RCTBridgeModule.h"
Hope this helps you. Feel free for doubts.
I'm trying to implement a share extension with a firebase-based app. So I have created a pod file and generated a .xcworkspace project.
I'm using [react-native-share-extension][1]. Followed all installation tutorial and all seem ok, but when I try to launch the extension Xcode console says:
RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects 'Podfile' and have run 'pod install'.
This is my pod file:
target 'Together' do
# Pods for Together
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/Storage'
pod "QBImagePickerController"
end
target 'TogetherShareEx' do
# Pods for TogetherShareEx
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
end
And this my TogetherShareEx.m:
#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>
#import <Firebase.h>
#interface TogetherShareEx : ReactNativeShareExtension
#end
#implementation TogetherShareEx
RCT_EXPORT_MODULE();
- (UIView*) shareView {
NSURL *jsCodeLocation;
[FIRApp configure];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:#"TogetherShareEx"
initialProperties:nil
launchOptions:nil];
rootView.backgroundColor = nil;
return rootView;
}
#end
I have also added these:
added '$(inherited)' in Other Linker Flags
added '$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase' in Header Search Paths
The result is that extension is created but when I try to share something, nothing happens. On Debugging the extension with Xcode the log shows the error shown above.
Any idea? Thanks
I was able to get this working after following the standard installation instructions, make sure you do the following:
Link libRNFirebase.a in your Extension's Build Phases. Also, make sure that libPods-{YOUR_EXTENSION_NAME}.a is linked as well.
Set the GoogleService-Info.plist target for both your main app
and your share extension in the right panel.
In your share extension's Build Settings > Other Linker Flags,
make sure you add $(inherited)
In your Share Extension .m file, make sure you import
Firebase and configure it there as well!
For more info, see the following GitHub thread: https://github.com/alinz/react-native-share-extension/issues/79
The Setup
I have successfully integrated the GoogleMaps SDK into my Swift 2 project using CocoaPods.
My setup is pretty much that suggested by the Ray Wenderlich tutorial on the subject.
The only difference I can find is, I have to add this line to AppDelegate:
import UIKit
import GoogleMaps // <- THIS LINE
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
...
...in order to use the framework's classes. The tutorial suggests importing:
#import <GoogleMaps/GoogleMaps.h>
...to the bridging header instead.
The app works without problems.
The Problem:
When I tried to run the test target auto-generated by Xcode, I get the error:
No such module 'GoogleMaps'
...pointing at the to the swift import statement in AppDelegate above.
So, I decide to switch to the way it is in the tutorial instead: I comment out the line import GoogleMaps in AppDelegate.swift and add an Objective-C-style import statement to the bridging header.
However, I can not get it right:
If I use: #import <GoogleMaps/GoogleMaps.h> or #import "GoogleMaps/GoogleMaps.h", it gives me:
Use of unresolved identifier 'GMServices'
at AppDelegate.swift when building the app target.
If I use: #import "GoogleMaps.h", it gives me:
'GoogleMaps.h': file not found
at the bridging header.
I have tried the solution in this answer, but the results are (puzzlingly) the same...?
Next, I checked the value of Build Settings / Search Paths / Framework Search Paths for both targets (app and tests). The app target had the entry:
"${PODS_ROOT}/GoogleMaps/Frameworks"
...which the test target lacked, so I added it, and reverted to the swift-style import (the only one that works at least when building the app target), but I still get:
import GoogleMaps <! No such module 'GoogleMaps'
How can I run tests for my app??
So, it turns out all I had to do is fix the Podfile (and run pod install), as explained in this answer.
My old pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
def import_pods
pod 'GoogleMaps'
end
workspace 'MyWorkspace'
xcodeproj 'MyApp/MyApp.xcodeproj'
target : MyApp do
xcodeproj 'MyApp MyApp.xcodeproj'
pod 'GoogleMaps'
end
My current pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.1'
def import_pods
pod 'GoogleMaps'
end
workspace 'MyWorkspace'
xcodeproj 'MyApp/MyApp.xcodeproj'
target 'MyApp', :exclusive => true do
xcodeproj 'MyApp/MyApp.xcodeproj'
import_pods
end
target 'MyAppTests', :exclusive => true do
xcodeproj 'MyApp/MyApp.xcodeproj'
import_pods
end
As suggest title, I need to use InstagramKit (3.5.0) pod (written in objective-c) in a new swift project.
So I install pod (pod install), then I create my InstagramSwift-Bridging-Header.h and add-import library:
#import <InstagramKit/InstagramEngine.h>
Then, just building this empty project, I get:
/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h:5:9:
note: in file included from
/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h:5:
-(BOOL)application:(UIApplication *)application
^ <unknown>:0:
error: failed to import bridging header
'/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h'
Expected a type Failed to import bridging header
'/Users/.../workspace/InstagramSwift/InstagramSwift/InstagramSwift-Bridging-Header.h'
What could I miss?
After a lot of discussions with #eric-d, I probably find the problem in my podfile that was:
target "InstagramSwift" do
pod 'InstagramKit', '3.5.0'
end
So I deleted project and start again from an empty project using Podfile:
use_frameworks!
platform :ios, '8.0'
pod 'AFNetworking', '~> 2.5'
pod 'InstagramKit', '3.5.0'
Than I manually created SwitBridge.h and linked it in build settings.
Finally, in any swift file I can use instagramKit module, for example:
import InstagramKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let instagramEngine: InstagramEngine = InstagramEngine.sharedEngine()
}
}
Probably, problem was that platform setting is missing.
edit
Also,
"use_frameworks!"
thanks to this answer.