Meteor run ios-device --mobile-server not working?

I followed the Meteor Tutorial to get a taste of deploying a simple App to iOS via Cordova. When I get to Running on mobile I have no problems running in the iOS simulator or on a physical device (iPhone 6 w/iOS9).

However, I’ve deployed the app using:

meteor deploy <appname>.meteor.com

Yet when I run…

 meteor run ios-device --mobile-server <appname>.meteor.com

… it does not appear that the App is loading any resources from the remote server: The App always starts with an empty todo list, even though I’ve added items via a desktop browser at appname.meteor.com

I’ve tried this both with Meteor 1.1.0.3 and Meteor 1.2-rc.16.
This is Xcode 7.0 with an iPhone 6 iOS 9.0

In looking at Xcode debug output, I see references to fetching http://meteor.local but no references to http://appname.meteor.com, which makes me think that the --mobile-server option is not affecting the build.

The --mobile-server option should affect where the DDP connection is made to, and where new app versions are downloaded from. Files are always loaded from the local device, which is what meteor.local refers to.

I’m not sure what is going on in your specific situation. What you describe should be enough to connect to your deployed app. Does this also happen when running on the simulator or on an Android device?

I eventually got it working both on Simulator and Device. It seems to be some sort of caching issue in Xcode that I still can’t resolve.

At present, I am building the Meteor 1.1.0.3 which has a config.xml with:

<access origin="http://meteor.local/*"/>
<access origin="*://cv-demo1.meteor.com/*"/>

No references to cv-demo2 anywhere in the meteor project’s tree. Yet the debugger output refers to http://cv-demo2.meteor.com which was used in my Meteor 1.2-rc.16 build.

I’ve done a Clean, restarted Xcode, deleted the App manually, and am still seeing cv-demo2 in debug output.

I am experiencing the same issue. The first time I used --mobile-server it worked perfectly, however when I need to use a different server, the flag doesn’t work. The first use seems to cache the URL somewhere, and uses that as the default location.

I have no idea if that’s the issue here, but If you downgrade from Meteor 1.2 RC to 1.1.0.3, you may have to clean the .meteor/local/cordova-build directory yourself.

Are you using meteor run ios-device and opening the project in Xcode? Did you rerun the app in Xcode?

I haven’t downgraded–just kept two separate projects with each of above versions. I also tried blowing away cordova-build on both projects and that didn’t seem to make a difference.

Hi, did you figure out how to fix this problem? I’m having the same issue where my app isn’t connecting to the URL specified, but an old URL I was using and it will not change no matter what I do.

I found the easiest thing was to just always delete the .meteor/local/cordova-build and then re-run meteor run ios-device.

I also noticed quirks in the Xcode simulator where you would have to “reset” the simulator in order to truly get the latest version of the App installed. And on a physical device, deleting the previous version before running a debug build is probably wise.

I spent quite a few hours trying to figure this out.
With 1.1.0.3 I was able to build the app for android ( apk file ) and install it on android . After a lot of googling and reading posts ,it came down to the following : build the app using meteor build buildfolder --server=http://server:port
and running the server with the option --mobile-server=http://server:port

I have seen posts where some people got it to work by setting ROOT_URL or other env variables. None of those worked for me. Only thing that worked is the --mobile-server option passed while starting the server.
I was building the app on a vm and never really tried to use the simulator etc and this app did not have any oAuth plugins.

Another app with the same meteor version - 1.1.0.3 , has oAuth due to the accounts-google and accounts-facebook , now this time building on Mac ( latest OS ) and when run with the meteor run ios --mobile-server server:port does not get past the splash screen - some issue with the oAuth … allright , i run it on device due to the oAuth issue of not being able to run it on simulator with meteor run ios-device --mobile-settings server:port , i get past the splash screen on the device but the records are not beign rendered or does not seem like the app on the device is connecting to the server when run from the xcode.

Also in the mix i tried to port to released 1.2.x … spent quite few hours , ran into issues related to ionic, ionic tabs not rendering , iron router not rendering the templates or not finding the templates missing ejson etc… and dropped the idea of porting the app to 1.2.x …

My experience working with Meteor so far has been trial and error , broken documentation and several issues or difficulties building apps for mobile devices ( it is different thing building pure web apps - much straight forward) … We are so far nearing our planned launch date for our apps and continuing to work with meteor … Hopefully in future will upgrade to something more stable

Writing this , while i am still trying to figure out how to get my app launched on the device from Xcode to communicate with the remote server -lol

All right … the app when invoked by meteor run android-device --mobile-server http://server:port works well. No issues with the android , can see the docs in the app

Same thing when tryin to run on ios using meteor run ios-device --mobile-server http://server:port does not connect to the server. Tried with xcode 7 and xcode 6.4 - no luck .

In both the cases server has been started with --mobile-server http://server:port

On Meteor 1.1.0.3 – Any help /suggestions will greatly help .

There’s a long running Issue up on github around this.

I had issues with this about a year ago. I added the following in server/lib/config.js and haven’t had troubles since. Not sure if it’s all necessary but it’s working for me.

Meteor.startup(function() {

    var theURL = "http://myapp.meteor.com";

    if (process.env.NODE_ENV === "development") {

        // home
        theURL = "http://192.168.0.10:3000";

        // office
        //theURL = "http://192.168.10.30:3000";

    }

    Meteor.absoluteUrl.defaultOptions.rootUrl = theURL;
    process.env.ROOT_URL = theURL;
    process.env.MOBILE_ROOT_URL = theURL;
    process.env.MOBILE_DDP_URL = theURL;
    process.env.DDP_DEFAULT_CONNECTION_URL = theURL;

});
4 Likes