Deploying mobile apps / Deploying mobile apps on iOS devices |
Genero provides a command-line tool to build applications for iOS devices.
Genero mobile apps for iOS are distributed as IPA packages like any other iOS app. Genero provides a command line tool to build the .ipa package for your mobile application, or the .app directory for simulators.
$ instruments -s Known Devices: fraise [55D6D6C1-DE87-52F0-865E-3C6DC79F13D7] Fourjs2 iPod touch (9.1) [78b7452fa9462c98c3bc7047da344314fd032004] iPad 2 (9.0) [19CDA827-CA55-46F1-9376-BF61E2ECFDBB] iPad Air (9.0) [F55E1207-C42B-472E-BD76-5B5AE46DE77A] iPad Air 2 (9.0) [A0E8C4CD-67CD-42CB-84DF-9C75AC773293] ... Known Templates: "Activity Monitor" "Allocations" ...
In the above output, the UDID of the iPod is 78b7452fa9462c98c3bc7047da344314fd032004.
Four Js is not allowed to provide a ready-to-use front-end component for iOS devices, because of iOS app limitations defined by Apple: An iOS app shipped on the App Store cannot listen to a TCP port to provide a GUI service. Therefore, you will have to create your own GMI front-end, with your own Apple certificate and provisioning profile. The generated GMI can then be deployed on your device or simulator for development purpose listening on the port 6400, to display applications running on a server (FGLSERVER).
$ gmibuildtool
$ gmibuildtool --device booted
$ gmibuildtool \ --device phone \ --certificate HGRW8... \ --provisioning "~/Library/MobileDevice/Provisioning Profiles/myapp.mobileprovision"
The generated IPA file can be found in the build subdirectory. This IPA file can be installed on your devices by using iTunes.
$ gmibuildtool \ --device "Mike's iPhone 6 (9.0)" \ --certificate HGRW8... \ --provisioning "~/Library/MobileDevice/Provisioning Profiles/myapp.mobileprovision"
The gmibuildtool command can build and install iOS apps for the simulator or for physical devices.
The build and/or install action is controlled by the --device option:
By default, the generated GMI.app directory and .ipa archive can be found in $PWD/build sub-directories. However you can specify the destination IPA file with the --output option.
For a complete description of command options, see gmibuildtool.
For convenience, the build tool supports a default directory structure to find all files required to build the app:
top-dir | |-- main.42m and other program files, as described in Directory structure for GMI apps | |-- gmi | | | |-- Info.plist | | | |-- LaunchScreen.storyboard | | | |-- Default@2x.png | |-- Default-568h@2x.png | |-- Default-Landscape.png | |-- Default-Landscape-667h@2x.png | |-- Default-Landscape-736h@3x.png | |-- Default-Landscape@2x.png | |-- Default-Portrait.png | |-- Default-Portrait-736h@3x.png | |-- Default-Portrait-667h@2x.png | |-- Default-Portrait@2x.png | | ... | |-- icon_29x29.png | |-- icon_40x40.png | |-- icon_57x57.png | |-- icon_58x58.png | |-- icon_72x72.png | |-- icon_76x76.png | |-- icon_80x80.png | |-- icon_120x120.png | |-- icon_152x152.png | | ...
iOS apps can be generated in a debug or release version. Release version are prepared for distribution on the App Store, while debug versions are used in development.
In debug mode, the app installed on the device can listen on the debug TCP port to allow fgldb -m connections, after enabling the debug port in the app settings.
Debug or release mode must be specified in the command line with the --mode debug or --mode release option. Additionnally, if you want to deploy on a physical device, you need to use a provisioning profile corresponding to the debug or release mode:
Apple distinguishes the app version number of a bundle (visible to the end user), from the build version number of a bundle (called a release version number in Apple docs).
You specify the app version number with the --app-version option of the gmibuildtool command. This option sets the CFBundleVersion property of the Info.plist file), and must match the version specified in iTunes Connect.
In order to distinguish multiple builds (Apple's term is "releases") of the same app version number, define the build version number of your app with the --build-number option. This option sets the CFBundleShortVersionString property of the Info.plist file. For a given app version, you need to increase this build number, to be able to upload a new binary on iTunes Connect.
iOS app are created with a set of properties that are essential configuration information for a bundled executable. These properties are defined in the "Information Property List File", an XML formatted file, named Info.plist by convention.
Most important Info.plist properties are defined with gmibuildtool options such as --app-name and --app-version. However, you may need to define other properties that are out of the scope of the build tool. For example: background modes, device capabilities, screen orientations, permanent wifi, etc.
In order to define specific app properties, setup an Info.plist file in top-dir/gmi directory, before executing the gmibuildtool. Properties covered by the build tool will be overwritten, while any other property defined in the top-dir/gmi/Info.plist file will be left untouched.
For more details about the Info.plist file structure, see Apple developer site page about Information Property List File.
Follow the next steps to setup a GMI app build directory in order to create an iOS app, based on the default directory structure:
$ cd top-dir $ gmibuildtool \ --output myapp.ipa \ --app-name "My App" \ --app-version "v3.1.6" \ --bundle-id "com.example.mycompany.myapp" \ --mode release \ --certificate HGRW8... \ --provisioning "~/Library/MobileDevice/Provisioning Profiles/myapp.mobileprovision" \ --device phone
In order to create an iOS app using C extensions written in Objective-C as in Implementing C-Extensions for GMI, you need to setup a Makefile calling the FGLDIR/lib/Makefile-gmi generic makefile file.
... all: $(MODULES) $(FORMS) ... run: all userextension.dylib fglrun -e userextension main userextension.dylib: userextension.c fglmkext $? ... GMI_OPTIONS = \ APPNAME=MyApp \ BUNDLE_IDENTIFIER=com.mycomany.myapp \ IDENTITY=HGRW8... \ PROVISIONING_PROFILE=~/Library/MobileDevice/Provisioning\ Profiles/myapp.mobileprovision \ USEREXTENSION=userextension.o \ TARGET=phone GMI_MAKE = make -f $(FGLDIR)/lib/Makefile-gmi $(GMI_OPTIONS) gmi.all: all $(GMI_MMAKE) all gmi.install: all $(GMI_MMAKE) install gmi.uninstall: $(GMI_MMAKE) uninstall gmi.info: $(GMI_MMAKE) info gmi.clean: ~$(GMI_MMAKE) clean
The same technique can be used to build apps that must include custom front calls.
For complete examples, see FGLDIR/demo/MobileDemo/userextension and FGLDIR/demo/MobileDemo/userfrontcall