如何使用Xcode创建具有Root权限的App?

需求: 最近要做一个具有root权限的App,App内容复杂,需要引用大量的第三方库和编写大量代码,对于theos创建的App,在配置Makefile方面,比较繁琐,所以想使用xcode来创建,目前出现的问题有:
1:编写好了bash以及Run Script,启动app的时候会出现do not have permisson to view it,将生成的app打包签名使用ideviceinstaller 安装,报错:Install failed. Got error “APIInternalError” with code 0x00000000: Failed to unhide archs in executable file:///private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.o6mh9E/extracted/Payload/superManager.app/bash

操作步骤:main.m加入setuid(0),编写bash:#!/bin/bash
root=$(dirname “$0”)
exec “${root}”/superManager
,给bash权限0755;info.plist中 Executable file 设置为bash;bash和info.plist同目录;Build Phase 最后一步添加RunScript,添加chmod 6775 ${BUILT_PRODUCTS_DIR}/${TARGET_NAME}.app/${TARGET_NAME},直接build。

听起来你需要把bash脚本用C重新实现一遍。这个步骤应该是试图砍掉二进制里无关的架构时因为你是脚本才报的错

谢张总指点,我换到了Theos来创建,昨天还是可以make package的,今天make就出现以下错误

mmroot make package messages=yes

> Making all for tool MMRoot…

/Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile --no-keep-going COLOR=1 \

internal-tool-compile \

_THEOS_CURRENT_TYPE=tool THEOS_CURRENT_INSTANCE=MMRoot _THEOS_CURRENT_OPERATION=compile \

THEOS_BUILD_DIR="." _THEOS_MAKE_PARALLEL=yes

make[2]: Nothing to be done for `internal-tool-compile’.

set -o pipefail; (rm -rf “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_”)

set -o pipefail; (/opt/theos/bin/fakeroot.sh -p “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/fakeroot” -c)

set -o pipefail; (mkdir -p “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_”)

set -o pipefail; ([ -d layout ] && rsync -a “layout/” “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_” --exclude “DEBIAN” --exclude “MTN" --exclude “.git” --exclude “.svn” --exclude “.DS_Store” --exclude ".*” || true)

> Making stage for tool MMRoot…

set -o pipefail; (mkdir -p “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/usr/bin”)

set -o pipefail; (cp /Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/obj/debug/MMRoot “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/usr/bin”)

set -o pipefail; (mkdir -p “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/DEBIAN”)

set -o pipefail; (sed -e ‘s/${LIBSWIFT}/org.swift.libswift (>= 5.0)/g; s/${LIBSWIFT_VERSION}/5.0/g; /^[Vv]ersion:/d; /^$/d; $a’ “/Users/Metros/Documents/reAPP/iOSRe/mmroot/control” > “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/DEBIAN/control”)

set -o pipefail; (echo “Version: 0.0.1-3+debug” >> “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/DEBIAN/control”)

set -o pipefail; (echo “Installed-Size: 136” >> “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_/DEBIAN/control”)

set -o pipefail; (COPYFILE_DISABLE=1 /opt/theos/bin/fakeroot.sh -p “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/fakeroot” -r dm.pl -Zlzma -z0 -b “/Users/Metros/Documents/reAPP/iOSRe/mmroot/.theos/_” “./packages/com.Metros.MMRoot_0.0.1-3+debug_iphoneos-arm.deb”)

然后这条命令也不会结束,张总有时间帮我分析下原因。