5

I'm following the NativeScript tutorial, but when I'm trying to load the image with res:// is not working with iOS.

<Image src="res://logo" stretch ="none" />

The file is in the App_Resources/iOS/logo.png

UPDATE:

Now works:

1.- Uninstall the app from the device/emulator

2.- Then do a new tns build ios to get a fresh build

4 Answers 4

7

Related steps for the same issue but with Android.

tns platform remove Android
tns platform add Android
tns run Android

Added explanation: The issue here is that your app isn't really running from AppResources. It is actually running from platform/ios and platform/android, both of which are compiled during a fresh build.

So when you add an image under AppResources, great, but unless you rebuild the app is still running on outdated resources found in platform/ios and platform/android.

Removing the platforms and adding the platforms will ensure the folders your app is using mimic App Resources. And your image will be available.

1
  • 1
    Thanks .. I solved the bug this way only.. what a waste of time though.
    – niketan
    May 10, 2017 at 10:55
2

It worked for me.

  1. Uninstall the app from the emulator
  2. Re-run your build / livesync
  3. Done
1

I expect the issue is with your use of the nativescript cli.

To compile and run a new app, you should run tns prepare ios, then tns build ios then tns launch ios. Alternatively tns run ios completes all these steps. So bear in mind that when adding new platforms, plugins or resources, you should re-run the prepare command.

2
  • I tried with ths prepare ios, but if you don't uninstall the app from the emulator the images still cached
    – eusoj
    Jun 7, 2016 at 21:38
  • But if you are just adding new images, that shouldn't effect it? Should only be an issue if your image changes but keeps the same file name... Jun 7, 2016 at 21:39
0

Take a look at the tag stretch ="none". It have an space between ch and =. There is an error on Visual Code snippets. Maybe this is the case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.