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.
Related
I'm creating a react-native module I would like for this custom module to import another pod, specifically AFNetworking.
How do I go about this?
What I've done:
Adding pod 'AFNetworking', '~> 4.0' to my project's Podfile
Added s.dependency "AFNetworking" in my custom module's podspec
import "AFNetworking.h" in MyModule.mm
I get the error Expected unqualified-id
I've tried all variations of
#import “../../../Pods/AFNetworking/AFNetworking.h”
#import "AFNetworking.h"
#import "AFNetworking/AFNetworking.h"
#import <AFNetworking.h>
#import <AFNetworking/AFNetworking.h>
None of which seem to work
This does the trick
#import <AFNetworking/AFNetworking.h>
See What is the difference between #include <filename> and #include "filename"?
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.
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
I'm very new to iOS and I'm coming from the Android background. I've read many post about this issue but I'm unable to resolve this issue.
My problem is that the app runs fine on the iPhone simulator but while running on the device it gives me following error -
error: 'AFNetworking.h' file not found
#import "AFNetworking.h"
^
<unknown>:0: error: failed to import bridging header ‘path/to/project/<main project directory>/projectName-Bridging-Header.h'
Update:
platform :ios, '7.0'
use_frameworks!
target 'SomeTarget' do
pod 'AFNetworking'
pod 'MSDynamicsDrawerViewController'
pod 'KRLCollectionViewGridLayout', '~> 0.2.0'
pod 'Canvas'
pod 'MBProgressHUD'
pod 'RBMenu'
pod 'RKTabView'
pod 'AHTabBarController'
pod 'Fabric'
pod 'Crashlytics'
end
My Bridging Header File
#import "AFNetworking.h"
#import "UIKit+AFNetworking.h"
#import "MSDynamicsDrawerStyler.h"
#import "KRLCollectionViewGridLayout.h"
#import "Canvas.h"
#import "MBProgressHUD.h"
#import "UIScrollView+TwitterCover.h"
#import "A3ParallaxScrollView.h"
#import "ParallaxHeaderView.h"
#import "UIImage+ImageEffects.h"
#import "SGFocusImageFrame.h"
#import "RBMenu.h"
#import "ILBarButtonItem.h"
#import "CMPopTipView.h"
#import "RKTabView.h"
#import "AHTabBarController.h"
#import "UIViewController+MJPopupViewController.h"
#import "NSString+FontAwesome.h"
#import “KMAccordionTableViewController.h"
#import <Crashlytics/Crashlytics.h>
Can you please point the issue I'm getting right now. Why it is running fine on emulator and not on actual device?
This might help somebody.
I've fixed this issue by adding an entry for Header Search Paths to "${PODS_ROOT}/" with recursive. Thanks to lostInTransit for pointing this attribute.
You can find Header Search Paths under BuildSettings for your project target.
I am following this github project : Here.In that they mentioned to do :
Cocoapods
CocoaPods is the recommended way to add PNChart to your project.
Add a pod entry for PNChart to your Podfile pod 'PNChart'
Install the pod(s) by running pod install.
Include PNChart wherever you need it with #import "PNChart.h".
What i did is :
start the new project and add all frame works.
then i use terminal to create podfile like ( touch podfile )
then i move to my project folder to podfile file and i add this code
pod 'PNChart', '~> 0.8.7'
Then i use pod install to run .
then i add PNChart folder to my project, after that when i build i am not able to see my graph.
But when i download their project from github , then when i see their podfile file .its like this below code:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '6.0'
pod 'UICountingLabel','~> 1.2.0'
target :PNChartTests do
pod 'Expecta'
end
But when i copy these files to my podfile and when i run pod install in terminal . i am getting error no PNChartTest are seen
What i need to do first to work with line graph. please some one guid me to do,thanks!
UPDATED:
Error occur in this file : PNRadarChartDataItem.h- this file will be inside the PNChart folder
#import <Foundation/Foundation.h>
#interface PNRadarChartDataItem : NSObject
+ (instancetype)dataItemWithValue:(CGFloat)value
description:(NSString *)description;
#property (nonatomic) CGFloat value;
#property (nonatomic,copy) NSString *textDescription;
#end
3 error :
error in this line + (instancetype)dataItemWithValue:(CGFloat)value
description:(NSString *)description
error : Expected a type
error in this line - (void)setValue:(CGFloat)value {
error : Expected a type
error in this line #property (nonatomic) CGFloat value;
error : unknow type name cgfloat
Create new project.
Right click on 'Xcode project' in Xcode project navigator and choose others & empty file name 'Podfile' and select the destination as project directory level (Podfile should be at the xcodeproject file level) and add following lines
pod 'PNChart'
Close xcodeproject
Go to project directory and run the 'pod install' command from the termial
Open workspace i.e. .xcworkspace file
Import charts file in view controller such as
#import "ViewController.h"
#import "PNChart.h"
Added sample project here.