When its running without "-l", it can't find files in /img or /templates


#1

When I am running

ionic run ios --device -c

It can’t find the images from www/img (its working fine in emulator or serve)

[Error] Failed to load resource: The requested URL was not found on this server. (X_Marker.png, line 0)

or either

a .html file that I am using as template of directive’s templateUrl is also not working…

[Error] Failed to load resource: The requested URL was not found on this server. (window.html, line 0)

strange thing is if I run with livereload “-l”

ionic run ios --device -c -l

I get all the template .html for directives and images from www/img without problems… What am I doing wrong…?

I am also posting the dir structure that I have right now…

as you see above,
“window.html” is the html file that I am using for directive. which works fine with “-l”


No content security policy meta?
#2

Sorry but I never so this particular error.


#3

I guess its related to managing local resources…

I am putting the img or html in www/img or www/templates.

And calling it as below.

   var imagePost = {
            url: 'img/Default_Marker.png',
            size: new google.maps.Size(100, 100),
            origin: new google.maps.Point(0, 0),
            anchor: new google.maps.Point(17, 34),
            scaledSize: new google.maps.Size(1, 1)
        };

or for html,

 return {
    restrict: 'A',
    templateUrl: '/templates/window.html',
    link: link
};

If this is fixed, I am really right behind my alpha build for test…
Any help from anybody would be really appreciated!

I think I will post as new post with title 'resource is getting being loaded differently with livereald or something.


#4

Hi, have you tried deploying to the device with XCode?


#5

I deployed to device using

ionic run ios --device.

Do you mean not using ionic CLI but just Xcode? how would I do that?


#6

Do this first:

ionic prepare ios

That will make sure the iOS project is up-to-date.

Then go to the platforms/ios directory from the root of your app project. There you should find a file with the extension .xcodeproj. Open that in Xcode and on the top of the window you can select your device and press the Run button (⌘R).

You can also have a look at the files in the Staging folder in XCode and see if there is anything missing there.


#7

@asheteya

thanks for the tip,

before I read your thread, it somehow started to work again, here’s what I got before and here’s how it gets fixed.

I am sharing since I see lots of similar issue has been posted and nobody was able to answer it correctly. I guess your answer is most useful info amongst others.

heres what I found :

and they have told me to reset ip address using

ionic address

or disconnect wifi and reconnect it for both laptop and mobile.

both did not work for me, until I went to cafe and set wifi for theirs (starbucks) and then came home get the wifi again -> now it works.

I don’t know why it did this so I am very worried if this problem occurs again.

I event made the new start project and start placed my code about 4 days ago so I think I might not need to do below?

ionic prepare ios

I hope some Ionic people notice about this problem which have been occurred few times for other peoples too. I want clear solution for later just in case.