saltcorn icon indicating copy to clipboard operation
saltcorn copied to clipboard

Provide more docs about mobile apps

Open AleksandrSokolov opened this issue 2 years ago • 5 comments

Currently there are no documentation how and what needs to be configured to get success of mobile apps building.

In admin.js I found:

const spawnParams = [ "build-app", "-e", entryPoint, "-t", entryPointType, "-c", appOut, "-b", ${os.userInfo().homedir}/mobile_app_build, ];

But I still in doubt)).

Please give more information - what needs to installed or configured for mobile builder to get success.

AleksandrSokolov avatar Aug 13 '22 16:08 AleksandrSokolov

@christianhugoch please help with this

AleksandrSokolov avatar Aug 13 '22 17:08 AleksandrSokolov

Hi Aleksandr, nice to see that you want to use it. I will write more docu later that day, can you tell me already for which platform you want to build (Android or iOS)?

christianhugoch avatar Aug 14 '22 09:08 christianhugoch

Android: If you want to build for android, take a look at this docker file: https://github.com/saltcorn/saltcorn/tree/master/packages/saltcorn-mobile-builder/docker npm builds the image when you do 'npm install' in a postinstall hook. You need to install docker and make it accessible without sudo for this, either with the docker rootless mode, or add the current user to the group 'docker'.

Or to build the docker mage on your own:

cd  ./saltcorn/packages/saltcorn-mobile-builder/docker
docker build . --network host -f ./Dockerfile -t saltcorn/cordova-builder

After this, select the checkboxes 'android' and 'docker' on the builder gui and click build. Or via a cli: saltcorn build-app -e [first_view] -t view -c ~/saltcorn/packages/server/mobile-app-out -b ~/mobile_app_build -d -p android

-d for docker -b is a directory where the build runs. The cli command copies the saltcorn-mobile-app package to -b and executes all build commands there. Make sure the user has permissions to create and delete directories at -b

-c is an out directory where you will find the actual app file (.apk for android) -e is the name of the first view after the login (entry-point) -t specifices if the entry point is a page or a view

If you are interested in building without docker, I could describe how to set up an Android environment on your own.

iOS: For iOS apps, you need to have an actual mac or a MacOS VM. Take a look at this: https://cordova.apache.org/docs/en/11.x/guide/platforms/ios/

You will need

xcode-select --install

brew install ios-deploy

sudo gem install cocoapods

After this, select the iOS checkbox and click build.

Or via cli:

saltcorn build-app -e [first_view] -t view -c ~/saltcorn/packages/server/mobile-app-out -b ~/mobile_app_build -d -p ios

If you have an enrolled Apple Developer Account, then take your apple team id and do:

saltcorn set-cfg apple_team_id [your team id]

Otherwise, you won't be able to build an .ipa file, but you can create a xcode project that runs on the iOS Simulator. If you have no 'apple_team_id' then set --buildForEmulator (the gui already does this for you) and after the build, go to the build directory (-b) search for the xcode project file and open it with xcode. (https://cordova.apache.org/docs/en/11.x/guide/platforms/ios/#deploying-to-simulator)

I am still in the process of activating my Apple developer account, so I wasn't able to test the apple_team_id cfg parameter, but it looks good in the simulator.

A better documentation is coming soon, but I hope this helps for now.

christianhugoch avatar Aug 14 '22 18:08 christianhugoch

Almost forgot, when you want to try it in the Android emulator, set the serverURL field to http://10.0.2.2:3000

or from cli

-s http://10.0.2.2:3000

christianhugoch avatar Aug 14 '22 20:08 christianhugoch

And I believe you should use any-bootstrap-theme (just activate it on the server), the sb-admin-2 sidebar is not optimized for mobile. ~~For iOS, you need to install this~~

~~https://github.com/christianhugoch/any-bootstrap-theme/tree/mobile-ios-platform~~

~~as a local plugin. It's not merged yet~~

christianhugoch avatar Aug 14 '22 20:08 christianhugoch