HikariObfuscator/Hikari

Use Hikari's toolchain with "Theos for iOS" (logos)

xelahot opened this issue · 13 comments

Hi it's my first time writing an issue on github, i'm not sure if that's the place to ask but here it is.

I'm working on a big tweak and it uses logos syntax and a makefile. I have "Theos for iOS" installed on my iPhone and I'm usually compiling tweaks directly on it with the make package command with MTerminal after SSHing the source code on my iPhone. I never tried to develop tweaks a different way before so that's scary to me.

Now a friend told me about Hikari's toolchain and I would like to try compiling my tweak with it. The problem is I have no idea how I can "install" this in Theos or if it's possible to do so and compile a tweak with logos syntax. If that's possible could someone explain me how I could do it and if compiling works the same? If not, what are my best options (so I don't have to edit my tweak that is nearly finished).

Check https://github.com/HikariObfuscator/TweakObfuscateDemo for an example Makefile. Since you are compiling on iOS, you’ll also need a Mac to cross-compile Hikari’s toolchain to iOS, which is something I have zero intention of due to the limited user of such a cross-compilation

In case you are thinking of Cross-Compiling for iOS by yourself on your iOS device. It takes:

  • 15GB+ of storage
  • ~45minutes on my Mac with 8Threads
  • ~9GB of memory usage.

for a normal Release Build with Asserts.

So the fastest way is to buy a Mac

I can probably use a VM to do that right? Also, i'm not sure how to compile Hikari's toolchain so I can use it without Xcode because my projects are with logos/theos.

Also, i'm not sure how to compile Hikari's toolchain

Read the wiki

So I can use it without Xcode because my projects are with logos/theos.

Unrelated, you can use the toolchain with Theos as long as you modify the Makefile using the example I provided

I did setup a Catalina VM and installed all prerequisites mentionned to compile it but It doesn't work. I'm not sure how to adjust the "git clone --recurs..." command to cross-compile it for iOS.

I tried to edit the command like that :

git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DCMAKE_OSX_ARCHITECTURES="armv7;armv7s;arm64" -DCMAKE_TOOLCHAIN_FILE=../Hikari/cmake/platforms/iOS.cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_RUNTIME=Off -DLLVM_INCLUDE_TESTS=Off -DLLVM_INCLUDE_EXAMPLES=Off -DLLVM_ENABLE_BACKTRACES=Off -DLLVM_TARGETS_TO_BUILD="ARM;AArch64" -DLLVM_TARGET_ARCH=ARM ../Hikari && ninja && ninja install && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari

but it fails here :

...
...
-- Performing Test CXX_SUPPORTS_NO_GNU_ANONYMOUS_STRUCT - Success
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES - Success
-- LLDB version: 8.0.0
CMake Error at /usr/local/Cellar/cmake/3.17.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Curses (missing: CURSES_INCLUDE_PATH)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.17.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.17.2/share/cmake/Modules/FindCurses.cmake:262 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
tools/lldb/cmake/modules/LLDBConfig.cmake:409 (find_package)
tools/lldb/CMakeLists.txt:11 (include)

-- Configuring incomplete, errors occurred!
See also "/Users/xelahot/HikInst/Build/CMakeFiles/CMakeOutput.log".
See also "/Users/xelahot/HikInst/Build/CMakeFiles/CMakeError.log".

I don't know if i'm on the right track there but I would really like to try this, It think this is a great tool.

Could NOT find Curses

That obviously means you are missing a dependency, do your own research and get that installed

Plus if you already have a VM, you can just compile using that macOS Catalina directly without ever needing to cross-compile for iOS

Does my "git clone" command looks ok though? It would just be a dependencies problem?

Because I tried the pre-compiled version for MacOS but it doesnt work when I compile my tweak. I think it was compiled with xcode options and it gives me errors about headers in the SDKs insinde the xcode.app which I don't want to use. All I need is in theos

Because I tried the pre-compiled version for MacOS but it doesnt work when I compile my tweak. I think it was compiled with xcode options and it gives me errors about headers in the SDKs insinde the xcode.app which I don't want to use. All I need is in theos

Thank you, that description is very useful and helped me a lot with locating and debugging the issue

Well first of, is that command ok to compile it for iOS so it can compile logos tweaks with Theos iOS? There's no example in the wiki.

git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DCMAKE_OSX_ARCHITECTURES="armv7;armv7s;arm64" -DCMAKE_TOOLCHAIN_FILE=../Hikari/cmake/platforms/iOS.cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_RUNTIME=Off -DLLVM_INCLUDE_TESTS=Off -DLLVM_INCLUDE_EXAMPLES=Off -DLLVM_ENABLE_BACKTRACES=Off -DLLVM_TARGETS_TO_BUILD="ARM;AArch64" -DLLVM_TARGET_ARCH=ARM ../Hikari && ninja && ninja install && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari

And I did 'brew install ncurses' but it still said 'Could NOT find Curses (missing: CURSES_INCLUDE_PATH)'. So What I did is add this to the command : '
-DCMAKE_PREFIX_PATH=/usr/local/opt/ncurses' and it seems to get past this error (I'm not sure if that's the right thing to do though). Maybe you should add ncurses to the wiki's prerequisites because it's not listed and I have all of em' installed. But now it stops here :

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Core/libedit_INCLUDE_DIRS
   used as include directory in directory /Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Core
/Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Host/libedit_INCLUDE_DIRS
   used as include directory in directory /Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Host
/Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Interpreter/libedit_INCLUDE_DIRS
   used as include directory in directory /Users/xelahot/testo/Build/Build/Hikari/tools/lldb/source/Interpreter

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

I do have libedit installed. I did 'brew install libedit' after I saw this error but it still shows this error.

I honestly forgot. brew install installs the macOS version of such binaries which is probably why your compilation is failing

The command should roughly be correct though

cmake -G "Ninja" -DCMAKE_OSX_ARCHITECTURES="armv7;armv7s;arm64" -DCMAKE_TOOLCHAIN_FILE=../LLVM/cmake/platforms/iOS.cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_RUNTIME=Off -DLLVM_INCLUDE_TESTS=Off -DLLVM_INCLUDE_EXAMPLES=Off -DLLVM_ENABLE_BACKTRACES=Off -DLLVM_TARGETS_TO_BUILD="ARM;AArch64" -DLLVM_TARGET_ARCH=ARM ../LLVM

I used this during ~LLVM7 era and it was working fully as intended without special configuration