Python 在 iOS 调整?

Python in iOS Tweak?

我尝试使用 https://github.com/pybee/Python-Apple-support(python 3.5.3 ios 库)

编辑:我尝试添加 HackScript_PRIVATE_FRAMEWORKS = Python.framework 但它说 Python/Python.h 在我尝试包含时不存在。

Tweak.xm:

#include "Python\Python.framework\Versions.5\Resources\include\python3.5\Python.h"
%hook SpringBoard

- (void)applicationDidFinishLaunching:(id)application {
    %orig;

    PyObject *py_main, *py_dict;
    py_main = PyImport_AddModule("__main__");
  py_dict = PyModule_GetDict(py_main);

    PyObject *PyRes = PyRun_String("print(\"This is a test message from HackScript\")", Py_single_input, py_dict, py_dict);

    PyObject *PyResRep = PyObject_Str(PyRes);

    char *PyResCStr = PyBytes_AS_STRING(PyResRep);
    NSString *PyResStr = @(PyResCStr);

    UIAlertView *alert1 = [[objc_getClass("UIAlertView") alloc] initWithTitle:@"Welcome"
        message:PyResStr
        delegate:self
        cancelButtonTitle:@"k"
        otherButtonTitles:nil];

        [alert1 show];

        [alert1 release];
}

%end

生成文件:

export ARCHS = armv7 armv7s arm64
export TARGET = iphone:clang:8.1:8.1
export SDKVERSION=8.1

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = HackScript
HackScript_FILES = Tweak.xm

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
    install.exec "killall -9 SpringBoard"

但是当我包含 Python.h 并尝试访问 python 对象时,它在编译时给我这个错误:

Undefined symbols for architecture armv7:
  "_PyImport_AddModule", referenced from:
      __ZL67_logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$P11SpringBoardP13objc_selectorP11objc_object in Tweak.xm.2544b2e5.o
  "_PyModule_GetDict", referenced from:
      __ZL67_logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$P11SpringBoardP13objc_selectorP11objc_object in Tweak.xm.2544b2e5.o
  "_PyObject_Str", referenced from:
      __ZL67_logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$P11SpringBoardP13objc_selectorP11objc_object in Tweak.xm.2544b2e5.o
  "_PyRun_StringFlags", referenced from:
      __ZL67_logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$P11SpringBoardP13objc_selectorP11objc_object in Tweak.xm.2544b2e5.o
ld: symbol(s) not found for architecture armv7
arm64-apple-darwin14-clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [/opt/theos/makefiles/instance/library.mk:33: /home/jujha/projects/hackscript/.theos/obj/debug/armv7/HackScript.dylib] Error 1
make[2]: *** [/opt/theos/makefiles/instance/library.mk:32: /home/jujha/projects/hackscript/.theos/obj/debug/armv7/HackScript.dylib] Error 2
make[1]: *** [/opt/theos/makefiles/instance/library.mk:24: internal-library-all_] Error 2
make: *** [/opt/theos/makefiles/master/rules.mk:90: HackScript.all.tweak.variables] Error 2

如果这行不通,谁能推荐一种我可以嵌入到我的 theos 调整中的脚本语言?

您是否在复制阶段将 Python.framework 复制到您的二进制文件中?

请参阅 GitHub 上的问题部分。