We’ve been building an Android app for the last year and we are trying to start work on the iOS version.
I’ve started testing on the simulator and we have a number of issues.
The app builds without complaint but when I run the app in the simulator I am unable to login or register as the app fails as soon as I attempt an XHR request.
I’m not getting a helluva lot to go on in the console as I just get a whole lot of the below:
Is there something I have wrong with my build perhaps?
How does the network tab look like?
What is your ionic info
output?
I dont get anything in the network tab. I’m currently trying to re-add ios platform to see if that helps.
My ionic info is as follows:
cli packages: (/Users/Baadier/Dev/Ionic/mobeewash/node_modules)
@ionic/cli-plugin-cordova : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils : 1.7.0
ionic (Ionic CLI) : 3.7.0
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.2
Ionic Framework : ionic-angular 3.6.0
System:
Node : v6.7.0
OS : macOS Sierra
Xcode : Xcode 8.0 Build version 8A218a
ios-deploy : 1.9.0
ios-sim : 5.0.8
npm : 5.3.0
The ios platform just finished and its version 4.4.0
1 Like
Ok, so the app doesn’t even start the requests?
The first error you have, what does this link to?
Apologies for the long wait. Somewhere along the way may GoogleService-Info.plist got corrupted and I had to debug that first cause my app wouldnt launch after I updated iOS platform.
This is the stack trace for the first of the errors (I couldnt find a way to copy it):
I also get this in the system log
Aug 17 20:17:39 Baadiers-MBP MobeeWash[16852]: ERROR: {"line":3,"column":23956,"sourceURL":"file:///Users/Baadier/Library/Developer/CoreSimulator/Devices/A8769D2D-95B5-46DC-8F56-606C733028A1/data/Containers/Bundle/Application/4AC4C810-EB07-4799-951D-8FC64912AD16/MobeeWash.app/www/build/polyfills.js"}
Aug 17 20:18:09 --- last message repeated 7 times ---
Look at the files from your code space in their (authentication-provider.ts, login-provider.ts, login.ts) to find out what is actually happening here and what could be broken.
What is the exact command you used to build your app?
Would generic Javascript code that works on Android not on work on iOS?
ionic cordova emulate ios
I tested with our login provider and stepped through the code.
As soon as it hits:
this.http.post(Constants.api.host + Constants.api.client.login, body, this.httpClient.getHeaders())
it jumps straight to
error => {
reject(error);
}
The full related block is as follows:
return new Promise<any>((resolve, reject) => {
this.http.post(Constants.api.host + Constants.api.client.login, body, this.httpClient.getHeaders())
.timeout(Constants.httpTimeout)
.map(res => res.json())
.subscribe(data => {
resolve(data);
}, (error => {
reject(error);
}));
});
Looking at your error message: No
In general: It should… But as you are using WKWebView this might influence it.
Ok, next step: See if all the variables are set as expected.
Don’t explicitly instantiate needless Promise
s. I suspect your problem might be caused by insecure endpoints. Are you using HTTPS?
My debugger shows that all the variables necessary to do the request have been set.
The server has HTTPS and it still bums out. The one I was using previously doesnt.
I just realised that I had enableProdMode() on from an earlier build so I’ll try and build again and hopefully get better debug output.
Please leave main.ts
alone. There’s nothing in there that you should need to be fooling with at all.
I deployed an Android build to Beta earlier hence it was on and didnt reset my environment after when I started tinkering with this iOS build.
I don’t understand what you are saying here, but generate a new project, copy the main.ts
from it, and then just leave it alone. You do not need to modify anything in it, ever.
We have a vanilla main.ts that includes the enableProdMode commented out until we build for the Play Store.
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import {enableProdMode} from '@angular/core';
import { AppModule } from './app.module';
// enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Are you saying thats the wrong place to put the enableProdMode() call?
You don’t need to do any of that. The ionic build process takes care of all of it for you. There is no need for you to modify main.ts
, period, and doing so is actively harmful, because it will confuse app-scripts.
Thanks.
I read through some other posts on the forum and elsewhere and it seems I was misinformed. I’ll remove it from our build.
If you’re curious about the details, see here.
1 Like