#StackBounty: #ios #firebase #dart #flutter Flutter Dart App RangeError only on specific devices (not simulator)

Bounty: 50

My Flutter app has a list that loads data from a Firebase Firestore database. It loads fine on all simulator devices (and some real iOS devices) but breaks on actual iPhone 7 devices only. The following error is what I’m getting on iPhone7 :

RangeError (index): Invalid value: Valid value range is empty: 0

I’m not really sure where to begin debugging this error. Any guidance would be greatly appreciated!

Here’s my list generator code:

return new ListView(
  physics: const AlwaysScrollableScrollPhysics(),
  children: snapshot.data.documents.map((DocumentSnapshot document) {
    return _buildActivityItem(context,
      new Activity(
        activity: document['activity'],
        dateCreated: document['dateCreated'],
        food: document['food'],
        id: document.documentID,
        sentiment: document['sentiment'],
        text: document['text'],
      )
    );
  }).toList(),
);

Widget _buildActivityItem(BuildContext context, Activity activity) {
  // Format Date
  var formatter = new DateFormat('E., MMMM d').add_j();
  var today = new DateFormat('E').format(new DateTime.now()) == new DateFormat('E').format(activity.dateCreated);
  String formattedDateCreated = today ? new DateFormat().add_j().format(activity.dateCreated) : formatter.format(activity.dateCreated);

  // Format Activity
  String emoji = activity.activity == 'Exercise' ? '🏃‍' 
    : activity.food.length > 0 ? '🍴' 
      : '😐';

  // List Foods
  String getFoodList = activity.food.join(', ');

  return Container(
    decoration: new BoxDecoration(
      border: new Border(
        bottom: new BorderSide(width: 1.0, color: Theme.of(context).dividerColor)
      )
    ),
    child: ListTile(
      leading: new Text(
        emoji,
        style: new TextStyle(
          fontSize: 34.0
        )
      ),
      title: new Text(activity.text),
      subtitle: activity.activity.length > 0 ?  
        new Text(activity.activity )
        : activity.food.length > 0 ? new Text(getFoodList) 
          : null,
      trailing: new Text(formattedDateCreated),
    ),
  );
}


Get this bounty!!!

#StackBounty: #ios #swift #vpn #networkextension #l2tp Implementing VPN with L2TP protocol in iOS app

Bounty: 100

In iOS settings there are options to create VPN configuration using IPSec, IKEv2 and L2TP. Using NetworkExtension framework from Apple there’s option to create VPN using IPSec and IKEv2 protocols only. They do work but problem is that I need to create connection via L2TP since that’s only supported by company’s firewall.

There’s question iOS app with custom VPN connect from 2014 and it’s answered with:

If you want to connect programatically in ios 8 you can use only IPSec or IKEv2 protocols. L2TP and PPTP protocols are private for apple. It is not possible to use L2TP and PPTP APIs in your applications. Only Apple is currently using these APIs.

Is there any way to create L2TP VPN connection from iOS application (Swift)?


Get this bounty!!!

#StackBounty: #ios #swift #xcode #ios-charts Returning to xcode/swift/ios project – suddenly get "no such module"

Bounty: 100

I think xcode is having a laugh at me.

I open my old project that uses charts library
https://github.com/danielgindi/Charts/

and get error

No such module Charts

where I use

import Charts

I then tried to remove Charts from my project. Downloaded new project. And dragged Charts.xcodeproj file into my project – no change

The way my files physically are organized is:

 xcode-ios-projects
 - charts-ios
 - yourappplaform
 -- appcodegeneric (my source code and different .plist files for different apps)
 -- different-apps-asset-folder-1
 -- different-apps-asset-folder-2
 -- different-apps-asset-folder-x

Inside xcode IDE structure looks like this

appgeneric
- Charts.xcodeproj
- appcodegeneric
-- different-apps-asset-folder-1
-- different-apps-asset-folder-2
-- different-apps-asset-folder-x

I have updated xcode, charts etc. to newest. I have not yet updated to Swift 4 conversion process

It has been a long time since I touched my ios/swift project, so maybe I am missing something obvious – but this problem seems a bit odd to me.

UPDATE
After using “Clean” I now get the following error when I “Build”:

Module compiled with Swift 3.0.2 cannot be imported in Swift 3.3:
/Users/myname/Library/Developer/Xcode/kukuhkhkuhkuh/Build/Products/Debug-iphonesimulator/Charts.framework/Modules/Charts.swiftmodule/x86_64.swiftmodule

However – after cleaning that folder manually in Finder… I know get the same error as in the beginning:

no such module ‘Charts’


Get this bounty!!!

#StackBounty: #ios #swift #camera #core-graphics #avcapturemoviefileoutput How to compose AVCaptureVideoPreviewLayer with other views o…

Bounty: 500

I have managed to setup a basic AVCaptureSession which records a video and saves it on device by using AVCaptureFileOutputRecordingDelegate. I have been searching through docs to understand how we can add statistics overlays on top of the video which is being recorded.

i.e.

enter image description here

As you can see in the above image. I have multiple overlays on top of video preview layer. Now, when I save my video output I would like to compose those views onto the video as well.

What have I tried so far?

  • Honestly, I am just jumping around on internet to find a reputable blog explaining how one would do this. But failed to find one.
  • I have read few places that one could render text layer overlays as described in following post by creating CALayer and adding it as a sublayer.
  • But, what about if I want to render MapView on top of the video being recorded. Also, I am not looking for screen capture. Some of the content on the screen will not be part of the final recording so I want to be able to cherry pick view that will be composed.

What am I looking for?

  1. Direction.
  2. No straight up solution
  3. Documentation link and class names I should be reading more about to create this.

Progress So Far:

I have managed to understand that I need to get hold of CVImageBuffer from CMSampleBuffer and draw text over it. There are things still unclear to me whether it is possible to somehow overlay MapView over the video that is being recorded.


Get this bounty!!!

#StackBounty: #ios #swift #uitableview #uiscrollview Can UITableView scroll with UICollectionView inside it?

Bounty: 50

I have the structures below…

enter image description here

I wrap two of collection views into tableview

One is in tableview header(Collection1), another is in tableview 1st row(Collection2).

All the functions are good (Both collection view).

just…

When I scroll up in Collection2, Collection1 will Not scroll up together, because I’m only scrolling the collectionViews not the tableview.

It only scroll together when I scroll in Collection1.

Is it possible to make the header view scroll with user just like app store’s index carousel header?

Or I just went to the wrong place, I should use other ways to approach.


Get this bounty!!!

#StackBounty: #javascript #android #ios #reactjs #react-native React Native: TextInput with state and AsyncStorage

Bounty: 200

When typing on the keyboard I was seeing some warnings about the input being ahead of the JS code..

Native TextInput(react native is awesome) is 4 events ahead of JS – try to make your JS faster.

So added the debounce and got this to “work”:

...
import { debounce } from 'lodash'
...
export default class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      data,
      indexRef: data.reduce((result, item, index) => {
        result[item.title] = index
        return result
      }, {}),
      ready: false,
    }

    this.updatePitch = this.updatePitch.bind(this)
    this.saveLocally = debounce(this.saveLocally, 300).bind(this)
  }
  ...
  updatePitch(id, text) {
    // Copy the data
    let data = [...this.state.data]
    const index = data.findIndex(obj => obj.id == id)
    data[index].pitch = text
    // Update the state
    this.setState({ data }, this.saveLocally(data))
  }

  saveLocally(data) {
    try {
      AsyncStorage.setItem('data', JSON.stringify(data))
      this.forceUpdate()
    } catch (error) {
      // Well..
    }
  }

  render() {
  ...

BTW: I’m doing some “prop drilling” for now – but planning to do use the Context API (react 16.3)

The warning seems to have gone by adding debounce (1).. But I’m seeing some strange issues – particularly on the iPhone 8 plus simulator (not seeing the same on iPhone 6 simulator or Android device)

Issues observed:

  • TextInput don’t expand – it just add scolling (expands on iPhone 6 and Android device)
  • Some layout issues in the FlatList – seems like it has problems finding correct height of list elements..

What is the best practice for fast JS code and saving to both state and AsyncStorage?

(1) One other way than using debounce could be to use getDerivedStateFromProps and add some sort of timer pushing the state to the parent component after some period of time.. But wasn’t sure that this would make the JS code faster. So didn’t try it.

UPDATE

Had a request to show my data structure:

{
  "data": [
    {
      "id": "H3D1",
      "title": "Produkt",
      "pitch": "",
      "questions": [
        "Hvad er produktet?  ",
        "Hvilken værdi skaber det?  ",
        "Hvad er unikt?  ",
        "Hvordan er kvaliteten?  ",
        "Hvad er udsalgsprisen?  ",
        "Er prisen konkurrencedygtig?  ",
        "Hvor meget tjenes der på ét salg?  ",
        "Ejes der patenter/licenser?  "
      ]
    },
 ...
 ]
}

I currently save it locally in a JSON “template” file called data.json and load it initially.

import { data } from '../data.json'

export default class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      data,
      indexRef: data.reduce((result, item, index) => {
        result[item.title] = index
        return result
      }, {}),
      ready: false,
    }

and then retrieve the end users version via async componentDidMount by some await AsyncStorage.

  async componentDidMount() {
    SplashScreen.hide()
    try {
      let BusinessPlan = await AsyncStorage.getItem('BusinessPlan')
      if (BusinessPlan !== null) {
        // We have data!!
        let data = JSON.parse(BusinessPlan)
        data = this.state.data.map(item => {
          const index = data.findIndex(obj => obj.id == item.id)
          const pitch = index >= 0 ? data[index].pitch : ''
          return { ...item, pitch }
        })
        this.setState({ data, ready: true })
      } else {
        this.setState({ ready: true })
      }
    } catch (error) {
      // Error retrieving data
    }
  }


Get this bounty!!!

#StackBounty: #javascript #ios #reactjs #react-native #cocoapods <React/RCTDefines.h> file not found

Bounty: 50

I am Using cocoapods to install react native and react. I just want to use a toast component(https://www.npmjs.com/package/react-native-simple-toast) which does ti have a cocoapods Installation. when i install and and run the app I am getting an error “” file not found error.
I have added header search path but still getting this error.
1)error
enter image description here

2)react-native-simple-toast xcode project Header search path
enter image description here

3) Main project Header search path
enter image description here


Get this bounty!!!

#StackBounty: #ios #css #objective-c #xcode Load .CSS file from within app in uiwebview

Bounty: 50

i am trying to load .js and .css files from within app resources to uiwebview. and i am able to load .js file but can not load .css file please help. here is my code

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    //NSString *cssFile = @"styling.css";

    NSString *jsFile = @"storage.js";
    NSString *jsFilePath = [[NSBundle mainBundle] pathForResource:jsFile ofType:nil];
    NSURL *jsURL = [NSURL fileURLWithPath:jsFilePath];
    NSString *javascriptCode = [NSString stringWithContentsOfFile:jsURL.path encoding:NSUTF8StringEncoding error:nil];
    [webView stringByEvaluatingJavaScriptFromString:javascriptCode];
}

this code it working perfectly for .js file but how can i use .css file in it?


Get this bounty!!!