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

weird image data on react native file upload on iOS

$
0
0
const data = new FormData();
    data.append('photo', {
      name: pic.fileName,
      type: pic.type,
      uri: Platform.OS === 'android' ? pic.uri : pic.uri.replace('file://', ''),
      // data: pic.data,
    });

this is the form data that i am sending to the backend. In the backend multer handles the image.

But i am getting the image data as below, that could not be used to store on the server folder

This is the response i am getting on the server side


Custom font not working in React Native

$
0
0

I want to use a font from google fonts in my app. Here is the font.

I have placed the .ttf file in app/fonts.

package.json:

{
    "name": "xxx",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "rnpm": {
        "assets": ["./app/fonts"]
    },
    "jest": {
        "preset": "react-native",
        "moduleNameMapper": {
            "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
            "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
        }
    },
    "dependencies": {
        "flow-typed": "^2.0.0",
        "immutable": "^3.8.1",
        "react": "~15.4.1",
        "react-native": "0.42.0",
        "react-native-vector-icons": "^4.0.0",
        "react-redux": "^5.0.3",
        "redux": "^3.6.0",
        "redux-immutable": "^4.0.0",
        "redux-observable": "^0.14.1",
        "rxjs": "^5.2.0"
    },
    "devDependencies": {
        "babel-eslint": "^7.1.1",
        "babel-jest": "19.0.0",
        "babel-preset-react-native": "1.9.1",
        "eslint": "^3.17.0",
        "eslint-plugin-flowtype": "^2.30.3",
        "eslint-plugin-jsx": "^0.0.2",
        "eslint-plugin-react": "^6.10.0",
        "eslint-plugin-react-native": "^2.3.1",
        "flow-bin": "^0.42.0",
        "jest": "19.0.2",
        "jest-cli": "^19.0.2",
        "react-test-renderer": "~15.4.1",
        "redux-devtools": "^3.3.2",
        "remote-redux-devtools": "^0.5.7"
    }
}

then ran react-native link.

Then use the font in my app:

import { View, Text } from 'react-native'
import React from 'react'
import Width from '../width/Width'
import Shape from '../shape/Shape'
import Height from '../height/Height'
import Thickness from '../thickness/Thickness'

export const Volcalc = () => (
  <View style={styles.container}>
    <Text style={styles.text}>SHAPE</Text>
    <Shape />
    <Text style={styles.text}>HEIGHT</Text>
    <Height />
    <Text style={styles.text}>WIDTH</Text>
    <Width />
    <Text style={styles.text}>THICKNESS</Text>
    <Thickness />
  </View>
)

const $mainColor = '#00d1b2'
const styles = {
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: $mainColor
  },
  text: {
    textAlign: 'center',
    color: 'rgba(255, 255, 255, 0.9)',
    fontSize: 15,
    fontFamily: 'Orbitron'
  }
}

In android it doesn't show the new font but has no error. In ios it has error:

Unrecognised font family "Orbitron"

What am I doing wrong?

How do I find out the EXACT value to place in fontFamily: 'xxx'?

firebase cloud messaging testing on iphone 6S (ios, xcode, react native)

$
0
0

I'm trying to test FCM push notifications on an iOS (iPhone 6S). I've got this working a month ago, but now I do not get it to work.

I'm using React Native Firebase v.5.x.x. I've followed the initial setup guide, the setup guid for cloud messaging and the setup guide for notifications. I also followed this manual on the firebase docs to set up APN certificates.

Now, when I use the editor on the firebase console to send a notification, I do not get any response from my app. This is my react native code in my app.

    const run = async () => {
        const enabled = await firebase.messaging().hasPermission()
        console.log('firebase', enabled)
        if (enabled) {
            // user has permissions
            console.log(await firebase.messaging().getToken())
        } else {
            // user doesn't have permission
            try {
                await firebase.messaging().requestPermission();
            } catch (error) {
                // User has rejected permissions
            }
        }
    }

    useEffect(() => {
        run()
    }, [])

    firebase.notifications().onNotification((notification) => {
        console.log(notification)
    });

With this code, I ask for permission to receive push notifications. I see the permissions dialog when I open the app for the first time. I accept the notifications. I also get a console.log output with the FCM token (console.log(await firebase.messaging().getToken())). I use this token in the notification creator in the firebase console to send a test notification. But I do not receive anything, if the app is in background, foreground, closed, ... it doesn't matter.

I have created a provisioning profile and I've added this in xcode. In xcode, going to my project > signing & capabilities, I've added the capabilities 'background modes (remote notifications)' and 'push notifications'. At the signing component, I have added the provisioning profile. I have unchecked automatically manage signing.

It seems to me I've done all steps necessary to receive push notifications. I'm testing on a real devices (iphone 6s), not on a simulator, and I've got it working on another iphone (6s) before, so it should work.

Am I missing anything?

Invertase: Firebase Cloud Messaging (FCM) with iOS devices

$
0
0

I'm trying to use push notifications on iOS devices with react-native.

I'm using Invertase and I managed to make them work on Android.

The only things I'm doing are: ask for the permission with messaging().requestPermission(); and registering a token with

firebase.messaging().getToken()

I can get a token on both devices. However when sending them with admin.messaging().sendToDevice does display the notification on Android but not on iOS although I don't get any error for both.

What Am I missing? Is there something more to do to handle notifications on the iOS part? Do I have to use zo0r/react-native-push-notification or wix/react-native-notifications?

Could you provide a push notification code example working on iOS with Invertase?

Shared Secret is required for consumable product to validate the receipt?

$
0
0

How can I validate the consumable IAP ? Is it a correct way to validate the consumable product ?

this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase: ProductPurchase ) => {
      const receipt = purchase.transactionReceipt;
      if (receipt) {

        const receiptBody = {
          'receipt-data': purchase.transactionReceipt,
          'password': '************'
        };

        RNIap.validateReceiptIos(receiptBody, false)
            .then((deliveryResult) => {
              if (deliveryResult) {
                 //required stuff...
              }
        }
    }

react-native-cameraroll not working on ios

$
0
0

I have the following react native code which works fine on android but not on ios:

    const [paging, setPaging] = useState({
        page: '',
        notLastPage: true
    })

   const MediaHandler = () => {
        if (paging.notLastPage) {
            CameraRoll.getPhotos({
                first: 5,
                after: paging.page,
                assetType: 'Photos'
            }).then(response => {
                console.log('response', response)
                let array = []
                response.edges.map((p, i) => {
                    array.push({
                        key: p.node.image.uri,
                        uri: p.node.image.uri,
                    })
                })
                setMedia([...media, ...array])
                setPaging(prevState => ({
                    ...prevState,
                    page: response.page_info.end_cursor,
                    notLastPage: response.page_info.has_next_page
                }))
            })
        }
    }

    useEffect(() => {
        MediaHandler()
    }, [])

    <FlatList
        data={media}
        renderItem={({ item, index }) => RenderMediaHandler(item)}
        onEndReached={MediaHandler}
        numColumns={3}
    />

(RenderMediaHandler is just a function to display the photos.)

How does it work?

When opening the screen, the function runs (useEffect). I fetched 5 photos. It also checks if there are any photos left. If the flatlist reached the end, the function is called again, and if there are any photos left, the next 5 photos are fetched. And so on. When there are no photos left, then paging.notLastPage is set to "false" and the function will not be executed anymore when the flatlist reaches the end.

This works exactly like it should on android, but not on ios. I just don't get any nodes (photos) in the response when I do a console.log(response).

When I leave out after: paging.page, I do get some photos, but only the first 5.

What's wrong with my code? I don't find any answers on their github page.

How to share from React Native to Instagram?

$
0
0

I'm using React Native to create an iOS app. However i would like to share a uri to an S3 video as follows:

import React from 'react'
import { Share, Linking ....} from 'react-native'

//button and run function
testShareInsta = async () => {
     const uri = "https://s3-dev.s3-us-west-1.amazonaws.com/video/myvideo";
     let encodedURL = encodeURIComponent(uri);  
     let instagramURL = 'instagram://library?AssetPath=${encodedURL}';
     return Linking.openURL(instagramURL);
  }

What can i do to make this work?

Is it possible to handle a file to another App without displaying the Share Screen in IOS?

$
0
0

I've never written any code with Objective-C and I'm as lost as you can be.

My App is in React Native but I couldn't find a way to achieve this so I had to start to search for a solution using Native Code.

What I basically need to do is taking a file I downloaded in my app's sandbox and open it in other app (PowerPoint) without actually showing the Share Screen Modal where the user selects the other App.

I know that when "Sharing" the file is copied into the PowerPoint's folder but I'm not sure if I'm able to do this kind of actions.

I was told to use this ->UIDocumentInteractionController but like I said, I'm not sure if it allows me to do that.

Any suggestion is welcome !

Thanks in advance !


Push Notifications - everything works except IOS when app is open

$
0
0

I have implemented push notifications using a Firebase cloud function for both android and IOS. When the app is closed the message is received in the notification bar. When tapped on the message the app opens without a problem for both IOS and Android

When the android app is opened and a message is received the message is shown in the notification bar.

However when the IOS app is opened, and a message is received, the message is shown in a pop-up on top of the screen, however inside the app I then receive a Failed to display notification message and I am not quite sure where I have to fix this.

Below is my notificationListener;

  useEffect(() => {
  this.removeNotificationDisplayedListener = firebase.notifications().onNotificationDisplayed((notification) => {
    console.log('NOTI DISPLAY', notification);
    // Process your notification as required
    // ANDROID: Remote notifications do not contain the channel ID. You will have to specify this manually if you'd like to re-display the notification.
});
this.removeNotificationListener = firebase.notifications().onNotification((notification) => {
  // Process your notification as required
  console.log('NOTI Normal', notification);
  notification

.android.setChannelId('channelId') .android.setSmallIcon('ic_launcher');

  const localNotification = new firebase.notifications.Notification()
                    .setNotificationId(notification.notificationId)
                    .setTitle(notification.title)
                    .setSound('default')
                    .setSubtitle(notification.subtitle)
                    .setBody(notification.body)
                    .setData(notification.data)
                    .ios.setBadge(notification.ios.badge);
                    localNotification.android.setChannelId('channelid');
                    console.log('SHOW NOTIFICATION', localNotification);
                firebase.notifications()
                    .displayNotification(localNotification)
                    .catch(err => console.error(err));
});
return () => {
    console.log('I AM CLEANING')
}

}, []);

Error message IOS when app is open

React-Native Navigation Drawer Inside Tab

$
0
0

I am making a React-Native App and I'm working with React-Native Navigation. I have currently a Stack navigation and a Tab Navigation, and I want to include a Drawer Navigation as well.

What I want to achieve is for a Drawer Menu to open on the side when the user taps the Menu Tab on the Bottom Tan Navigation.

Right now this is the Navigation code I have.

import React from 'react'
import { createStackNavigator, createAppContainer, createBottomTabNavigator } from 'react-navigation'
import { View, StatusBar, Text } from 'react-native'
// import FontAwesome from 'react-native-vector-icons/FontAwesome5'
import IconFontawesome from 'react-native-vector-icons/FontAwesome'
import IconMaterial from 'react-native-vector-icons/MaterialCommunityIcons'
import { MenuProvider } from 'react-native-popup-menu';

// screens
import Splashscreen from './src/screens/Splashscreen/Splashscreen'
import ProfileSetup from './src/screens/ProfileSetup/ProfileSetup'
import UserCreation from './src/screens/UserCreation/UserCreation'
import Login from './src/screens/Login/Login'
import Signup from './src/screens/Signup/Signup'
...

// Tabs
import MenuScreen from './src/screens/TabScreens/MenuScreen/MenuScreen'
import HomeScreen from './src/screens/TabScreens/HomeScreen/HomeScreen'
import BrandScreen from './src/screens/TabScreens/BrandScreen/BrandScreen'
import DeviceScreen from "./src/screens/TabScreens/DeviceScreen/DeviceScreen";

// Menu Screens
import AccountScreen from './src/screens/TabScreens/MenuScreen/AccountScreen/AccountScreen'
import HelpScreen from './src/screens/TabScreens/MenuScreen/HelpScreen/HelpScreen'
import PrivacyScreen from './src/screens/TabScreens/MenuScreen/PrivacyScreen/PrivacyScreen'
import ProfileScreen from './src/screens/TabScreens/MenuScreen/ProfileScreen/ProfileScreen';

import configureStore from "./src/state/store";
import { Provider } from "react-redux";
import { Root } from "native-base";

const DashboardTabNavigator = createBottomTabNavigator(
    {
        HomeScreen: HomeScreen,
        BrandScreen: BrandScreen,        
        DeviceScreen: DeviceScreen,
        MenuScreen: MenuScreen
    },
    {
        defaultNavigationOptions: ({ navigation }) => ({
            tabBarIcon: ({ focused, horizontal, tintColor }) => {
                const { routeName } = navigation.state;
                let iconName;

                if (routeName === 'MenuScreen') {
                    iconName = `menu`
                } else if (routeName === 'BrandScreen') {
                    iconName = `domain`
                } else if (routeName === 'HomeScreen') {
                    iconName = `home`
                } else if (routeName === 'DeviceScreen') {
                    iconName = `television`;
                } else if (routeName === 'DataScreen') {
                    iconName = `chart-line-variant`
                } else if (routeName === 'SearchScreen') {
                    iconName = `thermometer`
                }
                // return <IconFontawesome name={iconName} size={30} color={focused ? '#fff' : '#c0d3d6'} />
                return <IconMaterial name={iconName} size={30} color={focused ? '#fff' : '#c0d3d6'} />
            },
            tabBarLabel: ({ focused, tintColor }) => {
                const { routeName } = navigation.state;
                let labelName;
                if (routeName === 'MenuScreen') {
                    labelName = `MENU`
                } else if (routeName === 'BrandScreen') {
                    labelName = `BRANDS`
                } else if (routeName === 'HomeScreen') {
                    labelName = `HOME`
                } else if (routeName === 'DataScreen') {
                    labelName = `DATA`
                } else if (routeName === 'DeviceScreen') {
                    labelName = `DEVICES`
                } else if (routeName === 'SearchScreen') {
                    labelName = `Store`
                }
                return <Text style={focused ? { textAlign: 'center', fontSize: 11, color: '#fff', fontWeight: '600', marginTop: -5, marginBottom: 5 } : { textAlign: 'center', fontSize: 11, marginTop: -5, marginBottom: 5, color: '#C0D3D6' }}>{labelName}</Text>
            }
        }),
        tabBarOptions: {
            activeTintColor: '#ff3402',
            inactiveTintColor: '#eaeaea',
            style: {
                backgroundColor: '#00A5AC',
                height: 75
            },
            labelStyle: {
                color: '#fff'
            }
        },
        initialRouteName: 'HomeScreen',
        navigationOptions: {
            header: null
        }
    }
)

const AppNavigator = createStackNavigator(
    {
        Splashscreen: Splashscreen,
        UserCreation: UserCreation,
        Login: Login,
        Signup: Signup,
        Shop:Shop,
        Location:Location,
        ...
    },
    {
        initialRouteName: 'Splashscreen',
        navigationOptions: {
            header: null
        }
    }
);

const AppContainer = createAppContainer(AppNavigator)

export default class App extends React.Component {
    store = configureStore();

    componentDidMount(){
        console.disableYellowBox = true;
    }

    render() {

        return (
            <Provider store={this.store}>
                <Root>
                    <MenuProvider>
                        <View style={{ flex: 1 }}>
                            <AppContainer />
                            <StatusBar translucent backgroundColor='transparent' barStyle='light-content' />
                        </View>
                    </MenuProvider>
                </Root>
            </Provider>
        )
    }
}

I have tried adding the Drawer inside the Menu Tab but instead of opening a Drawer it redirects to the first screen inside the Drawer.

I'm a bit stumped on how to proceed with this with minimal modifications on the code, so any help would be greatly appreciated.

Can we use react native (npm) packages in react native expo project

$
0
0

I have created a react-native application using expo and now am working on it, I want to use some react native (npm: react-native-material-dropdown, react-native-datepicker, etc.,) packages in my expo project, but I am not able to use those in my expo project...

Is there any possibility or solution to make it happen?

Thanks in advance...

Module 'firebase' does not exist in the Haste module map

$
0
0

When trying to run my react-native project I get the following error. I think the error might be in the podfile but I cant seem to locate it.

enter image description here

Below I have added the files which I think are important and could be effecting the error

package.json

{
  "name": "ExerFit_mobileapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "bcrypt": "^3.0.7",
    "firebase": "^5.5.9",
    "moment": "^2.24.0",
    "moment-precise-range-plugin": "^1.3.0",
    "native-base": "^2.13.8",
    "qs": "^6.9.0",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-custom-tabs": "^0.1.7",
    "react-native-datepicker": "^1.7.2",
    "react-native-navigation": "^3.7.0",
    "react-native-progress": "^4.0.3",
    "react-native-progress-circle": "^2.1.0",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^2.18.2",
    "rn-apple-healthkit": "^0.6.5",
    "switch-button-react-native": "^1.0.3"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.8.4",
    "babel-jest": "23.6.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-react-native": "4.0.1",
    "detox": "^15.1.4",
    "jest": "23.6.0",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|static-container|expo|@expo|react-navigation|rn-apple-healthkit|switch-button-react-native|native-base))"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>/e2e"
    ],
    "moduleNameMapper": {
      "\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
      "\\.(css|less)$": "<rootDir>/__mocks__/fileMock.js"
    }

  },
  "detox": {
    "test-runner": "jest",
    "specs": "e2e",
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ExerFit_mobileapp.app",
        "build": "xcodebuild -workspace ios/ExerFit_mobileapp.xcworkspace -scheme ExerFit_mobileapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "device": {
          "type": "iPhone 8"
        }
      }
    }
  }
}

podfile

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

target 'ExerFit_mobileapp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  # add the Firebase pod for Google Analytics
  pod 'Firebase/Analytics'
  # add pods for any other desired Firebase products
  # https://firebase.google.com/docs/ios/setup#available-pods

  # Pods for ExerFit_mobileapp

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

  end

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

end

target 'ExerFit_mobileapp-tvOS' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for ExerFit_mobileapp-tvOS


end

This project had been working before today and when I began working on it I was getting this error. Any solutions would be greatly appreciated.

Why is the vibration duration in iOS not configurable (React Native)?

$
0
0

I am creating a game in React Native and I've searched all over the internet, Why is the vibration duration in iOS not configurable in React Native? All it says in the React Native docs is that the vibration duration in iOS not configurable but no other explanation. https://reactnative.dev/docs/vibration The reason why I would like to know why is because I would like to know if it would be possible for me to make a node module to work around this. thank you.

Getting the current section that is in the viewport in React-Native sectionlist

$
0
0

I want to detect which section of the react-native sectionlist is in the viewport. enter image description here

Is there any solution?

@objc override func insertReactSubview(_ subview: UIView!, at atIndex: Int) is not called iOS

$
0
0

@objc override func insertReactSubview(_ subview: UIView!, at atIndex: Int)

I use the above method to pass UIView from reactnative to ios. But this method is not calling sometimes. Please help.


I get an error with the npm run ios command

$
0
0

When I write this command 'npm run ios' I get this error:

'''

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening PhotoSearch.xcworkspace. Run CLI with --verbose flag for more details. User defaults from command line: IDEDerivedDataPathOverride = /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch

note: Using new build system note: Planning build note: Constructing build description Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Zocial.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Zocial.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/SimpleLineIcons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/SimpleLineIcons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Octicons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Octicons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Octicons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialIcons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialIcons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialCommunityIcons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialCommunityIcons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Ionicons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Ionicons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Ionicons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Foundation.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Foundation.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Foundation.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Fontisto.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Fontisto.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Fontisto.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Solid.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/FontAwesome5_Solid.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Solid.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Regular.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/FontAwesome5_Regular.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Regular.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Brands.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/FontAwesome5_Brands.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Brands.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Feather.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Feather.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Feather.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/EvilIcons.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/EvilIcons.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Entypo.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/Entypo.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Entypo.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

Build system information error: Multiple commands produce '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/AntDesign.ttf': 1) Target 'PhotoSearch' (project 'PhotoSearch') has copy command from '/Users/front.end.af/Documents/Nikita/kinoagenstvo/node_modules/react-native-vector-icons/Fonts/AntDesign.ttf' to '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/AntDesign.ttf' 2) That command depends on command in Target 'PhotoSearch' (project 'PhotoSearch'): script phase “[CP] Copy Pods Resources”

warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'react-native-orientation' from project 'Pods') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/AntDesign.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Entypo.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/EvilIcons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Feather.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Brands.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Regular.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/FontAwesome5_Solid.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Fontisto.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Foundation.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Ionicons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialCommunityIcons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/MaterialIcons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Octicons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/SimpleLineIcons.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: duplicate output file '/Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Products/Debug-iphonesimulator/PhotoSearch.app/Zocial.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/front.end.af/Documents/Nikita/kinoagenstvo/ios/build/PhotoSearch/Build/Intermediates.noindex/PhotoSearch.build/Debug-iphonesimulator/PhotoSearch.build/Script-97FA921B89C00DA950E1ACE1.sh (in target 'PhotoSearch' from project 'PhotoSearch') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'RSKImageCropper' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 6.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'libwebp' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'react-native-viewpager' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'RNImageRotate' from project 'Pods') warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 7.0, but the range of supported deployment target versions is 8.0 to 13.2.99. (in target 'react-native-image-picker' from project 'Pods')

** BUILD FAILED ** '''

Xcode Signing Errors

$
0
0

I have a react native project at school under my friend's account. I downloaded it to google drive and opened the Xcode file to run it, (taking care of the signing under my account) but its saying:

"no account for team "******" add a new account in the Account preferences pane or verify that your accounts have valid credentials."

I'm also receiving this error: No signing certificate for "IOS development" found: no signing certificate matching team ID "*****"

the ID it's listing isn't the same as mine.. do I have to somehow use my friend's ID to run this project? I've gone through a whole page of stack overflow questions. Do I need to go to school and download the certificate somehow?

Exact steps needed to migrate a react native android app to iOS

$
0
0

I've written a react-native app and compiled it for android. Now I wish to compile my app for iOS. I've searched the internet and found a lot of documentation about adding react-native components to an existing iOS app project, but couldn't find a concrete guide/explanation on how to take an existing react-native project(with many components, packages installed etc) and add the relevant iOS configuration.

I guess that I somehow should create an iOS project through xCode,then probably copy some project files into my ios folder of my project, create a podfile corresponding to my packages in package.json, install the required stuff using pod install and then maybe I can run it using the react-native run-ios command, but I'm really not sure whether I'm correct and to do these steps.

If someone can clarify to me what are the required steps I'll be grateful! (And I think other people might find it useful as well)

Could not find action, lane or variable 'update_plist'

$
0
0

when running fastlane, fastlane error

[!] Could not find action, lane or variable 'update_plist'. Check out the documentation for more details: https://docs.fastlane.tools/actions

Did anyone ever experience this problem? fastlane 2.28.3

crash (production only) in Swift in my react-native app

$
0
0

My healthkit swift code keeps crashing in the background in production, and I can't figure it out for the life of me. I am fairly new to Swift, so maybe I am making a fundamental error in my implementation.

Features of the crash:

  • It seems to happen only in production. (our internal test program contains 10 devices only (so maybe it is co-incidence that it doesn't get picked up there).
  • Occurs in iOS versions - 10,11,12,13
  • Occurs for a very small set of users (1.5% of active audience), but very frequently for these same users.

Please find the crash log from my Crashlytics account below.

Crashed: com.facebook.react.HKManagerQueue
0  stepapp                      0x100f4f324 specialized HKManager.getTotal(_:typeStr:unit:options:completion:) + 4372984612 (<compiler-generated>:4372984612)
1  stepapp                      0x100f52e04 HKManager._getTotals(_:completion:) + 397 (HKManager.swift:397)
2  stepapp                      0x100f532ac @objc HKManager.getTotals(_:resolver:rejecter:) + 4373000876 (<compiler-generated>:4373000876)
3  CoreFoundation                 0x1af698c20 __invoking___ + 144
4  CoreFoundation                 0x1af568d30 -[NSInvocation invoke] + 300
5  CoreFoundation                 0x1af569908 -[NSInvocation invokeWithTarget:] + 76
6  stepapp                      0x101184e6c -[RCTModuleMethod invokeWithBridge:module:arguments:] + 241556
7  stepapp                      0x101187248 facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&) + 250736
8  stepapp                      0x101186fac invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int) + 250068
9  libdispatch.dylib              0x1af35e610 _dispatch_call_block_and_release + 24
10 libdispatch.dylib              0x1af35f184 _dispatch_client_callout + 16
11 libdispatch.dylib              0x1af30b404 _dispatch_lane_serial_drain$VARIANT$mp + 608
12 libdispatch.dylib              0x1af30bdf8 _dispatch_lane_invoke$VARIANT$mp + 420
13 libdispatch.dylib              0x1af315314 _dispatch_workloop_worker_thread + 588
14 libsystem_pthread.dylib        0x1af3aeb88 _pthread_wqthread + 276
15 libsystem_pthread.dylib        0x1af3b1760 start_wqthread + 8

I have attached my implementation below, which contains the line mentioned in the crash logs

func _getTotals(_ options: Dictionary<String, Any>, completion: @escaping (Dictionary<String, Double>?) -> Void) {
    var stepsDone = false;
    var distanceDone = false;
    var caloriesDone = false;

    let steps = HKQuantityType.quantityType(forIdentifier: .stepCount);
    let distance = HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning);
    let calories = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned);

    var results = Dictionary<String, Double>();

    // 👇 THIS IS LINE 397 which is indicated in the crash report above
    self.getTotal(steps!, typeStr: HKManager.STEP_TYPE_STR, unit: HKUnit.count(), options: options) { (totalSteps, error) in
      stepsDone = true;
      if (totalSteps != nil) {
        results["steps"] = totalSteps;
      }

      if (stepsDone == true && distanceDone == true && caloriesDone == true) {
        return completion(results);
      }
    }

    self.getTotal(distance!, typeStr: HKManager.DISTANCE_TYPE_STR, unit: HKUnit.meter(), options: options) { (totalDistance, error) in
      distanceDone = true;
      if (totalDistance != nil) {
        results["distance"] = totalDistance;
      }
      if (stepsDone == true && distanceDone == true && caloriesDone == true) {
        return completion(results);
      }
    }

    self.getTotal(calories!, typeStr: HKManager.CALORIES_TYPE_STR, unit: HKUnit.kilocalorie(), options: options) { (totalCalories, error) in
      caloriesDone = true;
      if (totalCalories != nil) {
        results["calories"] = totalCalories;
      }
      if (stepsDone == true && distanceDone == true && caloriesDone == true) {
        return completion(results);
      }
    }
  }

I have also attached my implementation of the self.getTotal(...) function which is used in the above code. Point to note in this function, I switch to performing my HealthKit query in the background qos to ensure that these queries don't run on the main thread. I think it might be the cause for the crash.


  func getTotal(_ type: HKQuantityType, typeStr: String, unit: HKUnit, options: Dictionary<String, Any>, completion: @escaping (Double?, Error?) -> Void) {
    guard (self.healthStore != nil) else {
      let error = NSError(domain: "Healthkit not initialized", code: 50, userInfo: [:]);
      return completion(nil, error);
    }

    var start: Date;

    if (options["startDate"] != nil) {
      start = self.strToDate(dateStr: options["startDate"] as! String);
    } else {
      let date = Date()
      let cal = Calendar(identifier: .gregorian)
      let midnight = cal.startOfDay(for: date);

      start = midnight;
    }

    var ignoreMin = false;
    if (options["ignoreMin"] != nil) {
      ignoreMin = options["ignoreMin"] as! Bool;
    }

    if (ignoreMin != true && start < self.minStartDate && self.minStartDate != nil) {
      start = self.minStartDate;
    }

    var end: Date = Date();
    if (options["endDate"] != nil) {
      end = self.strToDate(dateStr: options["endDate"] as! String);
    }

    var sources = options["sources"] as? [String];
    if (sources == nil || (sources?.capacity)! < 1) {
      sources = ["com.apple.health."];
    }

    DispatchQueue.global(qos: .background).async { [weak self] in

      // fetch sources
      self?.getSources(sampleTypeStr: typeStr, sampleType: type, sources: sources!) { (s, error) in

        if (s == nil || ((s?.capacity) ?? 0) < 1) {
          return completion(0.0, nil);
        }

        let sourcePredicate = HKQuery.predicateForObjects(from: s!);

        // todo: enter date patterns
        let datePredicate = HKQuery.predicateForSamples(withStart: start, end: end, options: []);

        //      predicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
        let manualPredicate = HKQuery.predicateForObjects(withMetadataKey: HKMetadataKeyWasUserEntered, operatorType: .notEqualTo, value: "YES");

        let compound = NSCompoundPredicate(andPredicateWithSubpredicates: [
          sourcePredicate,
          datePredicate,
          manualPredicate
        ]);


        let statOptions = HKStatisticsOptions.cumulativeSum;


        let query = HKStatisticsQuery.init(quantityType:type , quantitySamplePredicate: compound, options: statOptions, completionHandler: { (query, results, error) in

          if (error != nil) {
            return completion(nil, error);
          }

          var total = 0.0;

          // handle if results came back as nil, or sum came back as nil
          guard (results != nil && results?.sumQuantity() != nil) else {
            return completion(total, nil);
          }

          total = results?.sumQuantity()?.doubleValue(for: unit) ?? 0.0;

          return completion(total, nil);
        });

        // execute stats query for step counts by source
        self?.healthStore?.execute(query);
      }
   }
  }

I would really appreciate any form of help, or pointers. Thanks in advance

PS: How frustrating are these swift stack traces?!@#

Viewing all 16907 articles
Browse latest View live


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