The Python framework used in Aidem X (an experimental extension to the Aidem app).
- Pull all submodules.
$ git submodule init
$ git submodule update --recursive
Note
For 3rd party package repos in the folder "/site_packages", make sure their branch is aidem
.
- Use the script to copy the latest Python site pkgs from "site_packages" to "AidemPython/python/lib/python3.8/site-packages":
$ ./apply_latest_site_packages.sh
Note
Make sure you have trash
cmd installed.
$ brew install trash
-
Add the lib folder "AidemPython" to the Xcode project using the "Create groups" option.
-
Extend the added group and remove the references to the "python" folder from "AidemPython".
Files left:
- VMDownloadProcessButton folder
- VMPython folder
- *.a files
-
Re-add the "python" folder back using the "Create folder references" option.
Tip
- This step ensures that these included lib files will be grouped under the compiled app package.
- Make sure no *.pyc files are added.
-
Add the required *.tbd files:
6.1. Select project target
6.2. Select "Build Phases"
6.3. Extend "Link Binary With Libraries" section
6.4. Add files: libsqlite3.tbd, libz.tbd -
Update Project Settings:
- HEADER_SEARCH_PATHS: Add '$(PROJECT_DIR)/path/to/AidemPython/python' (recursive)
- LIBRARY_SEARCH_PATHS: Add '$(PROJECT_DIR)/path/to/AidemPython' (non-recursive)
-
Disable bitcode for iOS target: Set
ENABLE_BITCODE
to NO in the project settings.
Note
For iOS apps, bitcode is the default but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include the bitcode.
-
Edit Info.plist to add "App Transport Security Settings" with "Allow Arbitrary Loads" value to YES.
-
(Optional) Add AFNetworking framework if need to use VMRemoteSourceDownloader to download source.
If you need to add a 3rd party package for Python, just add it to this folder:
AidemPython/python/lib/python3.8/site-packages/
README.txt under "site-packages" folder:
This directory exists so that 3rd party packages can be installed here. Read the source for site.py for more details.
And if you need to test Python packages, it is recommended to use venv
:
$ python3 -m venv venv
$ . venv/bin/activate
These static libs will be compile-time-linked.
-
libpython3.a: Main cross-compiled Python lib for iOS, its related header & resource files are stored in "python" folder.
-
(NOT USED NOW) libpyobjus.a: Access Objective-C classes from Python. Pyobjus Doc.
-
libffi.a: FFI stands for Foreign Function Interface. It is the popular name for the interface that allows code written in one language to call code written in another language.
-
libcrypto.a & libssl.a: OpenSSL provides two primary libraries: libssl and libcrypto. The libcrypto library provides the fundamental cryptographic routines used by libssl. You can however use libcrypto without using libssl.
Tip
If want to view *.a files, use cmd (refer to "Contents of a static library"):
$ nm libxxx.a | less
These files associate to related dynamic libs, which will be runtime-linked.
.tbd
(Text-Based Dylib) files are new "text-based stub libraries", that provide a much more compact version of the stub libraries for use in the SDK, and help to significantly reduce its download size. Refer to "Why Xcode 7 shows *.tbd instead of *.dylib?".
Posts:
Some related repos:
Libs about Python + Objc
-
pyobjus: Python module for accessing Objective-C classes as Python classes using Objective-C runtime reflection.
-
- Use Python to instantiate objects defined in Objective-C
- Use Python to invoke methods on objects defined in Objective-C, and
- Subclass and extend Objective-C classes in Python.
About Kivy:
- kivy-ios
- "Programming Guide » IOS Prerequisites"
- "Installation on OS X"
- "Create a package for IOS"
- "Kivy-Installation"
About reducing the application size:
- "Reducing the application size"
- "Are there any ways to to decrease the size of the kivy app?"
- "Cleaning site-packages directory"
Issues about adding 3rd party pkgs:
Isseus about App Store Validation:
- "App store validation fails due to .so.o files"
- "Invalid Bundle Structure caused by .so files when uploading to App Store"
- "ld: warning: could not create compact unwind for _ffi_call_unix64"
- "certificate verify failed: unable to get local issuer certificate"