Skip to content

Commit eff7efb

Browse files
authored
Merge pull request #22 from touchlab/bw/Xcode11SetupScript
setup script renamed; new setup script for all versions of xcode but 11
2 parents 6509710 + 827d546 commit eff7efb

File tree

4 files changed

+103
-38
lines changed

4 files changed

+103
-38
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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Use this script for Xcode 11.
4+
5+
###################
6+
# DEFINITIONS
7+
###################
8+
9+
service='Xcode'
10+
plugins_dir=~/Library/Developer/Xcode/Plug-ins
11+
12+
###################
13+
# SHUT DOWN XCODE IF IT'S RUNNING
14+
###################
15+
16+
if pgrep -xq -- "${service}"; then
17+
echo "Xcode is running. Attempt to shut down? y/n"
18+
read answer
19+
if [ "$answer" = "y" ]; then
20+
echo "Shutting down Xcode"
21+
pkill -x $service
22+
else
23+
echo "Xcode needs to be closed"
24+
exit 1
25+
fi
26+
fi
27+
28+
###################
29+
# FORGET EXISTING PLUG-IN
30+
###################
31+
32+
if [ -d "${plugins_dir}/Kotlin.ideplugin/" ]; then
33+
echo "Kotlin plugin found. Deleting and forgetting..."
34+
rm -rf "$plugins_dir/Kotlin.ideplugin/"
35+
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$(xcodebuild -version | grep Xcode | cut -d ' ' -f 2)
36+
fi
37+
38+
###################
39+
# CREATE PLUG-IN
40+
###################
41+
42+
echo "Creating new Kotlin plugin"
43+
mkdir -p $plugins_dir
44+
cp -r Kotlin.ideplugin $plugins_dir
45+
46+
###################
47+
# LLDB DEFINITIONS
48+
###################
49+
50+
lldb_config="command script import ~/Library/Developer/Xcode/Plug-ins/Kotlin.ideplugin/Contents/Resources/konan_lldb_config.py"
51+
lldb_format="command script import ~/Library/Developer/Xcode/Plug-ins/Kotlin.ideplugin/Contents/Resources/konan_lldb.py"
52+
53+
if grep --quiet -s konan_lldb ~/.lldbinit-Xcode
54+
then
55+
# code if found
56+
echo "konan_lldb.py found in ~/.lldbinit-Xcode"
57+
else
58+
# code if not found
59+
echo $lldb_config >> ~/.lldbinit-Xcode
60+
echo $lldb_format >> ~/.lldbinit-Xcode
61+
fi

setup.sh

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

3+
# Use this script for versions of Xcode other than Xcode 11.
4+
35
###################
46
# DEFINITIONS
57
###################
68

79
service='Xcode'
8-
plugins_dir=~/Library/Developer/Xcode/Plug-ins/
10+
plugins_dir=~/Library/Developer/Xcode/Plug-ins
11+
spec_dir=~/Library/Developer/Xcode/Specifications
912

1013
###################
1114
# SHUT DOWN XCODE IF IT'S RUNNING
@@ -15,7 +18,7 @@ if pgrep -xq -- "${service}"; then
1518
echo "Xcode is running. Attempt to shut down? y/n"
1619
read answer
1720
if [ "$answer" = "y" ]; then
18-
echo "Shutting down Xcode"
21+
echo "Shutting down Xcode..."
1922
pkill -x $service
2023
else
2124
echo "Xcode needs to be closed"
@@ -24,22 +27,36 @@ if pgrep -xq -- "${service}"; then
2427
fi
2528

2629
###################
27-
# DELETE EXISTING PLUG-IN
30+
# FORGET EXISTING PLUG-IN
2831
###################
2932

30-
if [ -d "${plugins_dir}Kotlin.ideplugin/" ]; then
31-
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/"
3241
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-$(xcodebuild -version | grep Xcode | cut -d ' ' -f 2)
3342
fi
3443

3544
###################
3645
# CREATE PLUG-IN
3746
###################
3847

39-
echo "Creating plugins directory"
48+
echo "Creating new Kotlin plugin"
4049
mkdir -p $plugins_dir
4150
cp -r Kotlin.ideplugin $plugins_dir
4251

52+
###################
53+
# CREATE SPECS DIR
54+
###################
55+
56+
echo "Creating new Kotlin language spec"
57+
mkdir -p $spec_dir
58+
cp Kotlin.xclangspec $spec_dir
59+
4360
###################
4461
# LLDB DEFINITIONS
4562
###################
@@ -55,5 +72,4 @@ else
5572
# code if not found
5673
echo $lldb_config >> ~/.lldbinit-Xcode
5774
echo $lldb_format >> ~/.lldbinit-Xcode
58-
fi
59-
75+
fi

0 commit comments

Comments
 (0)