Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all 16567 articles
Browse latest View live

How come my image is not showing - react native

$
0
0

I was wondering why my image is not showing, I have tried several things but still can not find the solutions, I have compared it to several tutorials. What I want is for my image to be in the background with my two buttons on the bottom, over the image. I am using react native, with the IDE 'Deco' for apps. Right now there is no image showing at all.

  import React, { Component } from 'react';
import { Button,Alert, TouchableOpacity,Image, Dimensions } from 'react-native'

import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';

class Project extends Component {
  render() {
    return (
      <View style={{backgroundColor: '#375D81', flex: 1}}>
        <Image source={{uri: 'https://upload.wikimedia.org/wikipedia/commons/f/f0/Everest_North_Face_toward_Base_Camp_Tibet_Luca_Galuzzi_2006_edit_1.jpg'}}/>
         <View style = {styles.container}>
           <TouchableOpacity style = {styles.buttonText1} onPress={() => { Alert.alert('You tapped the button!')}}>
             <Text style={styles.text}> 
              Button 1
             </Text>
           </TouchableOpacity>

           <TouchableOpacity style = {styles.buttonText2} onPress={() => { Alert.alert('You tapped the button!')}}>
             <Text style= {styles.text}>
              Button 2
             </Text>
           </TouchableOpacity>

        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
 main: {
   backgroundColor: 'blue'
 },
 text: {
 alignItems : 'center'

 },
 container: {
  alignItems: 'center',
  flex: 1,
 },
  buttonText1: {
      borderWidth: 1,
      padding: 25,      
      borderColor: 'black',
      backgroundColor: '#C4D7ED',
      alignItems: 'center',
      position: 'absolute',
      bottom: 0,
      width: Dimensions.get('window').width / 2,
      height: Dimensions.get('window').height / 8,
      left: 0,
   },
    buttonText2: {
      borderWidth: 1,
      padding: 25,      
      borderColor: 'black',
      backgroundColor: '#C4D7ED',
      alignItems: 'center',
      position: 'absolute',
      bottom: 0,
      width: Dimensions.get('window').width / 2,
      height: Dimensions.get('window').height / 8,
      right: 0,
   }
});

AppRegistry.registerComponent('Project', () => Project);

Thank you in advance.


React Native invalid podfile "No such file or directory - ./node_modules/.bin/react-native."

$
0
0

In my react native project react-native@60.5 in the iOS dir I get this issue when running a pod install

[!] Invalid `Podfile` file: No such file or directory - ./node_modules/.bin/react-native.

 #  from /Users/username/appname/ios/Podfile:44
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

This is a React Native fresh init from >@60.0; All worked perfect until I cleared my cache and installed node_modules with the following commands - this may have not been necessary or a good move on my part.

watchman watch-del-all && 
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ 
&& npm cache clean --force &&
npm install && 
npm start -- --reset-cache

Here is my podfile

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'XXX' do
  # Pods for XXX
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  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'

  # Required by RNFirebase
  pod 'Firebase/Core', '~> 6.3.0'
  pod 'Firebase/Auth', '~> 6.3.0'
  pod 'Firebase/Firestore', '~> 6.3.0'

  pod 'GoogleIDFASupport', '~> 3.14.0'
  pod 'Fabric', '~> 1.10.2'
  pod 'Crashlytics', '~> 3.13.2'

  target 'XXXTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end

target 'XXX-tvOS' do
  # Pods for XXX-tvOS

  target 'XXX-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

Here is my package.json

{
  "name": "XXX",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@gigasz/react-native-sketch-canvas": "github:jramalho/react-native-sketch-canvas",
    "@react-native-community/async-storage": "1.6.1",
    "@react-native-community/geolocation": "2.0.2",
    "@react-native-community/netinfo": "4.2.0",
    "@react-native-mapbox-gl/maps": "7.0.1",
    "@turf/turf": "5.1.6",
    "awaity": "1.0.0",
    "base-64": "0.1.0",
    "d3-scale": "3.1.0",
    "deepmerge": "4.0.0",
    "jetifier": "^1.6.4",
    "mobx": "5.13.0",
    "mobx-react": "6.1.3",
    "moment": "2.24.0",
    "prop-types": "15.7.2",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-device-info": "2.3.2",
    "react-native-firebase": "5.5.6",
    "react-native-fs": "2.14.1",
    "react-native-gesture-handler": "1.4.1",
    "react-native-image-picker": "1.1.0",
    "react-native-image-progress": "1.1.1",
    "react-native-indicators": "0.13.0",
    "react-native-masked-text": "1.13.0",
    "react-native-modal-datetime-picker": "7.5.0",
    "react-native-paper": "2.16.0",
    "react-native-pdf": "5.1.4",
    "react-native-shake": "3.3.1",
    "react-native-status-bar-height": "2.4.0",
    "react-native-svg": "9.8.4",
    "react-native-svg-charts": "5.3.0",
    "react-native-vector-icons": "6.6.0",
    "react-navigation": "4.0.0",
    "react-navigation-material-bottom-tabs": "1.1.1",
    "react-navigation-stack": "^1.5.1",
    "rn-fetch-blob": "0.10.16",
    "uuid": "3.3.3"
  },
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/runtime": "7.5.5",
    "@react-native-community/eslint-config": "0.0.5",
    "babel-jest": "24.9.0",
    "babel-plugin-transform-remove-console": "6.9.4",
    "eslint": "6.3.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.54.1",
    "react-test-renderer": "16.8.6"
  },
  "jest": {
    "preset": "react-native"
  }
}

My CI build system still works fine with the same podfile and package.json

Any help will be appreciated!

react native rebuild .bin folder in node modules

$
0
0

Cause of could not follow symbolic link error after upgrading react native from 0.59.4 to 0.60.4, i should remove .bin folder. The problem is solved on android version but in iOS, when i use pod install pod says :

[!] Invalid `Podfile` file: No such file or directory - ./node_modules/.bin/react-native.

 #  from /path-to-project/ios/Podfile:40
 #  -------------------------------------------
 #  
 >    use_native_modules!
 #  end
 #  -------------------------------------------

Is there any way to rebuild .bin folder?

Could you please help me?

Thanks

Firebase iOS stuck at 'Run your app to verify installation'

$
0
0

React Native Firebase installation for iOS gets held up at the "Run your app to verify installation" screen.

React Native Firebase has worked on Android for me before.

I followed these instructions.

https://rnfirebase.io/docs/v5.x.x/installation/ioshttps://firebase.google.com/docs/ios/setup#add_the_sdk

Here are what I've done so far.

-Set up a project within Firebase.google.com page.

-Create an iOS app there.

-Install react-native-firebase via npm.

-Add GoogleService-Info.plist file to the project within XCode.

-Make changes to ios/[YOUR APP NAME]/AppDelegate.m file.

-Creat a new Podfile (Cocoa pod) and updated it by "pod update" command.

-Add and edited lines to the Podfile per the instruction.

-Run "pod install"

-Run "react-native link react-native-firebase" from the project root.

-Click "Next" button within Firebase console and move on to "Run your app to verify installation" section.

-Run the iOS app on simulator by running "react-native run-ios" command.

The app boots up and functions as normal in the simulator.

Nothing happens in the Firebase page.

This is the first couple of lines of my Podfile.

# Uncomment the next line to define a global platform for your 
project
platform :ios, '9.0'

# Required by RNFirebase
pod 'Firebase/Core', '~> 5.20.1'

target 'My_App_Name' do

Where to start with native app using Firebase

$
0
0

I am looking to build an app where registered users can fill out a form (with some fields already prefilled for different forms) and then submit the form.

Users will need to be authenticated on the app. I'm thinking that Firebase might be best suited for the data, but not sure where to start as for the actual development and am looking for some advice. Do I use Flutter, React or another?

Is there any examples where anyone could point me to?

Thanks

Call a function in Swift from React Native (Native Modules)

$
0
0

I'm trying to get a hang on react native and native modules but I'm stuck for a few days now. I tried with this tutorial: https://teabreak.e-spres-oh.com/swift-in-react-native-the-ultimate-guide-part-1-modules-9bb8d054db03#b780

I want to call the function testfunction() in my Bridge.swift file, when I click a button in my React Native project. The function just needs to print "test" in the xcode console.

Bridge.swift

import Foundation
import UIKit

@objc(Bridge)
class Bridge : NSObject {
  @objc
  func testfunction(){
    print("test")
  }
}

Bridge.m

#import "React/RCTBridgeModule.h"

@interface RCT_EXTERN_MODULE(Bridge, NSObject)

RCT_EXTERN_METHOD(testfunction)
@end

Playground-Bridging-Header.h

#import "React/RCTBridgeModule.h"

Snippet of the button in App.js

<TouchableOpacity
   style={styles.button}       
   onPress={() => NativeModules.Bridge.testfunction()}>
   <Text>TEST</Text>
</TouchableOpacity>

When I click the button, nothing is printed in the console.

Sidenote: My project is called Playground.
It has a Today Widget target called PlaygroundWidget. The Bridge.swift file is located in this PlaygroundWidget folder, this is because this file will contain methods that will be called from the TodayViewController for the widget.
I needed to put the Bridge.m file in the Playground folder otherwise it couldn't resolve "React/RCTBridgeModule.h".

I'm using React Native 0.61 and xCode 11.1

Is there a way to run code from an Iphone app to another Iphone App?

$
0
0

So I know that we can use URL schemes to OPEN an app from an app, but that's not my objective.

Say I want to make an Iphone app which users can download and click a button which will launch another app ( eg.gmail for this case) and run some sort of front-end actions. For example, make the icons bigger, change colors, change the UI, highlight stuff, add pop-up text, etc. Just to re-terate, I'm not trying to modify any code on the gmail app it self. I want to code my app to do certain actions that can be "applied" or "faked" in the view of the other app.

I was thinking there could be a virtual button ideally (like the virtual assist on the iphone) that would popup on the gmail app. I'm not trying to change any functionalities or gmail's code, just want to to be able to modify the front-end experience.

Chrome extensions are easy to use in this case since you can open any site and change anything once user launches extension on the page, but is there something similar to IOS?

React Native PDF Signature

$
0
0

I’m trying to implement a pdf digital signature component for a react-native app.

I am using react-native-pdf for rendering the pdf on the screen and react-native-draggable for dragging the signature on top of the pdf view.

With react-native-draggable I can get the position of the signature on the screen but not related to the position on the pdf document.

Is there a way I can get/calculate the vertical position on the pdf?

I have to take into account different screen sizes, different pdf sizes, and different and variable margins. It looks more or less like this Refer to this image

Any formula/algorithm you can point as help is appreciated.


Expo ImagePicker crashed on IOS Gallery not opening

$
0
0

When I try to use expo imagepicker, the application freezes, opens the gallery or the camera and they close immediately, this only happens to me on ios, on android it works perfectly.

I hope someone can help me.

This is my code

  getPermissionAsync = async () => {
    if (Constants.platform.ios) {
      const { status } = await Permissions.askAsync(Permissions.CAMERA, Permissions.CAMERA_ROLL);
      if (status !== "granted") {
        alert(
          "Lo sentimos, necesitamos permisos de cámara para hacer que esto funcione!"
        );
      }
    }
  };

  _pickImage = async type => {
    let result = null;
    if (type == "galeria") {
      result = await ImagePicker.launchImageLibraryAsync({
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
        quality: 0.5,
        base64: true
      });
    } else {
      result = await ImagePicker.launchCameraAsync({
        mediaTypes: ImagePicker.MediaTypeOptions.Images,
        quality: 0.5,
        base64: true
      });
    }

    if (result != null && !result.cancelled) {
      let arr = this.state.imagenesAdjuntas;
      arr.push(result);
      this.setState({ imagenesAdjuntas: arr });
    }
  };

These are the dependencies

"dependencies": {
    "@expo/vector-icons": "^10.0.3",
    "expo": "^33.0.0",
    "expo-asset": "^6.0.0",
    "expo-barcode-scanner": "~5.0.1",
    "expo-blur": "~5.0.1",
    "expo-constants": "~5.0.1",
    "expo-font": "~5.0.1",
    "expo-image-picker": "~5.0.2",
    "expo-linear-gradient": "^5.0.1",
    "expo-mail-composer": "~5.0.1",
    "expo-permissions": "~5.0.1",
    "expo-secure-store": "~5.0.1",
    "firebase": "^7.2.1",
    "prop-types": "^15.7.2",
    "react": "16.8.3",
    "react-dom": "^16.8.6",
    "react-native": "https://github.com/expo/react-native/archive/sdk-33.0.0.tar.gz",
    "react-native-animated-hide-view": "^1.0.0",
    "react-native-banner-carousel": "^1.0.3",
    "react-native-elements": "^1.2.6",
    "react-native-flip-card": "^3.5.5",
    "react-native-gesture-handler": "~1.2.1",
    "react-native-maps": "~0.24.0",
    "react-native-modal": "^11.1.0",
    "react-native-render-html": "^4.1.2",
    "react-native-smtp-mailer": "^1.2.1",
    "react-native-table-component": "^1.2.0",
    "react-native-web": "^0.11.4",
    "react-navigation": "^3.11.0",
    "sharp": "^0.22.1"
  },
  "devDependencies": {
    "babel-preset-expo": "^5.1.1"
  },

This is the app.json

{
  "expo": {
    "name": "App Name",
    "slug": "appname",
    "privacy": "public",
    "sdkVersion": "33.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "loading": {
      "icon": "./assets/icon.png",
      "hideExponentText": false
    },
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#0088AD"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "packagerOpts": {
      "assetExts": [
        "ttf",
        "mp4",
        "otf",
        "xml",
        "html",
        "js"
      ]
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.company.name"
    },
    "android": {
      "package": "com.company.name",
      "config": {
      }
    },
    "description": ""
  }
}

I will put the following to fill

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

How to gracefully stop react-native run-ios?

$
0
0

I see a lot of process is started when I run this command

npx react-native run-ios

But I don't see any command like stop-ios. Looks like I have to kill all the process manually like Simulator, Metro bundler, etc.

I'm using Mac. Is there any alternative for this ? For both iOS and Android

React native client returns different data from API GET request that the browser

$
0
0

I'm pinging iTunes lookup API to get latest version of my application. My browser does return the proper version, whereas when I do fetch request from within my React Native application it returns previous version as the latest. Is there any chance some RN configs compromising my requests? I know that the data may be updating within 24 hours after uploading new version to Apple store, but it's weird that my browser(even the browser on IOS emulator) returns proper version. Thank you in advance

Integrating react native project into existing iOS app

$
0
0

i'm trying to integrate react native project into existing iOS app with this tutorial and everything were fine and i was managed to run the iOS app but after few tries with different project, the iOS app give me error below

2019-11-05 17:30:51.901 [info][tid:main][RCTCxxBridge.mm:236] Initializing <RCTCxxBridge: 0x7fc003600000> (parent: <RCTBridge: 0x600001845260>, executor: (null))
2019-11-05 17:30:51.902302+0800 JD_SDK[18656:187123] Initializing <RCTCxxBridge: 0x7fc003600000> (parent: <RCTBridge: 0x600001845260>, executor: (null))
2019-11-05 17:30:51.927 [info][tid:main][RCTRootView.m:293] Running application TestProject ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-11-05 17:30:51.927406+0800 JD_SDK[18656:187123] Running application TestProject\^Q ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-11-05 17:30:52.007 [info][tid:com.facebook.react.JavaScript] Running application "TestProject" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
2019-11-05 17:30:52.007524+0800 JD_SDK[18656:187288] Running application "TestProject\^Q" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
2019-11-05 17:30:52.008 [error][tid:com.facebook.react.JavaScript] Application TestProject has not been registered.

Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before.
If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start').

This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent.


2019-11-05 17:30:52.008503+0800 JD_SDK[18656:187288] Application TestProject\^Q has not been registered.

Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before.
If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start').

This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent.
2019-11-05 17:30:52.011 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: Application TestProject has not been registered.

Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before.
If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start').

This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent.


2019-11-05 17:30:52.011177+0800 JD_SDK[18656:187250] Unhandled JS Exception: Application TestProject\^Q has not been registered.

Hint: This error often happens when you're running the packager (local dev server) from a wrong folder. For example you have multiple apps and the packager is still running for the app you were working on before.
If this is the case, simply kill the old packager instance (e.g. close the packager terminal window) and start the packager in the correct app folder (e.g. cd into app folder and run 'npm start').

This error can also happen due to a require() error during initialization or failure to call AppRegistry.registerComponent.
2019-11-05 17:30:52.014618+0800 JD_SDK[18656:187123] -[AppDelegate window]: unrecognized selector sent to instance 0x600003154200
2019-11-05 17:30:52.015 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "TestProject\u0011" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON' }
2019-11-05 17:30:52.026262+0800 JD_SDK[18656:187288] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "TestProject\u0011" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON' }
2019-11-05 17:30:52.026869+0800 JD_SDK[18656:187123] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate window]: unrecognized selector sent to instance 0x600003154200'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23c4f02e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50b97b20 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23c6ff94 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKitCore                           0x00007fff4787df59 -[UIResponder doesNotRecognizeSelector:] + 302
    4   CoreFoundation                      0x00007fff23c53b56 ___forwarding___ + 838
    5   CoreFoundation                      0x00007fff23c55f38 _CF_forwarding_prep_0 + 120
    6   JD_SDK                              0x0000000101c0411d -[RCTRedBoxWindow bottomSafeViewHeight] + 125
    7   JD_SDK                              0x0000000101c027ff -[RCTRedBoxWindow initWithFrame:] + 623
    8   JD_SDK                              0x0000000101c076a4 __55-[RCTRedBox showErrorMessage:withParsedStack:isUpdate:]_block_invoke + 468
    9   libdispatch.dylib                   0x0000000102ab3dd4 _dispatch_call_block_and_release + 12
    10  libdispatch.dylib                   0x0000000102ab4d48 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x0000000102ac2de6 _dispatch_main_queue_callback_4CF + 1500
    12  CoreFoundation                      0x00007fff23bb1df9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    13  CoreFoundation                      0x00007fff23baca59 __CFRunLoopRun + 2329
    14  CoreFoundation                      0x00007fff23babe16 CFRunLoopRunSpecific + 438
    15  GraphicsServices                    0x00007fff38438bb0 GSEventRunModal + 65
    16  UIKitCore                           0x00007fff4784fb68 UIApplicationMain + 1621
    17  JD_SDK                              0x0000000101ac67ad main + 125
    18  libdyld.dylib                       0x00007fff51a1dc25 start + 1
    19  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

This is the code in my ViewController.m

#import "ViewController.h"
#import <React/RCTRootView.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)highScoreButtonPressed:(id)sender {
    NSURL *jsCodeLocation = [[NSBundle mainBundle] URLForResource: @"main" withExtension:@"jsbundle"];

    RCTRootView *rootView =
      [[RCTRootView alloc] initWithBundleURL: jsCodeLocation
                                  moduleName: @"TestProject"
                           initialProperties: nil
                               launchOptions: nil];
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view = rootView;
    [self presentViewController:vc animated:YES completion:nil];
}

@end

The module name, "TestProject" is definitely same with the app name of the react native project. Any idea what is going wrong?

React native localizations: Global variable

$
0
0

I am new to React, and I come from the world of iOS/Android where localized strings are all defined in dedicated files. I have looked into react-native-localization and it seems like we need to define the strings object in each class and then use the values in the rendering. This seems to be quite inefficient and fragmented to me, or maybe I have misunderstood the usage. I haven't been able to find good examples of the usage of react-native-localization. I'd really appreciate some guidance.

React-Native: React could not be found within project or in these directories

$
0
0

We have upgraded our react native project to the latest react native version (v0.61.2) with react (16.9.0) and it works perfectly fine on android. When we try to run it on ios thought, we get the message:

warning: the transform cache was reset. Loading dependency graph, done. error: bundling failed: Error: Unable to resolve module `React` from `ios/Pods/React/Libraries/react-native/react-native.js`: React could not be found within the project or in these directories:   node_modules

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*

We have followed the upgrade guide, updated all dependencies to their latest version and updated the pods. I actually don't know where or how to start debugging this, since this seems to be coming from the Pods folder.

This is the content of our Pods folder:

ls ios/Pods/
Adjust              GoogleDataTransport
Crashlytics         GoogleDataTransportCCTSupport
DoubleConversion        GoogleUtilities
Fabric              Headers
Firebase            Local Podspecs
FirebaseABTesting       Manifest.lock
FirebaseAnalytics       Pods.xcodeproj
FirebaseAnalyticsInterop    Protobuf
FirebaseCore            Pushwoosh
FirebaseCoreDiagnostics     PushwooshInboxUI
FirebaseCoreDiagnosticsInterop  React
FirebaseDynamicLinks        Target Support Files
FirebaseInstanceID      boost-for-react-native
FirebaseRemoteConfig        glog
Folly               nanopb
GoogleAppMeasurement

and in our node_modules folder, we have (with a lot more other packages):

...
react
depd                        react-deep-force-update
des.js                      react-devtools-core
destroy                     react-is
detect-libc                 react-lifecycles-compat
detect-newline              react-native
...

I have, of course, tried all the steps, like clearing caches, reset-cache, clearing DerivedData, Clean and build, ... I don't know where to start looking.

Apple HealthKit getSleepSample returns 0

$
0
0

I am trying to pull the sleep data from the Health app using react native. However every time I run it the getSleepSample return 0. My code for this is below.

let options = {
  startDate: (new Date(2019,10,25)).toISOString(),
  endDate: (new Date(2019,11,10)).toISOString(),
  limit: 10,
  permissions: {
      read: ["Height", "Weight", "StepCount", "DateOfBirth", "BodyMassIndex", "ActiveEnergyBurned", "SleepAnalysis"],
      write: ["Height", "Weight", "StepCount", "BodyMassIndex", "Biotin", "Caffeine", "Calcium", "Carbohydrates", "Chloride", "Cholesterol", "Copper", "EnergyConsumed", "FatMonounsaturated", "FatPolyunsaturated", "FatSaturated", "FatTotal", "Fiber", "Folate", "Iodine", "Iron", "Magnesium", "Manganese", "Molybdenum", "Niacin", "PantothenicAcid", "Phosphorus", "Potassium", "Protein", "Riboflavin", "Selenium", "Sodium", "Sugar", "Thiamin", "VitaminA", "VitaminB12", "VitaminB6", "VitaminC", "VitaminD", "VitaminE", "VitaminK", "Zinc", "Water"]
  }};

  componentDidMount(){
    AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => {
      if (err) {
          console.log("error initializing Healthkit: ", err);
          return;
      }
    AppleHealthKit.getSleepSamples(options, (err: Object, results: Array<Object>) => {
      if (err) {
        console.log(err);
        return;
      }
      console.log(results.length)
      this.setState({sleep:results.length})
    }); 
  });
  }

I am not sure if the problem is with the dates or the way I am calling the method. I have tried it with the getStepCount method and that works fine.


React Native Bluetooth LE Advertising

$
0
0

I'm building an application using React Native that is running on both iOS and Android. I need to be able to advertise but I don't see any libraries that have that functionality for cross-platform. Here is one library I found but it's only for iOS.

Are there libraries I'm just not seeing or what other approach can I take?

Thanks

"Invalid Date" in React Native on real device only [duplicate]

$
0
0

This question already has an answer here:

In my React Native app I am displaying the following in a Text string:

moment(new Date('2019-02-02 7:00:00')).format('h:mm A')

This works fine in an emulator, but returns "Invalid Date" on a real iOS device.

Does anyone know why this is happening and how I could resolve it?

React Native: How to make emulator have local settings?

$
0
0

I'm using Date objects in my React Native app, and read that some of the settings in these objects might vary from country to country. I'm getting slightly different behaviour on my . real device compared to my iOS emulator, and want to make sure my emulator is set to the same country as my real device. Does anyone know how to control which country your emulator is set to?

Export Datas from react-native app to csv

$
0
0

I've been trying to export datas from react-native app to a csv file for a few days but unsuccessfully.

I need to create a cross-plateform app that cat get some data from user even without any network. When the tablet is connected to internet, I have to sync it with my server.

My question is how to save my data even when I close the app or reboot the tablet.

Please excuse my English ;) Thanks

How to make emulator have local settings?

$
0
0

I'm using Date objects in my React Native app, and read that some of the settings in these objects might vary from country to country. I'm getting slightly different behaviour on my . real device compared to my iOS emulator, and want to make sure my emulator is set to the same country as my real device. Does anyone know how to control which country your emulator is set to?

Viewing all 16567 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>