Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support SIMBL library loading system #367

Merged
merged 4 commits into from
Apr 4, 2021
Merged
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
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
xcodebuild:=xcodebuild -configuration
xcode_plugin_path:=$(HOME)/Library/Application Support/Developer/Shared/Xcode/Plug-ins
simbl_plugin_path:=/Library/Application Support/MacEnhance/Plugins

ifdef BUILDLOG
REDIRECT=>> $(BUILDLOG)
endif

.PHONY: release debug clean clean-release clean-debug uninstall uuid build-test
.PHONY: release debug clean clean-release clean-debug simbl move-to-simbl uninstall uuid build-test

release: uuid
$(xcodebuild) Release $(REDIRECT)
Expand All @@ -21,9 +23,21 @@ clean-release:
clean-debug:
$(xcodebuild) Debug clean

simbl: release move-to-simbl

move-to-simbl:
rm -rf "$(simbl_plugin_path)/XVim2.bundle"; \
if [ -d "$(simbl_plugin_path)" ]; then \
mv "$(xcode_plugin_path)/XVim2.xcplugin" "$(simbl_plugin_path)/XVim2.bundle"; \
printf "\nInstall to SIMBL plugin directory succeeded.\n"; \
else \
printf "\n$(simbl_plugin_path) directory not found.\n"; \
printf "\nPlease setup MacForge.\n"; \
fi;

uninstall:
rm -rf "$(HOME)/Library/Application Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin"
rm -rf "$(xcode_plugin_path)/XVim2.xcplugin"; \
rm -rf "$(simbl_plugin_path)/XVim2.bundle";

uuid:
@xcode_path=`xcode-select -p`; \
Expand Down
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,66 @@

## Install

1. Sign Xcode with your own certificate. You can [read the instructions for how to do this](SIGNING_Xcode.md) and if you have questions or concerns about what this means you can [read the FAQ on why you need to resign Xcode to use XVim2](why_resign_xcode.md).

2. Clone the repo:
1. Clone the repo:
```bash
$ git clone https://github.com/XVimProject/XVim2.git
$ cd XVim2
```

3. Confirm `xcode-select` points to your Xcode:
2. Confirm `xcode-select` points to your Xcode:
```bash
$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
```

If this doesn't show your Xcode application path, use `xcode-select -s /path/to/Xcode.app/Contents/Developer` to set the correct path.

4. `git checkout` a branch for your Xcode version. See [Branches and Releases](#branches-and-releases) section for more information.
3. `git checkout` a branch for your Xcode version. See [Branches and Releases](#branches-and-releases) section for more information.

5. `make`:
4. `make`:
```bash
$ cd XVim2
$ make
```

5. XVim2 support some code injection system to load XVim2 into Xcode.

- [Xcode plugin system](#xcode-plugin-system)
- [SIMBL plugin system](#simbl-plugin-system)

6. Create `.xvimrc` as you need.

### Xcode plugin system

NOTE: This method have issue for sign-in to Apple ID via Xcode on Big Sur. [#340](/issues/340)

1. Sign Xcode with your own certificate. You can [read the instructions for how to do this](SIGNING_Xcode.md) and if you have questions or concerns about what this means you can [read the FAQ on why you need to resign Xcode to use XVim2](why_resign_xcode.md).

If you see something like the following:
```
XVim hasn't confirmed the compatibility with your Xcode, Version X.X
Do you want to compile XVim with support Xcode Version X.X at your own risk?
```
Press `y` to use XVim with your Xcode version (even if XVim is not confirmed to work with that version of Xcode).

6. Create `.xvimrc` as you need.

7. Launch Xcode, where you'll be asked if you want to load XVim. Press 'Yes' to do so.
2. Launch Xcode, where you'll be asked if you want to load XVim. Press 'Yes' to do so.
If you press 'No' by mistake, close Xcode and execute the following from a terminal:

```
defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-X.X (X.X is your Xcode version)
```
Then relaunch Xcode and choose 'Yes' to load XVim.

### SIMBL plugin system

NOTE: SIMBL plugin system required disabling some security feature to work on recently macOS.

1. Setup [MacForge](https://github.com/MacEnhance/MacForge) with disabling Library Validation and System Integrity Protection (SIP).

2. make:
```bash
$ make simbl
```

## Branches and Releases

- `master`: for the lastest GM Xcode.
Expand Down Expand Up @@ -77,8 +97,9 @@
```

### Manual uninstall
Delete the following directory:
`$HOME/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin`
Delete the following directories:
- `$HOME/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/XVim2.xcplugin`
- `/Library/Application\ Support/MacEnhance/Plugins/XVim2.bundle`

## Feature list
See separate [FeatureList.md](Documents/FeatureList.md)
Expand Down
7 changes: 7 additions & 0 deletions XVim2/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<array>
<string>com.apple.dt.Xcode</string>
</array>
<key>SIMBLTargetApplications</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.dt.Xcode</string>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
4 changes: 3 additions & 1 deletion XVim2/XVim/XVim.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ - (id)init
object:nil];
}
else {
[self addMenuItem];
dispatch_async(dispatch_get_main_queue(), ^{
[self addMenuItem];
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fix when load via MacForge.

Process:               Xcode [6791]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            Xcode
Version:               12.4 (17801)
Build Info:            IDEFrameworks-17801000000000000~7 (12D4e)
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Xcode [6791]
User ID:               501

Date/Time:             2021-04-04 00:15:41.823 +0900
OS Version:            macOS 11.2.1 (20D74)
Report Version:        12
Bridge OS Version:     5.2 (18P4346)
Anonymous UUID:        806AEC77-75B7-48EE-8368-FE248094F0D8


Time Awake Since Boot: 2300 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Signal:    Illegal instruction: 4
Termination Reason:    Namespace SIGNAL, Code 0x4
Terminating Process:   exc handler [6791]

External Modification Warnings:
Thread creation by external task.

Application Specific Information:
ProductBuildVersion: 12D4e
BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libdispatch.dylib             	0x00007fff2048bff2 _dispatch_once_wait.cold.1 + 14
1   libdispatch.dylib             	0x00007fff2045ef3b _dispatch_once_wait + 93
2   net.JugglerShu.XVim2          	0x000000013f367b90 _dispatch_once + 19 (once.h:84) [inlined]
3   net.JugglerShu.XVim2          	0x000000013f367b90 +[XVim instance] + 64 (XVim.m:124)
4   net.JugglerShu.XVim2          	0x000000013f368cfd -[XVim xvimMenuItem] + 253 (XVim.m:315)
5   net.JugglerShu.XVim2          	0x000000013f368b35 -[XVim addMenuItem] + 133 (XVim.m:295)
6   net.JugglerShu.XVim2          	0x000000013f367fa4 -[XVim init] + 932 (XVim.m:169)
7   net.JugglerShu.XVim2          	0x000000013f367bc5 __16+[XVim instance]_block_invoke + 37 (XVim.m:125)
8   libdispatch.dylib             	0x00007fff2045e7c7 _dispatch_client_callout + 8
9   libdispatch.dylib             	0x00007fff2045f96b _dispatch_once_callout + 20
10  net.JugglerShu.XVim2          	0x000000013f367b90 _dispatch_once + 19 (once.h:84) [inlined]
11  net.JugglerShu.XVim2          	0x000000013f367b90 +[XVim instance] + 64 (XVim.m:124)
12  net.JugglerShu.XVim2          	0x000000013f35cdfd -[XVimWindow handleRelativeNumbers] + 61 (XVimWindow.m:519)
13  net.JugglerShu.XVim2          	0x000000013f35ac34 -[XVimWindow resetEvaluatorStack:activateNormalHandler:] + 148 (XVimWindow.m:116)
14  net.JugglerShu.XVim2          	0x000000013f35a67e -[XVimWindow initWithSourceView:] + 270 (XVimWindow.m:60)
15  net.JugglerShu.XVim2          	0x000000013f38685e -[XVimIDESourceEditorView xvim_window] + 238 (XVimIDESourceEditorView.m:97)
16  net.JugglerShu.XVim2          	0x000000013f386748 -[XVimIDESourceEditorView xvim_setupOnFirstAppearance] + 24 (XVimIDESourceEditorView.m:88)
17  com.apple.Foundation          	0x00007fff2146f01c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 7
18  com.apple.Foundation          	0x00007fff2146ef14 -[NSBlockOperation main] + 98
19  com.apple.Foundation          	0x00007fff2146eea5 __NSOPERATION_IS_INVOKING_MAIN__ + 17
20  com.apple.Foundation          	0x00007fff2146e156 -[NSOperation start] + 785
21  com.apple.Foundation          	0x00007fff2146de3a __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 17
22  com.apple.Foundation          	0x00007fff2146dd0d __NSOQSchedule_f + 182
23  libdispatch.dylib             	0x00007fff2046b1d5 _dispatch_block_async_invoke2 + 83
24  libdispatch.dylib             	0x00007fff2045e7c7 _dispatch_client_callout + 8
25  libdispatch.dylib             	0x00007fff2046ab86 _dispatch_main_queue_callback_4CF + 940
26  com.apple.CoreFoundation      	0x00007fff2073e970 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
27  com.apple.CoreFoundation      	0x00007fff20700852 __CFRunLoopRun + 2731
28  com.apple.CoreFoundation      	0x00007fff206ff6ce CFRunLoopRunSpecific + 563
29  com.apple.HIToolbox           	0x00007fff28987630 RunCurrentEventLoopInMode + 292
30  com.apple.HIToolbox           	0x00007fff2898742c ReceiveNextEventCommon + 709
31  com.apple.HIToolbox           	0x00007fff2898714f _BlockUntilNextEventMatchingListInModeWithFilter + 64
32  com.apple.AppKit              	0x00007fff22f1f9b1 _DPSNextEvent + 883
33  com.apple.AppKit              	0x00007fff22f1e177 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
34  com.apple.dt.DVTKit           	0x0000000101eabd07 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 421
35  com.apple.AppKit              	0x00007fff22f1068a -[NSApplication run] + 586
36  com.apple.AppKit              	0x00007fff22ee496f NSApplicationMain + 816
37  libdyld.dylib                 	0x00007fff20624621 start + 1

}
}
return self;
Expand Down