我正在尝试将简单的 kivy 应用程序编译到 IOS。
系统: -索诺玛14.6 -苹果M3芯片
main.py
:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
class MyApp(App):
def build(self):
self.label = Label(text="Hello!")
button = Button(text="Change")
button.bind(on_press=self.update_label)
layout = BoxLayout(orientation='vertical')
layout.add_widget(self.label)
layout.add_widget(button)
return layout
def update_label(self, instance):
self.label.text = "Button pressed!"
if __name__ == '__main__':
MyApp().run()
正如文档所说:
-创建虚拟环境。 main.py 附近:
python3.9 -m venv venv
-切换到 venv:
. venv/bin/activate
-安装kivy-ios:
pip install kivy-ios
(kivy-ios 2024.3.17)
-安装kivy:
pip install kivy==2.3.0
这些之后,
python main.py
成功返回我的应用程序。
使用 iOS&macOS 平台工具从 AppStore 安装 Xcode(版本 16.1)。
使用
xcode-select --install
& brew install autoconf automake libtool pkg-config
& brew link libtool
也安装了一些组件。
我的 libffi 配方版本是:
[INFO ] Using the bundled version for recipe 'libffi' libffi 3.4.4
当我尝试使用
toolchain build python3 kivy
构建简单的应用程序时,我收到有关 libffi 的错误。
[INFO ] Recipe order is ['hostopenssl', 'libffi', 'libpng', 'openssl', 'sdl2', 'hostpython3', 'sdl2_image', 'sdl2_mixer', 'sdl2_ttf', 'python3', 'ios', 'pyobjus', 'kivy']
hostopenssl
成功下载并安装。
libffi
下载成功但无法安装:
运行外壳:
[INFO ] Running Shell: /usr/bin/tar ('-C', '/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64', '-xv', '-z', '-f', '/Users/mertmehmetaraz/synapp/Test1/.cache/libffi-libffi-3.4.4.tar.gz') {'_iter': True, '_out_bufsize': 1, '_err_to_out': True}
...
...
[Succesfully OUTPUTS HERE]
...
...
[DEBUG ] configure: error: in `/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/build_iphoneos-armv7':
[DEBUG ] configure: error: C compiler cannot create executables
[DEBUG ] See `config.log' for more details
[DEBUG ] Traceback (most recent call last):
[DEBUG ] File "/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/generate-darwin-source-and-headers.py", line 314, in <module>
[DEBUG ] generate_source_and_headers(
[DEBUG ] File "/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/generate-darwin-source-and-headers.py", line 283, in generate_source_and_headers
[DEBUG ] build_target(ios_device_armv7_platform, platform_headers)
[DEBUG ] File "/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/generate-darwin-source-and-headers.py", line 232, in build_target
[DEBUG ] subprocess.check_call(['../configure', '-host', platform.triple], env=env)
[DEBUG ] File "/opt/homebrew/Cellar/[email protected]/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 373, in check_call
[DEBUG ] raise CalledProcessError(retcode, cmd)
[DEBUG ] subprocess.CalledProcessError: Command '['../configure', '-host', 'arm-apple-darwin11']' returned non-zero exit status 77.
Exception in thread background thread for pid 68035:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/[email protected]/3.9.20/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 1634, in wrap
fn(*rgs, **kwargs)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 2636, in background_thread
handle_exit_code(exit_code)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 2327, in fn
return self.command.handle_command_exit_code(exit_code)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 821, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /Users/mertmehmetaraz/synapp/Test1/venv/bin/python3 generate-darwin-source-and-headers.py --only-ios
STDOUT:
Skipping i386
checking build system type... aarch64-apple-darwin23.6.0
checking host system type... x86_64-apple-darwin13
checking target system type... x86_64-apple-darwin13
checking for gsed... sed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-apple-darwin13-strip... no
checking for strip... strip
checking for a race-free mkdir -p... ../install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for x86_64-apple-darwin13-gcc... xcrun -sdk iphonesimulator clang -target x86_64-apple-ios-simulator
chec... (21159 more, please see e.stdout)
STDERR:
Traceback (most recent call last):
File "/Users/mertmehmetaraz/synapp/Test1/venv/bin/toolchain", line 8, in <module>
sys.exit(main())
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1670, in main
ToolchainCL()
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1407, in __init__
getattr(self, args.command)()
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1483, in build
build_recipes(args.recipe, ctx)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 1231, in build_recipes
recipe.execute()
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 758, in execute
self.build_all()
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 78, in _cache_execution
f(self, *args, **kwargs)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 858, in build_all
self.build(plat)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 78, in _cache_execution
f(self, *args, **kwargs)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 844, in build
self.build_platform(plat)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/recipes/libffi/__init__.py", line 29, in build_platform
shprint(python3, "generate-darwin-source-and-headers.py", "--only-ios")
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/kivy_ios/toolchain.py", line 60, in shprint
for line in cmd:
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 877, in __next__
self.wait()
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 794, in wait
self.handle_command_exit_code(exit_code)
File "/Users/mertmehmetaraz/synapp/Test1/venv/lib/python3.9/site-packages/sh.py", line 821, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /Users/mertmehmetaraz/synapp/Test1/venv/bin/python3 generate-darwin-source-and-headers.py --only-ios
STDOUT:
Skipping i386
checking build system type... aarch64-apple-darwin23.6.0
checking host system type... x86_64-apple-darwin13
checking target system type... x86_64-apple-darwin13
checking for gsed... sed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for x86_64-apple-darwin13-strip... no
checking for strip... strip
checking for a race-free mkdir -p... ../install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for x86_64-apple-darwin13-gcc... xcrun -sdk iphonesimulator clang -target x86_64-apple-ios-simulator
chec... (21159 more, please see e.stdout)
STDERR:
config.log
:
This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake.
It was created by libffi configure 3.4.4, which was generated by GNU Autoconf 2.71. Invocation command line was
$ ../configure -host arm-apple-darwin11
## --------- ##
## Platform. ##
## --------- ##
hostname = Merts-MacBook-Air.local uname -m = arm64 uname -r = 23.6.0 uname -s = Darwin uname -v = Darwin Kernel Version 23.6.0: Fri Jul 5 17:56:39 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T8122
/usr/bin/uname -p = arm /bin/uname -X = unknown
/bin/arch = unknown /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = Mach kernel version: Darwin Kernel Version 23.6.0: Fri Jul 5 17:56:39 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T8122 Kernel configured for up to 8 processors. 8 processors are physically available. 8 processors are logically available. Processor type: arm64e (ARM64E) Processors active: 0 1 2 3 4 5 6 7 Primary memory available: 8.00 gigabytes Default processor set: 597 tasks, 2248 threads, 8 processors Load average: 3.50, Mach factor: 4.58 /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown
PATH: /usr/gnu/bin/ PATH: /usr/local/bin/ PATH: /bin/ PATH: /usr/bin/ PATH: ./
## ----------- ##
## Core tests. ##
## ----------- ##
configure:3073: looking for aux files: ltmain.sh compile missing install-sh config.guess config.sub configure:3086: trying ../ configure:3115: ../ltmain.sh found configure:3115: ../compile found configure:3115: ../missing found configure:3097: ../install-sh found configure:3115: ../config.guess found configure:3115: ../config.sub found configure:3236: checking build system type configure:3251: result: aarch64-apple-darwin23.6.0 configure:3271: checking host system type configure:3285: result: arm-apple-darwin11 configure:3305: checking target system type configure:3319: result: arm-apple-darwin11 configure:3417: checking for gsed configure:3453: result: sed configure:3482: checking for a BSD-compatible install configure:3555: result: /usr/bin/install -c configure:3566: checking whether build environment is sane configure:3621: result: yes configure:3673: checking for arm-apple-darwin11-strip configure:3708: result: no configure:3718: checking for strip configure:3739: found /usr/bin/strip configure:3750: result: strip configure:3776: checking for a race-free mkdir -p configure:3820: result: ../install-sh -c -d configure:3827: checking for gawk configure:3862: result: no configure:3827: checking for mawk configure:3862: result: no configure:3827: checking for nawk configure:3862: result: no configure:3827: checking for awk configure:3848: found /usr/bin/awk configure:3859: result: awk configure:3870: checking whether make sets $(MAKE) configure:3893: result: yes configure:3923: checking whether make supports nested variables configure:3941: result: yes configure:4105: checking for arm-apple-darwin11-gcc configure:4137: result: xcrun -sdk iphoneos clang -target armv7-apple-ios configure:4535: checking for C compiler version configure:4544: xcrun -sdk iphoneos clang -target armv7-apple-ios --version >&5 Apple clang version 16.0.0 (clang-1600.0.26.4) Target: armv7-apple-ios Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin configure:4555: $? = 0 configure:4544: xcrun -sdk iphoneos clang
-target armv7-apple-ios -v >&5 Apple clang version 16.0.0 (clang-1600.0.26.4) Target: armv7-apple-ios Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin configure:4555: $? = 0 configure:4544: xcrun -sdk iphoneos clang
-target armv7-apple-ios -V >&5 clang: error: argument to '-V' is missing (expected 1 value) clang: error: no input files configure:4555: $? = 1 configure:4544: xcrun -sdk iphoneos clang
-target armv7-apple-ios -qversion >&5 clang: error: unknown argument '-qversion'; did you mean '--version'? clang: error: no input files configure:4555: $? = 1 configure:4544: xcrun -sdk iphoneos clang
-target armv7-apple-ios -version >&5 clang: error: unknown argument '-version'; did you mean '--version'? clang: error: no input files configure:4555: $? = 1 configure:4575: checking whether the C compiler works configure:4597: xcrun -sdk iphoneos clang -target armv7-apple-ios -miphoneos-version-min=9.0 -fembed-bitcode conftest.c >&5 ld: warning: -bitcode_bundle is no longer supported and will be ignored ld: -mllvm and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together clang: error: linker command failed with exit code 1 (use -v to see invocation) configure:4601: $? = 1 configure:4641: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "libffi" |
#define PACKAGE_TARNAME "libffi" | #define PACKAGE_VERSION "3.4.4" | #define PACKAGE_STRING "libffi 3.4.4" | #define PACKAGE_BUGREPORT "http://github.com/libffi/libffi/issues" | #define PACKAGE_URL "" |
#define PACKAGE "libffi" | #define VERSION "3.4.4" | /* end confdefs.h. */ | | int | main (void) | { | | ; | return 0; | } configure:4646: error: in `/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/build_iphoneos-armv7': configure:4648: error: C compiler cannot create executables See `config.log' for more details
## ---------------- ##
## Cache variables. ##
## ---------------- ##
ac_cv_build=aarch64-apple-darwin23.6.0 ac_cv_env_CCASFLAGS_set= ac_cv_env_CCASFLAGS_value= ac_cv_env_CCAS_set= ac_cv_env_CCAS_value= ac_cv_env_CPPFLAGS_set= ac_cv_env_CPPFLAGS_value= ac_cv_env_CXXCPP_set= ac_cv_env_CXXCPP_value= ac_cv_env_LT_SYS_LIBRARY_PATH_set= ac_cv_env_LT_SYS_LIBRARY_PATH_value= ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set=set ac_cv_env_host_alias_value=arm-apple-darwin11 ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_host=arm-apple-darwin11 ac_cv_path_ax_enable_builddir_sed=sed ac_cv_path_install='/usr/bin/install -c' ac_cv_prog_AWK=awk ac_cv_prog_CC='xcrun -sdk iphoneos clang -target armv7-apple-ios' ac_cv_prog_ac_ct_STRIP=strip ac_cv_prog_make_make_set=yes ac_cv_target=arm-apple-darwin11 am_cv_make_support_nested_variables=yes
## ----------------- ##
## Output variables. ##
## ----------------- ##
ACLOCAL='${SHELL} '\''/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/missing'\'' aclocal-1.16' ALLOCA='' AMDEPBACKSLASH='' AMDEP_FALSE='' AMDEP_TRUE='' AMTAR='$${TAR-tar}' AM_BACKSLASH='\' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' AM_DEFAULT_VERBOSITY='1' AM_LTLDFLAGS='' AM_RUNTESTFLAGS='' AM_V='$(V)' AR='' AUTOCONF='${SHELL} '\''/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/missing'\'' autoconf' AUTOHEADER='${SHELL} '\''/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/missing'\'' autoheader' AUTOMAKE='${SHELL} '\''/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/missing'\'' automake-1.16' AWK='awk' BUILD_DOCS_FALSE='' BUILD_DOCS_TRUE='' CC='xcrun -sdk iphoneos clang -target armv7-apple-ios' CCAS='' CCASDEPMODE='' CCASFLAGS='' CCDEPMODE='' CFLAGS='-miphoneos-version-min=9.0 -fembed-bitcode' CPPFLAGS='' CSCOPE='cscope' CTAGS='ctags' CXX='' CXXCPP='' CXXDEPMODE='' CXXFLAGS='' CYGPATH_W='echo' DEFS='' DEPDIR='' DLLTOOL='' DSYMUTIL='' DUMPBIN='' ECHO_C='\c' ECHO_N='' ECHO_T='' EGREP='' ETAGS='etags' EXEEXT='' FFI_DEBUG_FALSE='' FFI_DEBUG_TRUE='' FFI_EXEC_TRAMPOLINE_TABLE='' FFI_EXEC_TRAMPOLINE_TABLE_FALSE='' FFI_EXEC_TRAMPOLINE_TABLE_TRUE='' FGREP='' FILECMD='' GREP='' HAVE_LONG_DOUBLE='' HAVE_LONG_DOUBLE_VARIANT='' INSTALL_DATA='${INSTALL} -m 644' INSTALL_PROGRAM='${INSTALL}' INSTALL_SCRIPT='${INSTALL}' INSTALL_STRIP_PROGRAM='$(install_sh) -c
-s' LD='xcrun -sdk iphoneos ld -target armv7-apple-ios' LDFLAGS='' LIBFFI_BUILD_VERSIONED_SHLIB_FALSE='' LIBFFI_BUILD_VERSIONED_SHLIB_GNU_FALSE='' LIBFFI_BUILD_VERSIONED_SHLIB_GNU_TRUE='' LIBFFI_BUILD_VERSIONED_SHLIB_SUN_FALSE='' LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE='' LIBFFI_BUILD_VERSIONED_SHLIB_TRUE='' LIBOBJS='' LIBS='' LIBTOOL='' LIPO='' LN_S='' LTLIBOBJS='' LT_SYS_LIBRARY_PATH='' MAINT='' MAINTAINER_MODE_FALSE='' MAINTAINER_MODE_TRUE='' MAKEINFO='${SHELL} '\''/Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/missing'\'' makeinfo' MANIFEST_TOOL='' MKDIR_P='../install-sh -c -d' NM='' NMEDIT='' OBJDUMP='' OBJEXT='' OPT_LDFLAGS='' OTOOL64='' OTOOL='' PACKAGE='libffi' PACKAGE_BUGREPORT='http://github.com/libffi/libffi/issues' PACKAGE_NAME='libffi' PACKAGE_STRING='libffi 3.4.4' PACKAGE_TARNAME='libffi' PACKAGE_URL='' PACKAGE_VERSION='3.4.4' PATH_SEPARATOR=':' PRTDIAG='' RANLIB='' READELF='' SECTION_LDFLAGS='' SED='' SET_MAKE='' SHELL='/bin/sh' STRIP='strip' TARGET='' TARGETDIR='' TARGET_OBJ='' TESTSUBDIR_FALSE='' TESTSUBDIR_TRUE='' VERSION='3.4.4' ac_ct_AR='' ac_ct_CC='' ac_ct_CXX='' ac_ct_DUMPBIN='' am__EXEEXT_FALSE='' am__EXEEXT_TRUE='' am__fastdepCCAS_FALSE='' am__fastdepCCAS_TRUE='' am__fastdepCC_FALSE='' am__fastdepCC_TRUE='' am__fastdepCXX_FALSE='' am__fastdepCXX_TRUE='' am__include='' am__isrc=' -I$(srcdir)' am__leading_dot='.' am__nodep='' am__quote='' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' ax_enable_builddir_sed='sed' bindir='${exec_prefix}/bin' build='aarch64-apple-darwin23.6.0' build_alias='' build_cpu='aarch64' build_os='darwin23.6.0' build_vendor='apple' datadir='${datarootdir}' datarootdir='${prefix}/share' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' dvidir='${docdir}' exec_prefix='NONE' host='arm-apple-darwin11' host_alias='arm-apple-darwin11' host_cpu='arm' host_os='darwin11' host_vendor='apple' htmldir='${docdir}' includedir='${prefix}/include' infodir='${datarootdir}/info' install_sh='${SHELL} /Users/mertmehmetaraz/synapp/Test1/build/libffi/iphoneos-arm64/libffi-3.4.4/install-sh' libdir='${exec_prefix}/lib' libexecdir='${exec_prefix}/libexec' localedir='${datarootdir}/locale' localstatedir='${prefix}/var' mandir='${datarootdir}/man' mkdir_p='$(MKDIR_P)' oldincludedir='/usr/include' pdfdir='${docdir}' prefix='NONE' program_transform_name='s,x,x,' psdir='${docdir}' runstatedir='${localstatedir}/run' sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com' sys_symbol_underscore='' sysconfdir='${prefix}/etc' target='arm-apple-darwin11' target_alias='arm-apple-darwin11' target_cpu='arm' target_os='darwin11' target_vendor='apple' tmake_file='' toolexecdir='' toolexeclibdir=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME "libffi"
#define PACKAGE_TARNAME "libffi"
#define PACKAGE_VERSION "3.4.4"
#define PACKAGE_STRING "libffi 3.4.4"
#define PACKAGE_BUGREPORT "http://github.com/libffi/libffi/issues"
#define PACKAGE_URL ""
#define PACKAGE "libffi"
#define VERSION "3.4.4"
configure: exit 77
将 libffi 版本更改为 3.4.5 后结果相同。任何帮助或想法都会很棒。谢谢。
在here找到解决方案:
pip uninstall kivy-ios
pip install git+https://github.com/kivy/kivy-ios