KJCracks / Clutch

Fast iOS executable dumper
3.67k stars 646 forks source link

Add CMake to the project #220

Closed palmerc closed 5 years ago

palmerc commented 6 years ago

I believe I've improved upon the previous CMake PR enough to warrant a complete do-over. :) You'll notice that in addition to building beautifully with make or ninja, it also generates an Xcode project that maintains the existing folder structure and most of the settings.

Tatsh commented 6 years ago

Not working for me on latest Xcode:

~/dev/clutch/build
 $ cmake ..
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
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:
MOBILECORESERVICES
    linked by target "Clutch" in directory /Users/tatsh/dev/clutch/Clutch
UIKIT
    linked by target "Clutch" in directory /Users/tatsh/dev/clutch/Clutch

-- Configuring incomplete, errors occurred!
See also "/Users/tatsh/dev/clutch/build/CMakeFiles/CMakeOutput.log".

I expect this to be able to work with only cmake .. (for a release build).

palmerc commented 6 years ago

I believe you invoked CMake incorrectly. You must specify a toolchain

cmake -G Xcode -D CMAKE_TOOLCHAIN_FILE=../Clutch/cmake/iphoneos.toolchain.cmake ../Clutch
Tatsh commented 6 years ago

Getting this error regarding minimum iOS version (set to 11.4):

clang: error: invalid version number in '-miphoneos-version-min='

Shouldn't this be something else? Also it should be version 8.0 as the minimum.

Also here.

Tatsh commented 6 years ago

With fixed paths, it looks like this works. However I still want the minimum iOS to be 8.0.

Tatsh commented 6 years ago

This is the command I am using now, from the Clutch root directory:

rm -fR build && mkdir build && cd build && cmake -G Xcode -D CMAKE_TOOLCHAIN_FILE=../cmake/iphoneos.toolchain.cmake ../Clutch && xcodebuild

With this, I get the -miphoneos-version-min= error.

palmerc commented 6 years ago

OK, I've seen what you're seeing. When building at the command-line with xcodebuild it is passing -miphoneos-version-min=11.4 and -O0 which says to me Debug and that I need to poke around in the settings to determine why it is making these choices.

UPDATE: It was Minizip. Had to add the XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET there as well. I almost always build with ninja these days which won't see this issue. I've updated the MiniZip build to behave differently with Xcode.

I'd like to add that generally for non-Clutch-developers it doesn't make sense to build with xcodebuild. Since this is an iphoneos command-line tool, they should build with Ninja or Make. It is simpler, fast and most importantly won't complain about code signing.

In the process I found two bugs in my XCODE_ATTRIBUTES so it compiles successfully with xcodebuild.

I'm using xcodebuild like this:

xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
palmerc commented 6 years ago

I went ahead and created a POST_BUILD step that replaces the bash script move_and_sign.sh. So we'll copy the binary into the build/ folder and call code sign on it.

Tatsh commented 5 years ago

Finally got a chance to test this. Merging now.