Meteor IOS build is not connecting with - -server option.What are the steps to build iOS app?

meteor build ~/Desktop/iOS --server=URL in not working.

1 Like

Please try to explain a little better what you’ve tried, what you expected to happen, and what happened.

Are you running your app on the development server (meteor run), or have you deployed it somewhere? Is the server reachable from the device?

I have two apps one is for backend and another is frontend(mobile app). When i am build the ios frontend app using this command : meteor build ~/Desktop/iOS --server=URL(backend development server URL). Then build is created but my app is not connecting to server when i login.

Ah, so you mean the backend and frontend are two separate Meteor apps? Usually Meteor runs the same app on the backend and frontend. What is your reason for splitting these up? Does your backend have a separate user interface?

You can’t just connect to a different app with the --server option, because that sets ROOT_URL and affects autoupdating data and where assets are downloaded from. If you want autoupdating, you’ll still need to host your frontend app somewhere.

To connect to a different app you can open a connection manually using DDP.connect and construct your own AccountsClient to log in.

Yes, I have two separate apps with separate user interface. But when I have created for Android using this: meteor run android-device --mobile-server=SERVER_URL. Then app is installed on the android device and connected to defined SERVER_URL and working perfectly.Is there any limitation for iOS platform using these commands.

There is no real difference between Android and iOS in this respect. Doing it like this won’t work perfectly on Android either. The default server should not be set to a server running a different app. Hot code push will no longer work for instance.

I’m afraid there is no way around using DDP.connect to open a separate connection if you want to connect to a different app.

Thanks for your time and quick replies.

a) We have used DDP.connnect to communicate the apps it works fine but I need to login every time when visit the mobile app and also web app whenever refresh the page it log outs the current user.
My requirements are :
1). Maintain user session until user manually logouts.
2). Want to maintain offline data of mobile app application but DDP.connect logout creates problem.

kindly suggest.

Are you using AccountsClient to login over the connection you opened with DDP.connect?

I am not using AccountsClient to login over the connection opened with DDP.connect. I am using accounts-ui package for use login/signup .

Not sure if this will fix your specific problem, but I just fought for hours until I realized that you need to (somewhat redundantly) specify the publicly accessible URL of the server in even more places than you might think:

  • ROOT_URL environment variable on the server
  • --mobile-server flag on the server
  • --server on your local Mac’s meteor build

If you forget to set --mobile-server on the server, it will try to connect, then the files will get overwritten by the server’s own Cordova build, which in that case would try to connect you to localhost! There should definitely be better documentation on this, but hopefully this post helps someone!

Unfortunately, accounts-ui (like many other packages) relies on a global Accounts singleton (this is what is used when you call the Meteor.login... methods).

Until we have a better solution for this, you will have to do something like this to login over a different connection:

Accounts = new AccountsClient(connection: ...);
Meteor.users = Accounts.users;
1 Like

So you mean i need to login the user every time from localStorage or from something else.

Maybe I’m misunderstanding what you’re trying to do, but this should configure accounts-ui to log in over the passed in DDP connection. AccountsClient should take care of storing the token in localStorage, as it would for the default connection.

Have you any example or link to do this?

You mentioned you’ve already successfully used DDP.connect, so passing that connection into the AccountsClient constructor in the code above should hopefully work.

This is the code that I tried in the client:

if (Meteor.isClient) {
//—DDP connection at remote server—//
remoteHost = SERVER_URL;
remote = DDP.connect(remoteHost);
Meteor.call = function(){
return remote.call.apply(remote, arguments);
};
Accounts = new AccountsClient({connection: remote});
Meteor.users = Accounts.users;
}

but getting error
ReferenceError: AccountsClient is not defined

Are you running Meteor 1.2? AccountsClient is not available on earlier versions. You may also have to meteor add accounts-base.

I am using Meteor 1.1.0.3 version

Is anything holding you back from upgrading? Especially when it comes to the Cordova integration, I wouldn’t recommend staying on 1.1.0.3.

I am seeing the same issues . Behavior is inconsistent originally was on 1.1.0.3 did not work ,migrated to 1.2.1 did not help either

My setup is as follows

2 different apps pointing to the same MongoDB . Two different apps have different UI and targeted for a different types of users .

Each app is running on its own vm .

1st app running at http://vm1:3000 and using MONGO_URL parm to point to a remote mongodb - sharedmongodb
2nd app running at http://vm2:3000 and using MONGO_URL parm to point to a remote mongodb - sharedmongodb

Apps started on server by executing the command
App1
export MONGO_URL=SHAREDMONGOURL
meteor ----mobile-server http://vm1:3000

App2
export MONGO_URL=SHAREDMONGOURL
meteor ----mobile-server http://vm2:3000

Can access both the apps through the desktop and mobile browsers and apps are working as expected when using BROWSERS.

Apps were built using
for APP1
meteor build --server=http://vm1:3000

for APP2
meteor build --server=http://vm2:3000

APP1 when installed on android and ios connects to remote server just fine . ( Though i had to build numerous times …and i eventually got it to work when i started the server with --mobile-server option.)

APP2 after trying to build numerous times and trying to run it using
meteor run ios-device --mobile-server http://vm2.com was able to connect to the remote server …

This same build when packaged and installed on ios does not work . Somewhere i read it is a issue with XCODE on ios devices , and used the XCODE 6.4 to build with on success.

What i have seen is app build process / feature is unstable … elsewhere i read that it is due to the iron_router and how it handles URL_PREFIX … if so , why does the first app work without any issues? both use IRON ROUTER.

Cannot switch to FLOW ROUTER as i see a lot of packages that are dependent on iron router that our app uses ex Meteoric:ionic , useraccounts etc…

It is high time meteor team should step up and provide clean and concise documentation on how these ROOT_URL, DDP_DEFAULT_CONNECTION or other params should be setup etc so the builds work consistently.

Me and my team spent a lot of time building these apps … for now we are living with app1’s hot code push and checking our updates on the devices without rebuilding the app .

I managed to get app2 on a ios device to connect to remote server when i ran the app using meteor run ios-device --mobile-server remoteserver. we are just using this one device to see our updates …

we are continuing to work on our apps , but iam afraid how it will turn out when i am ready to release the apps to the app stores …

HELPPPPPPP

2 Likes