Skip to content

Commit 827d546

Browse files
author
Ben Whitley
committed
setup scripts improved; color setup script renamed; README updated
1 parent 4bbe087 commit 827d546

File tree

4 files changed

+54
-44
lines changed

4 files changed

+54
-44
lines changed

README.md

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,39 @@
11
# Kotlin Native Xcode Support
22

3-
Plugin to facilitate debugging iOS applications using Kotlin Native in Xcode.
4-
Defines Kotlin files as source code, with basic highlighting. Allows you to
5-
set breakpoints and includes llvm support to view data in the debug window.
3+
Plugin to facilitate debugging iOS applications using Kotlin Native in Xcode. Defines Kotlin files as source code, with basic highlighting. Allows you to set breakpoints and includes llvm support to view data in the debug window. Xcode does not officially support custom language definitions, but they also don't explicitly block them.
64

75
> ## **We're Hiring!**
86
>
9-
> Touchlab is looking for Android-focused mobile engineers, experienced with Kotlin and
10-
> looking to get involved with Kotlin Multiplatorm in the near future. [More info here](https://on.touchlab.co/2P94J5q).
11-
12-
# Xcode 11+
13-
14-
Xcode does not officially support custom language definitions, but they also don't explicitly block them. However,
15-
Xcode 11 introduced several breaking changes from earlier versions, and some resolutions are still outstanding.
16-
17-
## Xcode <= 10.x
18-
19-
For earlier versions, please see [xcode10 branch](https://github.com/touchlab/xcode-kotlin/tree/xcode10). Life moves on,
20-
and we'll only be supporting Xcode 11+.
7+
> Touchlab is looking for Android-focused mobile engineers, experienced with Kotlin and looking to get involved with Kotlin Multiplatorm in the near future. [More info here](https://on.touchlab.co/2P94J5q).
218
229
## Installation
2310

2411
There are 2 parts to Kotlin support: 1) debugging support and 2) language color and style formatting.
2512

26-
### Step 1: Debugging Support
13+
You need to tell Xcode that `*.kt` files are source files, and run an lldb formatter script when debugging starts. Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the setup script.
14+
15+
### Xcode 11
2716

28-
You need to tell Xcode that `*.kt` files are source files, and run an lldb formatter script when debugging starts.
29-
Advanced users may want to do this manually, but if you have Xcode installed in the default place, you can run the
30-
setup script.
17+
For debugging support in Xcode 11, run the installation script:
3118

3219
```
33-
./setup.sh
20+
./setup-xcode11.sh
3421
```
3522

36-
### Step 2: Formatting Support
23+
Xcode 11 introduced several breaking changes from earlier versions, and some resolutions are still outstanding. If you're using Xcode 11, you need to move some files into a protected area. Some users may not want to do this, and may possibly not have permissions to do this. You'll need to run the formatting support script with sufficient permissions, which generally means `sudo`.
3724

38-
In Xcode 11, you need to move some files into a protected area. Some users may not want to do this, and may possibly
39-
not have permissions to do this. You'll need to run the script with sufficient permissions, which generally means
40-
`sudo`.
25+
```
26+
sudo ./colorsetup-xcode11.sh
27+
```
4128

4229
*You can still debug Kotlin without formatting support, just FYI. This step is not required.*
4330

31+
### All Other Xcode Versions
32+
33+
For all other versions of Xcode, the following script will install both debugging and formatting support:
34+
4435
```
45-
sudo ./colorsetup.sh
36+
./setup.sh
4637
```
4738

4839
## Kotlin 1.3.6x Issue
@@ -70,12 +61,9 @@ The [Droidcon NYC](https://github.com/touchlab/DroidconKotlin/) app has both the
7061

7162
### Sources
7263

73-
Setting up the Plugin has been an amalgam of various source projects, as Xcode "Plugins"
74-
are undocumented. The most significant piece, the language color file, came from other color
75-
files shipped with Xcode. Xcode plugin file from [GraphQL](https://github.com/apollographql/xcode-graphql/blob/master/GraphQL.ideplugin/Contents/Resources/GraphQL.xcplugindata)
64+
Setting up the Plugin has been an amalgam of various source projects, as Xcode "Plugins" are undocumented. The most significant piece, the language color file came from other color files shipped with Xcode. Xcode plugin file from [GraphQL](https://github.com/apollographql/xcode-graphql/blob/master/GraphQL.ideplugin/Contents/Resources/GraphQL.xcplugindata)
7665

77-
LLDB formatting originally comes from the Kotlin/Native project, source [konan_lldb.py](https://github.com/JetBrains/kotlin-native/blob/dbb162a4b523071f31913e888e212df344a1b61e/llvmDebugInfoC/src/scripts/konan_lldb.py), although the way data is grabbed has been heavily modified to better
78-
support an interactive debugger.
66+
LLDB formatting originally comes from the Kotlin/Native project, source [konan_lldb.py](https://github.com/JetBrains/kotlin-native/blob/dbb162a4b523071f31913e888e212df344a1b61e/llvmDebugInfoC/src/scripts/konan_lldb.py), although the way data is grabbed has been heavily modified to better support an interactive debugger.
7967

8068
## Possible Future Stuff
8169

File renamed without changes.

setup-xcode11.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

3-
set -o xtrace
3+
# Use this script for Xcode 11.
44

55
###################
66
# DEFINITIONS
77
###################
88

99
service='Xcode'
10-
plugins_dir=~/Library/Developer/Xcode/Plug-ins/
10+
plugins_dir=~/Library/Developer/Xcode/Plug-ins
1111

1212
###################
1313
# SHUT DOWN XCODE IF IT'S RUNNING
@@ -26,19 +26,20 @@ if pgrep -xq -- "${service}"; then
2626
fi
2727

2828
###################
29-
# DELETE EXISTING PLUG-IN
29+
# FORGET EXISTING PLUG-IN
3030
###################
3131

32-
if [ -d "${plugins_dir}Kotlin.ideplugin/" ]; then
33-
echo "Plugins directory and Kotlin plugin found..."
32+
if [ -d "${plugins_dir}/Kotlin.ideplugin/" ]; then
33+
echo "Kotlin plugin found. Deleting and forgetting..."
34+
rm -rf "$plugins_dir/Kotlin.ideplugin/"
3435
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$(xcodebuild -version | grep Xcode | cut -d ' ' -f 2)
3536
fi
3637

3738
###################
3839
# CREATE PLUG-IN
3940
###################
4041

41-
echo "Creating plugins directory"
42+
echo "Creating new Kotlin plugin"
4243
mkdir -p $plugins_dir
4344
cp -r Kotlin.ideplugin $plugins_dir
4445

setup.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,60 @@
22

33
# Use this script for versions of Xcode other than Xcode 11.
44

5-
set -o xtrace
6-
75
###################
86
# DEFINITIONS
97
###################
108

9+
service='Xcode'
1110
plugins_dir=~/Library/Developer/Xcode/Plug-ins
1211
spec_dir=~/Library/Developer/Xcode/Specifications
1312

13+
###################
14+
# SHUT DOWN XCODE IF IT'S RUNNING
15+
###################
16+
17+
if pgrep -xq -- "${service}"; then
18+
echo "Xcode is running. Attempt to shut down? y/n"
19+
read answer
20+
if [ "$answer" = "y" ]; then
21+
echo "Shutting down Xcode..."
22+
pkill -x $service
23+
else
24+
echo "Xcode needs to be closed"
25+
exit 1
26+
fi
27+
fi
28+
1429
###################
1530
# FORGET EXISTING PLUG-IN
1631
###################
1732

18-
if [ ! -d "$plugins_dir/Kotlin.ideplugin/" ]; then
19-
echo "Plugins directory and Kotlin plugin found..."
33+
if [ -d "$spec_dir/Kotlin.xclangspec" ]; then
34+
echo "Kotlin language spec found. Deleting..."
35+
rm "$spec_dir/Kotlin.xclangspec"
36+
fi
37+
38+
if [ -d "$plugins_dir/Kotlin.ideplugin/" ]; then
39+
echo "Kotlin plugin found. Deleting and forgetting..."
40+
rm -rf "$plugins_dir/Kotlin.ideplugin/"
2041
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$(xcodebuild -version | grep Xcode | cut -d ' ' -f 2)
2142
fi
2243

2344
###################
2445
# CREATE PLUG-IN
2546
###################
2647

27-
echo "Creating plugins directory"
48+
echo "Creating new Kotlin plugin"
2849
mkdir -p $plugins_dir
2950
cp -r Kotlin.ideplugin $plugins_dir
3051

3152
###################
3253
# CREATE SPECS DIR
3354
###################
3455

35-
if [ ! -d "$spec_dir" ]; then
36-
mkdir $spec_dir
37-
fi
56+
echo "Creating new Kotlin language spec"
57+
mkdir -p $spec_dir
58+
cp Kotlin.xclangspec $spec_dir
3859

3960
###################
4061
# LLDB DEFINITIONS

0 commit comments

Comments
 (0)