Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vars.mk
/build/
xcuserdata/
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PROJECT = ios-command-line-tool.xcodeproj

include vars.mk

.PHONY: all clean

all:
xcodebuild \
-project "$(PROJECT)" \
ARCHS="arm64" \
DEVELOPMENT_TEAM="$(DEV_TEAM)" \
IPHONEOS_DEPLOYMENT_TARGET="$(IOS_TARGET)" \
build

clean:
xcodebuild \
-project "$(PROJECT)" \
ARCHS="arm64" \
DEVELOPMENT_TEAM="$(DEV_TEAM)" \
IPHONEOS_DEPLOYMENT_TARGET="$(IOS_TARGET)" \
clean
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,79 @@ Xcode can be persuaded to build standalone Mach-O executables for iOS as well.

This technique has been tested with Xcode 9.3 and iOS 11.1.2.

## Build on Your System

Building the tool on your system requires updating signing information and deployment info. You
can do that from Xcode or from the command line.

In order to build on your system you need a developer account. You find out if you have one by
running the `security find-identity` command below on macOS. If you get an output similar to the
one below, you have a developer account:

```
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "iPhone Developer: AAAAAAA (BBBBBBBBBB)"
```

If you don't have a developer account you need to create one. See the instructions
[here](https://stackoverflow.com/questions/39524148/requires-a-development-team-select-a-development-team-in-the-project-editor-cod).

### Building on Xcode

Open the `ios-command-line-tool.xcodeproj` folder in Xcode (by using `File -> Open` in Xcode),
click on the `ios-command-line-tool` top icon in the project navigator (left side), then go to
the `General` tab (in the middle view). In the `Signing` section choose your `Team`. Once you
do that, other issues will disappear.

You may need to enable the `Project Navigator` view in Xcode. You do that by using `View ->
Navigators -> Show Project Navigator`.

If you want to build for an earlier version of iOS, go to the `Deployment Info` section in the
middle view and choose the `Deployment Target` of your choice.

You can now build the executable in Xcode (`Product -> Build`). The executable file will by
default be located in
`~/Library/Developer/Xcode/DerivedData/ios-command-line-tool-XXXXXXXXXXXX/Build/Products/Debug-iphoneos/ios-command-line-tool`
(see more on that [here](https://pewpewthespells.com/blog/xcode_build_locations.html)). For
example:

```
$ file ~/Library/Developer/Xcode/DerivedData/ios-command-line-tool-ffawlhgezawmrmfewovgtsimimkd/Build/Products/Debug-iphoneos/ios-command-line-tool
/Users/razvan/Library/Developer/Xcode/DerivedData/ios-command-line-tool-ffawlhgezawmrmfewovgtsimimkd/Build/Products/Debug-iphoneos/ios-command-line-tool: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
```

### Building on the Command Line

You can bypass using Xcode IDE altogether and resort to using the command line. You use the
`Makefile` and the `make` command.

Similar to the Xcode configuration, you first need to choose your development team. Create a
`vars.mk` file by copying `vars.mk.sample`:

```
cp vars.mk.sample vars.mk
```

Now update the `DEV_TEAM` and the `IOS_TARGET` variables to proper values. You can find out
existing development teams by running the one liner below, as shown
[here](https://answers.unity.com/questions/1248794/ios-build-error-devleopment-team.html).

```
security find-identity -v -p codesigning | awk -F \" '{if ($2) print $2}' | while read acct ; do security find-certificate -a -c "$acct" -p | openssl x509 -text | grep "^ *Subject:" | awk -v acct="$acct" -F , '{if ($3) {sub(/ *OU=/,"",$3);print $3","acct}}' ; done
```

In the `vars.mk` file update the `DEV_TEAM` with one of the team IDs from output lines above
and the `IOS_TARGET` with the iOS version you want to use.

Now use `make` build the executable. The executable will be located in
`build/Release-iphoneos/ios-command-line-tool`:

```
$ file build/Release-iphoneos/ios-command-line-tool
build/Release-iphoneos/ios-command-line-tool: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>
```

You can use `make clean` to clean the project.

## License

The ios-command-line-tool template is released into the public domain.
2 changes: 2 additions & 0 deletions vars.mk.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEV_TEAM = DEEG7TTSF2
IOS_TARGET = 11.1