7. iOS ã§ Python ã䜿ã¶
- èè :
Russell Keith-Magee (2024-03)
iOS ã«ããã Pythonã¯ããã¹ã¯ããããã©ãããã©ãŒã ã«ããã Python ãšã¯ç°ãªããŸãã ãã¹ã¯ããããã©ãããã©ãŒã ã§ã¯ã Python ã¯äžè¬çã«ã³ã³ãã¥ãŒã¿ãŒã®ã©ã®ãŠãŒã¶ãŒã§ã䜿ããã·ã¹ãã ãªãœãŒã¹ãšããŠã€ã³ã¹ããŒã«ãããŸãããããŠããŠãŒã¶ãŒã¯ python å®è¡å¯èœãã¡ã€ã«ãå®è¡ããŠå¯Ÿè©±åããã³ããã«ã³ãã³ããå ¥åãããã Python ã¹ã¯ãªãããå®è¡ãããããŠã Python ã䜿çšããããšãã§ããã®ã§ãã
iOS ã«ãããŠã¯ãã·ã¹ãã ãªãœãŒã¹ãšããŠã®ã€ã³ã¹ããŒã«ãšããæŠå¿µã¯ãããŸããããœãããŠã§ã¢é åžãå¯èœãªã®ã¯ã "ã¢ããª" ã ãã§ãããŸãã python å®è¡å¯èœãã¡ã€ã«ãå®è¡ãããã Python ã® REPL ã䜿çšããããããã³ã³ãœãŒã«ãååšããŸããã
ãã®ããã Python ã iOS äžã§äœ¿ããã äžã€ã®æ¹æ³ã¯ãåã蟌ã¿ã¢ãŒããã€ãŸãããã€ãã£ã iOS ã¢ããªã±ãŒã·ã§ã³ãæžãã libPython ã䜿çšã㊠Python ã€ã³ã¿ãŒããªã¿ãåã蟌ã¿ããã㊠Python åã蟌㿠API ã䜿çšã㊠Python ã³ãŒããåŒã³åºãããšã§ãã ããã«ãããå®å
šãª Python ã€ã³ã¿ãŒããªã¿ãæšæºã©ã€ãã©ãªã åã³ Python ã®ã³ãŒããã iOS App Store ãçµç±ããŠé
åžå¯èœãªã¹ã¿ã³ãã¢ããŒã³ãªãã³ãã«ãšããŠããã±ãŒãžåãããŸãã
ãããåã㊠iOS ã¢ããªã Python ã§æžãããšã詊ã¿ãŠãããªãã BeeWare ã Kivy ãšãã£ããããžã§ã¯ãã¯ããããããããããŠãŒã¶ãŒäœéšãæäŸããã§ãããããããã®ãããžã§ã¯ã㯠iOS ãããžã§ã¯ããå®è¡ããããšã«é¢é£ããè€éãªããšã管çããã®ã§ãããªã㯠Python ã®ã³ãŒãã«éäžããã ãã§è¯ããªããŸãã
7.1. iOS ã©ã³ã¿ã€ã ã§ã® Python¶
7.1.1. iOS ã®ããŒãžã§ã³äºææ§Â¶
ãµããŒããããæå°ã® iOS ããŒãžã§ã³ã¯ãã³ã³ãã€ã«æã« configure ã® --host ãªãã·ã§ã³ã䜿çšããŠæå®ã§ããŸããããã©ã«ãã§ã¯ã iOS çšã«ã³ã³ãã€ã«ããå Žåã Python ã¯æå°ã§ 13.0 ã® iOS ããŒãžã§ã³ããµããŒãããããã«ã³ã³ãã€ã«ãããŸããç°ãªãæå° iOS ããŒãžã§ã³ã䜿çšããã«ã¯ã --host åŒæ°ã®äžéšãšããŠããŒãžã§ã³çªå·ãæäŸããŸããäŸãã° --host=arm64-apple-ios15.4-simulator ãšãããšã ARM64 ã·ãã¥ã¬ãŒã¿ãŒçšã®ãã«ãã Deployment Target 15.4 ã§ã³ã³ãã€ã«ããŸãã
7.1.2. ãã©ãããã©ãŒã ã®èå¥Â¶
iOS äžã§å®è¡ããŠããå Žåã sys.platform 㯠ios ãšãªããŸããã¢ããªãã·ãã¥ã¬ãŒã¿ãŒã§å®è¡ãããŠããããç©çããã€ã¹ã§å®è¡ãããŠãããã«ãããããã iPhone ãŸã㯠iPad ã§ã¯ãã®å€ãšãªããŸãã
iOS ããŒãžã§ã³ãããã€ã¹ã®ã¢ãã«ãããã€ã¹ãã·ãã¥ã¬ãŒã¿ãŒã§ãããã©ãããå«ãããç¹å®ã®ã©ã³ã¿ã€ã ç°å¢ã«ã€ããŠã®æ
å ±ã¯ã platform.ios_ver() ã䜿çšããŠååŸã§ããŸãã platform.system() ã¯ãããã€ã¹ã«ãã iOS ãŸã㯠iPadOS ãå ±åããŸãã
os.uname() ã¯ãã«ãŒãã«ã¬ãã«ã®è©³çްãå ±åããŸãããã㯠Darwin ã®ååãå ±åããŸãã
7.1.3. æšæºã©ã€ãã©ãªã®å©çšå¯èœæ§Â¶
Python ã® æšæºã©ã€ãã©ãªã«ã¯ã iOS ã«ãããããã€ãã®éèŠãªçç¥ãå¶éããããŸãã詳现㯠iOS åãã® API å©çšå¯èœæ§ã¬ã€ã ãåç §ããŠãã ããã
7.1.4. ãã€ããªæ¡åŒµã¢ãžã¥ãŒã«Â¶
ãã©ãããã©ãŒã ãšããŠã® iOS ã«ã€ããŠã®éèŠãªéãã®äžã€ã¯ã App Store ã§ã®é åžãã¢ããªã±ãŒã·ã§ã³ã®ããã±ãŒãžã³ã°ã«å³ããæ¡ä»¶ã課ããšããããšã§ãã ãããã®æ¡ä»¶ã®äžã€ã¯ããã€ããªæ¡åŒµã¢ãžã¥ãŒã«ã®é åžæ¹æ³ãèŠå®ããŸãã
iOS App Store ã§ã¯ã iOS ã¢ããªã®å
šãŠã®ãã€ããªã¢ãžã¥ãŒã«ããããã±ãŒãžåãããã¢ããªã® Frameworks ãã©ã«ãã«ä¿åããããé©åãªã¡ã¿ããŒã¿ä»ãã®ãã¬ãŒã ã¯ãŒã¯ã«å«ãŸããåçã©ã€ãã©ãªã§ããå¿
èŠããããŸãããã¬ãŒã ã¯ãŒã¯ããšã«ãã€ããªã¯äžã€ã ãã§ã Frameworks ãã©ã«ãã®å€ã«å®è¡å¯èœãã€ããªããŒã¿ãèšçœ®ããããšã¯ã§ããŸããã
ããã¯ããã€ããªæ¡åŒµã¢ãžã¥ãŒã«ã sys.path äžã®ã©ã®å Žæããã§ãèªã¿èŸŒã¿å¯èœãªãéåžžã® Python ã®ãã€ããªé
åžã®ã¢ãããŒããšè¡çªããŸãã 確å®ã« App Store ããªã·ãŒã«åŸãããã«ã iOS ãããžã§ã¯ãã¯ãããã® Python ããã±ãŒãžã«ãã .so ãã€ããªã¢ãžã¥ãŒã«ããåå¥ã®ãã¹ã¿ã³ãã¢ããŒã³ã§ãé©åãªã¡ã¿ããŒã¿ãšçœ²åä»ãã®ãã¬ãŒã ã¯ãŒã¯ã«å€æããåŸåŠçãè¡ããªããã°ãªããŸãããã©ã®ããã«åŸåŠçãè¡ããã®è©³çްã¯ã ãããžã§ã¯ãã« Python ã远å ãã ã®ã¬ã€ããåç
§ããŠãã ããã
Python ãæ°ããå Žæã«ãããã€ããªãèŠã€ããããšãå©ããããã«ã sys.path ã«ããå
ã® .so ãã¡ã€ã«ã¯ .fwork ãã¡ã€ã«ã«çœ®ãæããããŸãã ãã®ãã¡ã€ã«ã¯ãã¢ããªãã³ãã«ããã®ã¬ãŒã ã¯ãŒã¯ãã€ããªã®çžå¯Ÿãã¹ãå«ãããã¹ããã¡ã€ã«ã§ãããã¬ãŒã ã¯ãŒã¯ãå
ã®å Žæã«è§£æ±ºã§ããããã«ããããã«ã¯ããã¬ãŒã ã¯ãŒã¯ã¯ãã¢ããªãã³ãã«ããã® .fwork ãã¡ã€ã«ã®çžå¯Ÿãã¹ãå«ãŸããã .origin ãã¡ã€ã«ãå«ãå¿
èŠããããŸãã
äŸãã°ãfrom foo.bar import _whiz ãã€ã³ããŒãããå ŽåãèããŠã¿ãŸãããã _whiz ããã€ããªã¢ãžã¥ãŒã« sources/foo/bar/_whiz.abi3.so ã§å®è£
ãããŠããã sources ã®ã¢ããªã±ãŒã·ã§ã³ãã³ãã«ããã®çžå¯Ÿãã¹ã sys.path ã«ç»é²ãããŠããŸãããã®ã¢ãžã¥ãŒã«ã¯ Frameworks/foo.bar._whiz.framework/foo.bar._whiz (ãã¬ãŒã ã¯ãŒã¯åã¯ã¢ãžã¥ãŒã«ã®å®å
šãªã€ã³ããŒããã¹ããåœåãããŠããŸã) ãšããŠããã€ããªããã¬ãŒã ã¯ãŒã¯ãšããŠèå¥ãã Info.plist ãã¡ã€ã«ã .framework ãã£ã¬ã¯ããªå
ã«èšçœ®ããŠé
åžããªããã°ãªããŸããã foo.bar._whiz ã¢ãžã¥ãŒã«ã¯ãå
ã®å Žæã§ã Frameworks/foo.bar._whiz/foo.bar._whiz ã®ãã¹ãå«ã sources/foo/bar/_whiz.abi3.fwork ããŒã«ãŒãã¡ã€ã«ã«èšè¿°ãããŸãã ãŸãããã¬ãŒã ã¯ãŒã¯ã¯ã .fwork ãžã®ãã¹ãå«ã Frameworks/foo.bar._whiz.framework/foo.bar._whiz.origin ãå«ãŸãªããã°ãªããŸããã
iOS äžã§å®è¡ããŠããå Žåã Python ã€ã³ã¿ãŒããªã¿ã¯ .fwork ãã¡ã€ã«ãèªã¿èŸŒãã§ã€ã³ããŒãããããšãã§ãã AppleFrameworkLoader ãã€ã³ã¹ããŒã«ããŸããã€ã³ããŒãããããšããã€ããªã¢ãžã¥ãŒã«ã® __file__ 屿§ã¯ .fwork ãã¡ã€ã«ã®å Žæãè¿ããŸããäžæ¹ãèªã¿èŸŒãŸããã¢ãžã¥ãŒã«ã® ModuleSpec ã¯ãã¬ãŒã ã¯ãŒã¯ãã©ã«ãã®ãã€ããªã®å Žæãšã㊠origin ãè¿ããŸãã
7.1.5. ã³ã³ãã€ã©ã¹ã¿ããã€ããªÂ¶
Xcode ã¯ã iOS çšã®æç€ºçãªã³ã³ãã€ã©ãæäŸããŠããŸããã代ããã«ãå®å
šãªã³ã³ãã€ã©ã®ãã¹ã解決ãã xcrun ã¹ã¯ãªããã䜿çšããŸã (ããšãã° xcrun --sdk iphoneos clang 㯠iPhone ããã€ã¹çšã® clang ãååŸããŸã) ãããããããã¯2ã€ã®åé¡ãåŒãèµ·ãããŸã:
xcrunã®åºåã¯ãã·ã³åºæã®ãã¹ãå«ã¿ããŠãŒã¶ãŒéã§å ±æã§ããªã sysconfig ã¢ãžã¥ãŒã«ã«ã€ãªãããããã«ããã
CC/CPP/LD/ARå®çŸ©ã«ã¹ããŒã¹ãå«ãŸããããšã«ãªããŸããå€ãã® C ãšã³ã·ã¹ãã ããŒã«ããæåã®ã¹ããŒã¹ã§ã³ãã³ãã©ã€ã³ãåå²ããã³ã³ãã€ã©å®è¡ãã¡ã€ã«ãååŸã§ããããšãåæãšããŠããŸããããããxcrunã䜿çšããå Žåã¯ããã§ã¯ãããŸããã
ãããã®åé¡ãé¿ããããã Python ã¯ãããã®ããŒã«çšã®ã¹ã¿ããæäŸããŸããããããã®ã¹ã¿ãã¯ãã³ã³ãã€ã«ããã iOS ãã¬ãŒã ã¯ãŒã¯ãšãšãã«é
åžããã bin ãã©ã«ãã§é
åžããããåºç€ã® xcrun ããŒã«ã®ã·ã§ã«ã¹ã¯ãªããã©ãããŒã§ãããããã®ã¹ã¯ãªããã¯åé
眮å¯èœã§ãåžžã«é©åãªããŒã«ã«ã·ã¹ãã ãã¹ã«è§£æ±ºãããŸãããããã®ã¹ã¯ãªããããã¬ãŒã ã¯ãŒã¯ã䌎ã bin ãã©ã«ããŒã«å«ããããšã§ã sysconfig ã¢ãžã¥ãŒã«ã¯ãšã³ããŠãŒã¶ãŒãèªèº«ã®ã¢ãžã¥ãŒã«ãã³ã³ãã€ã«ããã®ã«æçšã«ãªããŸããiOS çšã® ãµãŒãããŒãã£ã® Python ã¢ãžã¥ãŒã«ãã³ã³ãã€ã«ãããšãã¯ããããã®ã¹ã¿ããã€ããªããã¹äžã«ããããšã確èªããã¹ãã§ãã
7.2. iOS ã§ã® Python ã®ã€ã³ã¹ããŒã«Â¶
7.2.1. iOS ã¢ããªãã«ãçšã®ããŒã«Â¶
iOS åãã®ãã«ãã«ã¯ã Apple ã® Xcode ã®ããŒã«ã䜿çšããŸããXcode ã®ææ°ã®å®å®ãªãªãŒã¹ã䜿çšããããšãåŒ·ãæšå¥šããŸããApple ã¯å€ã macOS ã®ããŒãžã§ã³åãã«ã¯ Xcode ãã¡ã³ããã³ã¹ããªããããããã«ã¯æã (ãŸãã¯äºçªç®ã«) æè¿ã«ãªãªãŒã¹ããã macOS ã®ããŒãžã§ã³ãå¿ èŠã§ãã Xcode ã³ãã³ãã©ã€ã³ããŒã«ã¯ iOS éçºã«ã¯äžååã§ãããå®å šãª Xcode ã®ã€ã³ã¹ããŒã«ãå¿ èŠã§ãã
iOS ã·ãã¥ã¬ãŒã¿ãŒäžã§ã³ãŒããå®è¡ãããå Žåã¯ã iOS Simulator ãã©ãããã©ãŒã ãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã Xcode ãåããŠå®è¡ãããšãã iOS Simulator ãã©ãããã©ãŒã ãéžæããããã³ããã衚瀺ãããã¯ãã§ãã代ããã«ã Xcode ã® Settings ããã«ã® Platforms ã¿ããã iOS Simulator ãã©ãããã©ãŒã ãéžæããŠè¿œå ããããšãã§ããŸãã
7.2.2. iOS ãããžã§ã¯ãã« Python ã远å ãã¶
Python ã¯ã Swift ãŸã㯠Objective-C ã䜿ã£ãŠãã©ã® iOS ãããžã§ã¯ãã«ã§ã远å ã§ããŸãã以äžã®äŸã§ã¯ã Objective-C ã䜿çšããŠããŸãã Swift ã䜿ãå Žåã¯ã PythonKit ã®ãããªã©ã€ãã©ãªã圹ã«ç«ã€ãããããŸããã
Python ã iOS Xcode ãããžã§ã¯ãã«è¿œå ããã«ã¯:
Build or obtain a Python
XCFramework. See the instructions in Apple/iOS/README.md (in the CPython source distribution) for details on how to build a PythonXCFramework. At a minimum, you will need a build that supportsarm64-apple-ios, plus one of eitherarm64-apple-ios-simulatororx86_64-apple-ios-simulator.XCframeworkã iOS ãããžã§ã¯ãã«ãã©ãã°ããŸãã以éã®èª¬æã§ã¯ã ãããžã§ã¯ãã®ã«ãŒãã«XCframeworkãèšçœ®ãããã®ãšä»®å®ããŸããããã¹ãå¿ èŠã«å¿ããŠèª¿æŽããããšã§ãä»ã®å Žæã䜿çšããããšãåºæ¥ãŸããã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒããã Xcode ãããžã§ã¯ãã«ãã©ã«ããŒãšããŠè¿œå ããŸãã以éã®èª¬æã§ã¯ã ãããžã§ã¯ãã®ã«ãŒãã«
appãšããååã®ãŠãŒã¶ãŒã³ãŒããå ¥ã£ããã©ã«ããèšçœ®ãããã®ãšä»®å®ããŸããããã¹ãå¿ èŠã«å¿ããŠèª¿æŽããããšã§ãä»ã®å Žæã䜿çšããããšãåºæ¥ãŸãããã©ã«ããã¢ããªã®ã¿ãŒã²ããã«é¢é£ä»ããããŠããããšã確èªããŠãã ãããXcode ãããžã§ã¯ãã®ã«ãŒãããŒããéžæããããšã§ãã¢ããªã®ã¿ãŒã²ãããéžæããŠãã ããããããšãã¿ãŒã²ããåããµã€ãããŒã«çŸããã¯ãã§ãã
"General" ã®èšå®ã® "Frameworks, Libraries and Embedded Content" ã«ã "Embed & Sign" ãéžæããŠ
Python.xcframeworkã远å ããŠãã ããã"Build Settings" ã¿ãã§ã次ã®é ç®ãä¿®æ£ããŠãã ãã:
Build Options
User Script Sandboxing: No
Enable Testability: Yes
Search Paths
Framework Search Paths:
$(PROJECT_DIR)Header Search Paths:
"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers"
Apple Clang - Warnings - All languages
Quoted Include In Framework Header: No
Python ã®æšæºã©ã€ãã©ãªããã³ç¬èªã® Python ãã€ããªäŸåé¢ä¿ãåŠçãããã«ãã¹ãããã远å ããŸãã "Build Phases" ã¿ãã§ãæ°ãã "Run Script" ãã«ãã¹ãããã "Embed Frameworks" ã¹ãããã®åã«è¿œå ããŠãã ãããã¹ãããã®åå㯠"Process Python libraries" ã«ããŠã "Based on dependency analysis" ã®ãã§ãã¯ããã¯ã¹ãå€ããã¹ã¯ãªããã®å å®¹ãæ¬¡ã®ããã«èšå®ããŠãã ãã:
set -e source $PROJECT_DIR/Python.xcframework/build/build_utils.sh install_python Python.xcframework app
ãã XCFramework ããããžã§ã¯ãã®ã«ãŒã以å€ã®ã©ããã«èšçœ®ããå Žåã¯ãäžã€ç®ã®åŒæ°ãžã®ãã¹ãä¿®æ£ããŠãã ããã
Python ã€ã³ã¿ãŒããªã¿ãåã蟌ã¿ã¢ãŒãã§åæåã»äœ¿çšãã Objective C ã³ãŒãã远å ããŸããæ¬¡ã®ããšã確èªããå¿ èŠããããŸã:
UTF-8 ã¢ãŒã (
PyPreConfig.utf8_mode) ã æå¹ ã«ãªã£ãŠããããšBuffered stdio (
PyConfig.buffered_stdio) ã ç¡å¹ ã«ãªã£ãŠããããšãã€ãã³ãŒãã®æžã蟌㿠(
PyConfig.write_bytecode) ã ç¡å¹ ã«ãªã£ãŠããããšã·ã°ãã«ãã³ãã© (
PyConfig.install_signal_handlers) ã æå¹ ã«ãªã£ãŠããããšã·ã¹ãã ãã° (
PyConfig.use_system_logger) ã æå¹ ã«ãªã£ãŠããããš (ãªãã·ã§ã³ã§ãããåŒ·ãæšå¥šãããããã©ã«ãã§æå¹åãããŠããŸã)ã€ã³ã¿ãŒããªã¿ã®
PYTHONHOMEãã¢ããªãã³ãã«ã®pythonãµããã©ã«ããæãããã«æ§æãããŠããããšã€ã³ã¿ãŒããªã¿ã®
PYTHONPATHãæ¬¡ã®ãã®ãå«ãããšã¢ããªã®ãã³ãã«ã®
python/lib/python3.Xãµããã©ã«ãã¢ããªã®ãã³ãã«ã®
python/lib/python3.X/lib-dynloadãµããã©ã«ãã¢ããªã®ãã³ãã«ã®
appãµããã©ã«ã
ã¢ããªã®ãã³ãã«ã®å Žæã¯
[[NSBundle mainBundle] resourcePath]ãçšããŠååŸã§ããŸãã
ãããã®èª¬æã®æé 7, 8 㯠app ãšããååã®ãã äžã€ã®çŽç²ãª Python ã¢ããªã±ãŒã·ã§ã³ã®ã³ãŒãã®ãã©ã«ããããããšãåæãšããŠããŸãããããµãŒãããŒãã£ã®ãã€ããªã¢ãžã¥ãŒã«ãã¢ããªã«å«ãŸããå Žåã¯ãããã€ãã®è¿œå ã®æé ãå¿
èŠã§ã:
ãµãŒãããŒãã£ã®ãã€ããªãå«ããã©ã«ãããã¢ããªã®ã¿ãŒã²ããã«é¢é£ä»ããããŠããããŸãã¯æé 7 ã®äžéšãšããŠæç€ºçã«ã³ããŒãããŠããããšã確èªããå¿ èŠããããŸããæé 7 ã§ã¯ãç¹å®ã®ãã«ããã¿ãŒã²ãããšãããã©ãããã©ãŒã ã«é©åã§ãªããã€ããªãåãé€ã(ã€ãŸããããã·ãã¥ã¬ãŒã¿ãŒãã¿ãŒã²ãããšããã¢ããªããã«ãããŠããå Žåã¯ãããã€ã¹ãã€ããªãåé€ãã)ããšãå¿ èŠã§ãã
ãµãŒãããŒãã£ã®ããã±ãŒãžã«å¥ã®ãã©ã«ãã䜿çšããŠããå Žåã¯ãæé 7 ã§ãã©ã«ãã
install_pythonã®åŒã³åºãã®æ«å°Ÿã«è¿œå ãããæé 8 ã®PYTHONPATHèšå®ã®äžã€ãšããŠè¿œå ãããŠããããšã確èªããŠãã ããããµãŒãããŒãã£ããã±ãŒãžãå«ããã©ã«ãã
.pthãã¡ã€ã«ãå«ãå ŽåãçŽæ¥PYTHONPATHãsys.pathã«è¿œå ããã®ã§ã¯ãªãããã®ãã©ã«ãã (site.addsitedir()ã䜿çšããŠ) ãµã€ããã£ã¬ã¯ããªãšããŠè¿œå ããå¿ èŠããããŸãã
7.2.3. Python ããã±ãŒãžã®ãã¹ã¶
The CPython source tree contains a testbed project that is used to run the CPython test suite on the iOS simulator. This testbed can also be used as a testbed project for running your Python library's test suite on iOS.
After building or obtaining an iOS XCFramework (see Apple/iOS/README.md
for details), create a clone of the Python iOS testbed project. If you used the
Apple build script to build the XCframework, you can run:
$ python cross-build/iOS/testbed clone --app <module1 ã®ãã¹> --app <module2 ã®ãã¹> app-testbed
ãããã¯ãç¬èªã® XCFramework ã調éããå Žåã¯ã次ã®ã³ãã³ããå®è¡ããŠè¡ããŸã:
$ python Apple/testbed clone --platform iOS --framework <path/to/Python.xcframework> --app <path/to/module1> --app <path/to/module2> app-testbed
--app ãã©ã°ã§æå®ããããã©ã«ãã¯ãè€è£œããããã¹ãããããããžã§ã¯ãã«ã³ããŒãããŸããçµæãšããŠåŸããããã¹ããããã¯ã app-testbed ãã©ã«ãã®äžã«äœæãããŸãããã®äŸã§ã¯ã module1 ãš module2 ããå®è¡æã«ã€ã³ããŒãå¯èœãªã¢ãžã¥ãŒã«ãšãªããŸãããããžã§ã¯ãã«è¿œå ã®äŸåé¢ä¿ãããå Žåã¯ã (pip install --target app-testbed/Testbed/app_packages ããªã©äœ¿çšããŠ) ããã㯠app-testbed/Testbed/app_packages ãã©ã«ãã®äžã«ã€ã³ã¹ããŒã«ã§ããŸãã
You can then use the app-testbed folder to run the test suite for your app,
For example, if module1.tests was the entry point to your test suite, you
could run:
$ python app-testbed run -- module1.tests
This is the equivalent of running python -m module1.tests on a desktop
Python build. Any arguments after the -- will be passed to the testbed as
if they were arguments to python -m on a desktop machine.
You can also open the testbed project in Xcode by running:
$ open app-testbed/iOSTestbed.xcodeproj
This will allow you to use the full Xcode suite of tools for debugging.
The arguments used to run the test suite are defined as part of the test plan. To modify the test plan, select the test plan node of the project tree (it should be the first child of the root node), and select the "Configurations" tab. Modify the "Arguments Passed On Launch" value to change the testing arguments.
The test plan also disables parallel testing, and specifies the use of the
Testbed.lldbinit file for providing configuration of the debugger. The
default debugger configuration disables automatic breakpoints on the
SIGINT, SIGUSR1, SIGUSR2, and SIGXFSZ signals.
7.3. App Store ã³ã³ãã©ã€ã¢ã³ã¹Â¶
The only mechanism for distributing apps to third-party iOS devices is to submit the app to the iOS App Store; apps submitted for distribution must pass Apple's app review process. This process includes a set of automated validation rules that inspect the submitted application bundle for problematic code. There are some steps that must be taken to ensure that your app will be able to pass these validation steps.
7.3.1. æšæºã©ã€ãã©ãªå ã®äºææ§ã®ãªãã³ãŒã¶
Python ã®æšæºã©ã€ãã©ãªã«ã¯ããããã®èªåã«ãŒã«ã«éåããããšãç¥ãããŠããã³ãŒããããã€ãå«ãŸããŠããŸãããããã®éåã¯èª€æ€åºã§ãããšæãããŸããã Apple ã®å¯©æ»ã«ãŒã«ã«ç°è°ãå±ããããšã¯ã§ããŸããããã®ããã Python ã®æšæºã©ã€ãã©ãªããã¢ããªã App Store 審æ»ã«åæ Œããããä¿®æ£ããå¿ èŠããããŸãã
Python ã®ãœãŒã¹ããªãŒã¯ã App Store 審æ»ããã»ã¹ã§åé¡ãåŒãèµ·ããããšãç¥ãããŠãããã¹ãŠã®ã³ãŒããåé€ãã ããããã¡ã€ã« ãå«ãã§ããŸãããã®ããã㯠iOS çšã®ãã«ãæã«èªåçã«é©çšãããŸãã
7.3.2. ãã©ã€ãã·ãŒãããã§ã¹ã¶
In April 2025, Apple introduced a requirement for certain third-party
libraries to provide a Privacy Manifest.
As a result, if you have a binary module that uses one of the affected
libraries, you must provide an .xcprivacy file for that library.
OpenSSL is one library affected by this requirement, but there are others.
If you produce a binary module named mymodule.so, and use you the Xcode
build script described in step 7 above, you can place a mymodule.xcprivacy
file next to mymodule.so, and the privacy manifest will be installed into
the required location when the binary module is converted into a framework.