Changes in Ts File dont transfer to main.js file in Apple


#1

Hey I’m fairly new to ionic and app development. Our Company took over an existing app. Now we should change something. a part of the app should only be available for registered members. To do it i added a service provider with a Variable in it that gets set at the start of the App. In the Ts file of the part that should be locked for guests i get the variable. I got it in Android no problem. But on Apple i have the problem that the changes i did in my ts files are not transfered to the main.js file that is generated. I tried building it after cleaning my project. I even removed the platform and added it again but still no changes. I also ran cordova prepare but this didn’t do the trick either.

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0 

local packages:

@ionic/app-scripts : 3.1.9
Cordova Platforms  : android 6.4.0 ios 4.5.4
Ionic Framework    : ionic-angular 2.0.0-rc.4

System:

Node  : v8.10.0
npm   : 5.6.0 
OS    : macOS High Sierra
Xcode : Xcode 9.3 Build version 9E145 

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro

#2

@DominikMetzler The main.js file in the www folder is not generated correctly? Because if this is the case, it wouldn’t work in Android either…

Have you tried to run $ ionic cordova run ios

If you run $ cordova run ios (without ionic first) it will use the existing files in the www folder (without transpiling the ts files first).

Also, I see that you are using a relatively old version of ionic (ionic-angular 2.0.0-rc.4), although it shouldn’t prevent you from transpiling the ts files correctly.


#3

@lucasbasquerotto when i run $ ionic cordova run ios i get a lot of error messages regarding the sqlite plugin. In the Plugin Folder is no sqlite.js only a sqlite.d.ts. But it seems like the js code is in the ts file.

I never run $ ionic cordova run ios. I just build it in xcode. Is that wrong?

We got two different versions of the App. One for Android and one for Apple. It was that way, when we got the App. But it should be the same thing exept for the platforms. The Android Version of the App doesn’t have IOS Platform.


#4

@DominikMetzler I don’t know what is causing that problem, you can post another topic about that, but about the ts files you need the ionic build to transpile the ts files in the src folder to js files in the www folder, then do the other steps as you are doing right now, just make sure to run the build step.

Just to clarify, make it in 2 steps:

1) Execute the build:

Assuming you have the following in your package.json, under scripts:

"build": "ionic-app-scripts build"

Run:

npm run build --prod

This will make your production build, the js files will be in the www folder. This step doesn’t require cordova, you just create the js file with the prod flag to minify, optimize and make you app faster and smaller.

An implementation cannot be declared in ambient contexts

This is probably a problem in the ionic-native, the files .d.ts shouldn’t have implementation (they are just to define the types).

You should try upgrading the ionic-native package. It’s now using @ionic-native instead of ionic-native.

First see if npm run build --prod works, and see if it works in your android project too, then compare them (if it works in the android project and not in ios).

2) After fixing the errors, try running cordova build ios

After that you can use the xcode, because your code will be inside /platforms/ios.