Skip to content

Latest commit

 

History

History
185 lines (113 loc) · 7.28 KB

README.md

File metadata and controls

185 lines (113 loc) · 7.28 KB

AidemPython

The Python framework used in Aidem X (an experimental extension to the Aidem app).

Usage

  1. 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.

  1. 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
  1. Add the lib folder "AidemPython" to the Xcode project using the "Create groups" option.

  2. Extend the added group and remove the references to the "python" folder from "AidemPython".

    Files left:

    • VMDownloadProcessButton folder
    • VMPython folder
    • *.a files
  3. 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.
  1. 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

  2. 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)
  3. 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.

  1. Edit Info.plist to add "App Transport Security Settings" with "Allow Arbitrary Loads" value to YES.

  2. (Optional) Add AFNetworking framework if need to use VMRemoteSourceDownloader to download source.

Further Reading about bitcode

3rd Party Packages for Python

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

Further Reading

About *.a file

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

About *.tbd file

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?".


About Python Cross-Compile

Posts:

Some related repos:

Libs about Python + Objc

  • pyobjus: Python module for accessing Objective-C classes as Python classes using Objective-C runtime reflection.

  • rubicon-objc:

    • 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:

About reducing the application size:

Issues about adding 3rd party pkgs:

Isseus about App Store Validation:


About Embed Python Programming


Troubleshoots


Others