summaryrefslogtreecommitdiff
path: root/docs/guides/source.rst
blob: cb2499d2ac1f934167330c3c24d9237576cf5161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
Building from Source
`````````````````````

**NOTE** If you want to run it on your desktop, you can directly
download desktop binaries
`here <https://github.com/pliablepixels/releases>`__
and if you want it for Android/iOS you can get from the play/appstore.
This is only for those who *want* to run from source.

    Note: If you are building from source, you are mostly on your own. I
    have very limited time to debug environment differences/package
    differences between what I have and what you may have. I'm not a
    nodejs/grunt etc expert and stuff seems to change all the time.

Version note: The code is compiled using the following versions of
tools. **If you are using newer versions of ionic the code may not
compile - I don't have the time to upgrade yet. Finally, if you choose
to go the source route, I expect you to spend a lot of time yourself
debugging first before you create an issue. Even if you do create an
issue, I have very limited bandwidth to debug source compilation issues
for you.** Thanks.

Output of ``ionic info``

::

 
    Ionic:

    Ionic CLI         : 6.9.3 (/Users/pp/.nvm/versions/node/v12.17.0/lib/node_modules/@ionic/cli)
    Ionic Framework   : unknown
    @ionic/v1-toolkit : 1.0.22

    Cordova:

    Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
    Cordova Platforms : android 8.1.0, ios 5.1.1
    Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, (and 29 other plugins)

    Utility:

    cordova-res : not installed
    native-run  : not installed

    System:

    Android SDK Tools : 26.1.1 (/Users/pp/Library/Android/sdk)
    ios-deploy        : 1.10.0
    ios-sim           : 8.0.2
    NodeJS            : v12.17.0 (/Users/pp/.nvm/versions/node/v12.17.0/bin/node)
    npm               : 6.14.4
    OS                : macOS Catalina
    Xcode             : Xcode 11.6 Build version 11E708

Install Dependencies - needed for all platforms
-----------------------------------------------

Install NodeJS
~~~~~~~~~~~~~~

Install NodeJS from `here <https://nodejs.org/en/download/>`__. As of
Dec 2018, I'm using Node ``v8.11.2``. I use
`n <https://github.com/tj/n>`__ to manage node versions and switch
between them.

Install cordova and ionic
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash

    npm install -g cordova@8.1.2 ionic 
    npm install @ionic/v1-toolkit --save-dev

Don't install later versions of cordova. I found compilation issues with cordova 9.

And some more:

.. code:: bash

    npm install -g gulp
    npm install node-sass
    npm install async
    npm install jshint


(Note you may need to do ``sudo`` depending on how your system is set
up. It's `better you
don't <https://johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/>`__,
but if you must, well, you must)

You also need to install ``cocoapods`` (some of the plugins depend on them):

.. code:: bash

    sudo gem install cocoapods    

If you don't have ``gem`` that means you need to install ruby. Installing ruby
installs gobs of nonsense. Too bad. 

Download zmNinja
----------------

.. code:: bash

    git clone --depth 1 https://github.com/pliablepixels/zmNinja.git

Configure build configure zmNinja and get all required plugins
--------------------------------------------------------------

.. code:: bash


    cd zmNinja
    npm install
    ionic cordova platform add android (or ios)
    cordova prepare

Making an iOS build
-------------------

Note: You need to be doing this on a mac, with Xcode and the SDK
installed. You also need to have your developer certificates/etc. (I am
not going to detail this out - there are many internet resources on
this)

(Harder) If you need picture notification support in push
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As of Aug 2020, cordova-ios does not support multiple targets, nor does 
it support automatic building of notification extensions. So there is manual work to be done:

- Open up ``platforms/ios/zmNinja.xcworkspace`` in XCode
- Go to ``File->Workspace Settings`` and select ``Legacy Build System``
- Go to ``Target->zmNinja->Build Settings`` and set "Swift Language Version" to ``Swift 4``
- Go to ``File->New->Target->Notification Service Extension``, select Objective C 
- In the "Product Name" put in ``zmNinjaNotification`` (your BundleID should now read  ``com.pliablepixels.zmninja-pro.zmNinjaNotification``)
- Say "Yes" to "Activate zmNinjaNotification scheme?" popup
- Now go to zmNinjaNotification target and make version and  build same as zmNinja
- Now in XCode Targets, select ``zmNinjaNotification``, and make sure you select a Team and make sure Deployment Target is 11 or above
- Change Deployment target to 11 or above (same as zmNinja target)
- ``cp etc/NotificationService.m platforms/ios/zmNinjaNotification/``
- ``cd platforms/ios/``
- ``pod install``

You can now do `build_ios.sh`. However, after you build, you will have to go back to XCode
after the build to make the following changes:

1. Sync notification version with app version
2. Change notification bundle ID back to com.pliablepixels.zmninja-pro.zmNinjaNotification (cordova removes the last word)


(Easier) If you don't need picture notification support in push
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are a few steps you need to take to get the iOS build working for
the first time. If you don't do this, you may get a compilation error
that says ``ld: library not found for -lGoogleToolboxForMac``

::

    cd platforms/ios
    pod install

This does not produce an iOS ready ipa. What you need to do then is to
open ``platforms/ios/zmNinja.xcworkspace`` in Xcode, and run.

To compile a debug build for iOS from command line, from zmNinja project
root: First edit ``./build-auto.json`` and change the
``developmentTeam`` id to yours. Then:

.. code:: bash

     ./build_ios.sh

To compile using XCode, open ``platforms/ios/zmNinja.xcworkspace`` - You
need to use "Legacy Build" system if you are on XCode 10+. You can
change this in XCode ``File->Workspace Settings`` and then build usual.
Also switch to the Capabilities tab and make sure "Remote Notifications"
is on in Background Modes and in iCloud section, Key-Value storage is
enabled. If you see a "Fix issue" there, clicking on that button
resolves everything.

Making an Android build
-----------------------

Note that you need the `Android
SDK <http://developer.android.com/sdk/index.html>`__ installed and
configured properly for this to work.

From the zmNinja project root:

.. code:: bash

     ./build_android.sh --debug (or --release)

If this complains of missing SDKs, you need to install the SDK version
it requests This should produce an APK file. To install it on your phone
over adb, you'd do something like

.. code:: bash

    adb install -r debug_files/android-debug.apk #if you did --debug
    or,
    adb install -r release_files/zmNinja.apk #if you did --release 

Making a desktop build
----------------------

I use `electron <https://electron.atom.io>`__ to build the desktop app.

For versions 1.3.018 and beyond
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've migrated to using
`electron-builder <https://github.com/electron-userland/electron-builder>`__
to automate the build process better.

Make sure you have all the dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Typically, just running

::

    npm install

Should have installed everything. Validate by checking you have
``electron`` installed by invoking it on the command line

You now have the following options:

::

    npm run dist-all # builds linux, mac and windows packages
    npm run dist-mac # only builds mac packages
    npm run dist-lin # only builds linux packages (32bit, 64bit, arm)
    npm run dist-win # only builds win packages (32bit, 64bit)

Your packages will be created in the ``dist`` folder


Troubleshooting
---------------

Lots of things can go wrong. 

* Please make sure you don't post issues about why your own build is not working - please figure it out
* Look carefully at error messages