{"id":584,"date":"2017-03-10T15:25:04","date_gmt":"2017-03-10T14:25:04","guid":{"rendered":"http:\/\/www.renaudpradenc.com\/?p=584"},"modified":"2017-03-10T15:25:04","modified_gmt":"2017-03-10T14:25:04","slug":"luajit-on-ios","status":"publish","type":"post","link":"https:\/\/www.renaudpradenc.com\/?p=584","title":{"rendered":"LuaJIT on iOS"},"content":{"rendered":"<p>Someone created a fork, which essentially adds a script to build LuaJIT for the several architectures needed by iOS, then combines them using lipo:\u00a0<a href=\"https:\/\/github.com\/cailei\/luajit\">github.com\/cailei\/luajit<\/a>.<\/p>\n<p>I updated the script\u00a0by taking the latest SDK versions and removing the reference to gcc inside the Xcode bundle:<\/p>\n<pre class=\"lang:sh decode:true \">#\/bin\/sh\r\n\r\n# Check if the binary exists.\r\n# if [ -f \"lib\/libluajit.a\" ]; then\r\n#     exit 0\r\n# fi\r\n\r\nif [ ! -d lib\/temp ]; then\r\n    mkdir -p lib\/temp\r\nfi\r\n\r\nIXCODE=`xcode-select -print-path`\r\n\r\n# Build for MacOS (x86_64)\r\necho \"Building for macOS x86_84\"\r\nISDK=$IXCODE\/Platforms\/MacOSX.platform\/Developer\r\nISDKVER=MacOSX10.12.sdk\r\nISDKP=$ISDK\/usr\/bin\/\r\nISDKF=\"-arch x86_64 -isysroot $ISDK\/SDKs\/$ISDKVER\"\r\nmake clean\r\nmake TARGET_FLAGS=\"-arch x86_64\"\r\nmv src\/libluajit.a lib\/temp\/libluajit-macos-x86_64.a\r\n\r\n# Build for iOS device (armv7)\r\necho \"Building for iOS armv7\"\r\nISDK=$IXCODE\/Platforms\/iPhoneOS.platform\/Developer\r\nISDKVER=iPhoneOS10.2.sdk\r\nISDKP=\/usr\/bin\/\r\nISDKF=\"-arch armv7 -isysroot $ISDK\/SDKs\/$ISDKVER\"\r\nmake clean\r\nmake HOST_CC=\"gcc -m32 -arch i386\" CROSS=$ISDKP TARGET_FLAGS=\"$ISDKF\" \\\r\n     TARGET_SYS=iOS\r\nmv src\/libluajit.a lib\/temp\/libluajit-ios-armv7.a\r\n\r\n# Build for iOS device (armv7s)\r\necho \"Building for iOS armv7s\"\r\nISDKF=\"-arch armv7s -isysroot $ISDK\/SDKs\/$ISDKVER\"\r\nmake clean\r\nmake HOST_CC=\"gcc -m32 -arch i386\" CROSS=$ISDKP TARGET_FLAGS=\"$ISDKF\" \\\r\n     TARGET_SYS=iOS\r\nmv src\/libluajit.a lib\/temp\/libluajit-ios-armv7s.a\r\n\r\n# Build for iOS simulator\r\necho \"Building for iOS Simulator\"\r\nISDK=$IXCODE\/Platforms\/iPhoneSimulator.platform\/Developer\r\nISDKVER=iPhoneSimulator10.2.sdk\r\nISDKP=\/usr\/bin\/\r\nISDKF=\"-arch i386 -isysroot $ISDK\/SDKs\/$ISDKVER\"\r\nmake clean\r\nmake HOST_CFLAGS=\"-arch i386\" HOST_LDFLAGS=\"-arch i386\" TARGET_SYS=iOS TARGET=x86 CROSS=$ISDKP TARGET_FLAGS=\"$ISDKF\" \\\r\n     TARGET_SYS=iOS\r\nmv src\/libluajit.a lib\/temp\/libluajit-simulator.a\r\n\r\n# Combine all archives to one.\r\nlibtool -o lib\/libluajit.a lib\/temp\/*.a 2&gt; \/dev\/null\r\nrm -rf lib\/temp\r\nmake clean\r\n<\/pre>\n<p>The script works seamlessly with LuaJIT 2.0.4.<\/p>\n<p>Unfortunately, LuaJIT does not support the arm64 architecture yet.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Someone created a fork, which essentially adds a script to build LuaJIT for the several architectures needed by iOS, then combines them using lipo:\u00a0github.com\/cailei\/luajit. I updated the script\u00a0by taking the latest SDK versions and removing the reference to gcc inside the Xcode bundle: #\/bin\/sh # Check if the binary exists. # if [ -f &#8220;lib\/libluajit.a&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[89],"tags":[],"class_list":["post-584","post","type-post","status-publish","format-aside","hentry","category-english","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":3,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":587,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/587"}],"wp:attachment":[{"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.renaudpradenc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}