There appears to be an issue with 2.5.1 that is corrupting all incremental iOS builds targeting the simulator. The issue is captured and well described here:
Steps to reproduce:
tns build or tns deploy)This problem did not exist in 2.5.0.
@toddanglin
Can you reproduce the issue with hello-world templates?
Can you post your package.json?
I can not reproduce with:
npm uninstall -g nativescript
npm install -g [email protected]
tns create TestApp && cd TestApp
code app (open app folder in VSCode)
tns run ios
Make whatever changes (in css, js, xml, break the app on purpose with invalid changes and then fix it)
Result: No issues.
Same with release branch of https://github.com/NativeScript/sample-Groceries -> No issues.
Let me try to create a project that reproduces the issue. Clearly, as per the forum thread, I'm not the only one encountering this error...but it's also clear that it's not impacting every project.
I have a hunch that it could be related to plugins, most like i18n since it does the most during the build process. Let me test and report back...
Still struggling to get a new project to recreate the error. Here is the series of log messages that occurs when a LiveSync happens on my existing app (run with tns run ios --emulator):
Executing before-prepare hook from myapp/hooks/before-prepare/nativescript-dev-typescript.js
Executing before-prepare hook from myapp/hooks/before-prepare/nativescript-i18n.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from myapp/hooks/after-prepare/nativescript-i18n.js
Transferring project files...
Successfully transferred myView.xml.
Refreshing application...
Successfully synced application com.htmlui.MyApp on device [UUID].
NativeScript debugger attached.
CONSOLE LOG file:///app/tns_modules/tns-core-modules/trace/trace.js:151:28: Debug: TabView._onSelectedIndexPropertyChangedSetNativeValue(1)
CONSOLE LOG file:///app/views/tabs/devicesView.ts:76:16: OLD INDEX undefined
Skipping prepare.
Transferring project files...
Successfully transferred InfoPlist.strings.
Successfully transferred Localizable.strings.
Refreshing application...
Feb 21 17:12:30 Mac-Pro com.apple.CoreSimulator.SimDevice.[UUID].launchd_sim[427] (UIKitApplication:com.htmlui.MyApp[0xd35f][5579]): Service exited due to signal: Terminated: 15
Unable to sync files. Error is: Command xcrun with arguments simctl launch [UUID] com.htmlui.MyApp failed with exit code 3. Error output:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Failed to lookup the process ID of com.htmlui.MyApp after successful launch. Perhaps it crashed after launch.
No such process
Everything looks fine...the sync happens the app is refreshed...but then the process keeps going and seemingly attempts to build and refresh a 2nd time. Not sure if this will help trigger any ideas about what could be happening. Will keep trying to create a local, isolated problem reproduction.
Okay. Got it. This simple hello-world project reproduces the error:
https://github.com/toddanglin/ns-build-error
The steps to recreate the project:
tns create demo --tsc)tns platform add ios)tns plugin add nativescript-i18n)app > i18n > en > strings.xmlstrings.xml file like:<resources>
<string name="btnText">Next</string>
</resources>
tns run ios --emulator)Let me know if you are unable to reproduce the problem using this project. Seems to be definitely related to the i18n plugin. To trigger, you must have the plugin installed and a strings.xml file in the project.
All of this is likely also related to this Issue in the nativescript-i18n repo:
https://github.com/rborn/nativescript-i18n/issues/37
And this issue from 2.5.0:
https://github.com/NativeScript/nativescript-cli/issues/2482
Not sure if this is a regression or if the problem that those threads suggest was fixed did not cover all the scenarios. But definitely looks like same problem, only more severe in 2.5.1.
Thank you @toddanglin,
We'll investigate.
FWIW, I've downgraded to 2.5.0 for now. Seems to be the only way to continue working with the i18n plugin until this build issue is resolved.
Hey @toddanglin ,
It looks like the nativescript-i18n plugin has before-prepare hook that modifies Info.plist in app/App_Resources/iOS directory: https://github.com/rborn/nativescript-i18n/blob/master/lib/before-prepare.js#L52 . All changes in App_Resources required rebuiliding the application. That's why CLI starts a new build when you apply any change. Plugin's hook always modifies the Info.plist file, no matter which file has been changed. CLI 2.5.0 has issues with checking files (it relies on the mtime of a file, not the ctime, which is incorrect), that's why you do not see the error with it - it just does not understand there's a change in App_Resources.
I'm not sure what is the best way to handle this. I have some ideas, for example:
nativescript-i18n hook will overwrite app/App_Resources/Info.plist file, but its content will be the same and CLI will disregard this modification.node_modules and trigger livesync in case any file inside these plugins is modified.What do you think? Ping @hshristov , @Plamen5kov as well.
Personally, I like both Option 2 and 3.
Thinking of the CLI behavior before 2.5.0...the reason none of these problems existed was because LiveSync wouldn't attempt to do a native rebuild. The nativescript-i18n plugin would warn you that you'd need to manually trigger a full rebuild if you changed the strings definitions. And life was good. :)
I'm wondering if another option to consider is a flag (or config option) for tns run that lets developers disable native rebuilds during a LiveSync watch session. There are pros and cons to this approach, but it is this key change from 2.4 that is causing a lot of these problems now.
Adding @rborn since his plugin is one of the more popular impacted here.
I'm for option 2. Power to the people!
I'm wondering if another option to consider is a flag (or config option) for tns run that lets developers disable native rebuilds during a LiveSync watch session.
@toddanglin I'm not so optimistic about the flag and here's why:
--watch --no-watch)Any plans to patch this before 3.x?
I'm stuck now between downgrading to 2.5.0 and getting endlessly looping builds or 2.5.2, which still breaks with i18n. May have to downgrade 2.4.x if a patch will take a while...
@toddanglin we'll try to take a look at the concrete plugin and provide some workaround, and for 3.0 we should be able to introduce Option 2 as discussed, which will require some work on the plugin author`s side, but it's the best possible solution.
@toddanglin can you tell me how exactly does the above demo fail with cli 2.5.2?
Hi, I am experiencing the same issue with NS CLI 2.5.2 and NS SASS plugin. Steps to reproduce:
Here is log that is printed when running tns run ios and making a single change to a file:
| => tns run ios
Skipping prepare.
Searching for devices...
Skipping package build. No changes detected on the native side. This will be fast!
Skipping install.
Executing before-livesync hook from /Users/binici/projects/helloworld/hooks/before-livesync/nativescript-angular-sync.js
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
Executing before-watch hook from /Users/binici/projects/helloworld/hooks/before-watch/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
objc[94336]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11a438998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11a25a880). One of the two will be used. Which one is undefined.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
9:25:03 PM - Compilation complete. Watching for file changes.
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-typescript.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-sass.js
Transferring project files...
Successfully transferred items.component.html.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
NativeScript debugger attached.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-typescript.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-sass.js
Transferring project files...
Successfully transferred app.css.
Successfully transferred app.css.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-typescript.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-sass.js
Transferring project files...
Successfully transferred app.css.
Successfully transferred app.css.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-typescript.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-sass.js
Transferring project files...
Successfully transferred app.css.
Successfully transferred app.css.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld/hooks/before-prepare/nativescript-dev-typescript.js
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld/hooks/after-prepare/nativescript-dev-sass.js
Transferring project files...
Successfully transferred app.css.
Successfully transferred app.css.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
Skipping prepare.
Transferring project files...
Successfully transferred app.css.
Successfully transferred app.css.
Refreshing application...
Successfully synced application org.nativescript.helloworld on device BA2C79D3-C503-4596-8604-8EBECA0D1594.
CONSOLE LOG file:///app/tns_modules/@angular/core/bundles/core.umd.js:111:20: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
A single file change results in multiple builds and syncs to the iOS simulator. Just as @toddanglin I will have to downgrade to 2.5.0 until this is fixed.
@abinici thank you for the detailed steps. I managed to reproduce the problem, and I'll start investigating right away.
@Plamen5kov I think the problem is that both plugins (sass and mine) write something in the watched folder. So livesync will think something got updated and rebuild which will trigger another re-write, and so on.. ๐
@rborn you're right, but in the case of your plugin, the app crashes in a totally different way, and it's not doing the constant rebuild we're seeing in @abinici's case.
yeah ๐
By popular vote, we'll implement option 2. We'll provide more information to the plugin authors through the hookArguments so they can act accordingly to the changed files about to be livesynced.
Hey guys, can you checkout our @next and tell us if what you requested is covered as you expected?
@rborn @abinici @toddanglin
Hi @pkoleva , here is what I did to repeat my previous test:
Now, when I run tns run ios I get the following error:
| => tns run ios
Executing before-prepare hook from /Users/binici/projects/helloworld2/hooks/before-prepare/nativescript-dev-android-snapshot.js
Executing before-prepare hook from /Users/binici/projects/helloworld2/hooks/before-prepare/nativescript-dev-sass.js
Executing before-prepare hook from /Users/binici/projects/helloworld2/hooks/before-prepare/nativescript-dev-typescript.js
Found peer TypeScript 2.1.6
Preparing project...
Project successfully prepared (ios)
Executing after-prepare hook from /Users/binici/projects/helloworld2/hooks/after-prepare/nativescript-dev-android-snapshot.js
Executing after-prepare hook from /Users/binici/projects/helloworld2/hooks/after-prepare/nativescript-dev-sass.js
First call of getPlatformData without providing projectData.
Before installing sass there is no problem building and running the app. Maybe sass-plugin is not compatible with version 3 of Nativescript?
Here is the output of tns info:
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ Component โ Current version โ Latest version โ Information โ
โ nativescript โ 3.0.0-2017-03-24-8407 โ 2.5.3 โ Up to date โ
โ tns-core-modules โ 2.5.2 โ 2.5.2 โ Up to date โ
โ tns-android โ โ 2.5.0 โ Not installed โ
โ tns-ios โ 3.0.0-2017-3-14-1 โ 2.5.0 โ Up to date โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
This is expected since the plugin authors haven't updated the plugins, in compliance with the changes with CLI from @next, where they have more info coming in during livesync.
@pkoleva I'm a little overloaded these weeks, but as soon as I have a little time I'll give it a shot ๐
I'm having the same issues, except using nativescript-dev-less instead of sass. It's very difficult to do anything sort of development. Is there currently any resolution here other than downgrading my TNS version to 2.4 or removing the dependency?
All the changes, required by the plugin developers are already in master, so as soon as the plugin developers, update their respective plugins to use the newly provided information, the problems will be solved.
@Plamen5kov could you give us some links where we should look ? (commits, docs, etc?)
Thank you.
@rborn sure:
https://github.com/NativeScript/nativescript-cli/pull/2605
https://github.com/NativeScript/nativescript-cli/pull/2605/files
These changes are available in @next.
Are there any sample hooks using the hookArgs data? It accepted it as an allowable hook parameter however the variable was always undefined.
edit: I found it in use in nativescript-dev-babel, I'm going to start a clean project to isolate why I was getting undefined.