Skip to content

Commit

Permalink
适配Xcode 9
Browse files Browse the repository at this point in the history
  • Loading branch information
EnjoySR committed Aug 14, 2017
1 parent 55eae90 commit 401b821
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand All @@ -58,6 +60,10 @@
debugServiceExtension = "internal"
allowLocationSimulation = "NO"
viewDebuggingEnabled = "No">
<PathRunnable
runnableDebuggingMode = "0"
FilePath = "/Applications/Xcode-beta.app">
</PathRunnable>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand Down
8 changes: 4 additions & 4 deletions ESJsonFormat/Controller/ESDialogController.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ESDialogController">
Expand Down Expand Up @@ -46,7 +46,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="1We-vS-cHB">
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1We-vS-cHB">
<rect key="frame" x="79" y="8" width="192" height="51"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="NxW-qe-4hI">
Expand All @@ -56,7 +56,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CF8-wJ-h9l">
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CF8-wJ-h9l">
<rect key="frame" x="32" y="0.0" width="154" height="51"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Implement method 'objectClassInArray' for MJExtension" id="lMq-GB-Loj">
<font key="font" metaFont="system"/>
Expand Down
17 changes: 16 additions & 1 deletion ESJsonFormat/ESJsonFormat.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ - (id)initWithBundle:(NSBundle *)plugin
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationLog:) name:NSTextViewDidChangeSelectionNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationLog:) name:@"IDEEditorDocumentDidChangeNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationLog:) name:@"PBXProjectDidOpenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationLog:) name:@"SourceEditorSelectedSourceRangeChangedNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationLog:) name:@"IDEWorkspaceDocumentWillWriteStateDataNotification" object:nil];
}
instance = self;
return self;
}

- (void)notificationLog:(NSNotification *)notify
{

if (!self.notiTag) return;
if ([notify.name isEqualToString:NSTextViewDidChangeSelectionNotification]) {
if ([notify.object isKindOfClass:[NSTextView class]]) {
if ([notify.object isKindOfClass:NSClassFromString(@"DVTSourceTextView")]) {
NSTextView *text = (NSTextView *)notify.object;
self.currentTextView = text;
}
Expand All @@ -79,7 +82,19 @@ - (void)notificationLog:(NSNotification *)notify
}else if ([notify.name isEqualToString:@"PBXProjectDidOpenNotification"]){
self.currentProjectPath = [notify.object valueForKey:@"path"];
[[ESPbxprojInfo shareInstance] setParamsWithPath:[self.currentProjectPath stringByAppendingPathComponent:@"project.pbxproj"]];
}else if ([notify.name isEqualToString:@"SourceEditorSelectedSourceRangeChangedNotification"]) {
// 适配 Xcode 9,在Xcode 9 中代码编辑区域的 View 类型如下,继承于 NSView,但使用方式与 NSTextView 类似
if ([notify.object isKindOfClass:NSClassFromString(@"IDEPegasusSourceEditor.SourceCodeEditorView")]) {
self.currentTextView = notify.object;
}
}else if ([notify.name isEqualToString:@"IDEWorkspaceDocumentWillWriteStateDataNotification"]) {
NSArray *recentEditorDocumentURLs = [notify.object valueForKey:@"_recentEditorDocumentURLs"];
NSString *path = [recentEditorDocumentURLs.firstObject absoluteString];
if ([path hasPrefix:@"file"]) {
self.currentFilePath = path;
}
}

}

-(void)outputResult:(NSNotification*)noti{
Expand Down
4 changes: 2 additions & 2 deletions ESJsonFormat/ESJsonFormatManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ + (NSString *)formatObjcWithKey:(NSString *)key value:(NSObject *)value classInf
* @return
*/
+ (NSString *)formatSwiftWithKey:(NSString *)key value:(NSObject *)value classInfo:(ESClassInfo *)classInfo{
NSString *typeStr = @"String?";
NSString *typeStr = @"String";
//判断大小写
if ([ESUppercaseKeyWords containsObject:key] && [ESJsonFormatSetting defaultSetting].uppercaseKeyWordForId) {
key = [key uppercaseString];
}
if ([value isKindOfClass:[NSString class]]) {
return [NSString stringWithFormat:@" var %@: %@",key,typeStr];
return [NSString stringWithFormat:@" var %@: %@ = \"\"",key,typeStr];
}else if([value isKindOfClass:[@(YES) class]]){
typeStr = @"Bool";
return [NSString stringWithFormat:@" var %@: %@ = false",key,typeStr];
Expand Down
3 changes: 3 additions & 0 deletions ESJsonFormat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<key>DVTPlugInCompatibilityUUIDs</key>
<array>
<string>AABB7188-E14E-4433-AD3B-5CD791EAD9A3</string>
<string>1637F4D5-0B27-416B-A78D-498965D64877</string>
<string>F41BD31E-2683-44B8-AE7F-5F09E919790E</string>
<string>992275C1-432A-4CF7-B659-D84ED6D42D3F</string>
<string>7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90</string>
Expand All @@ -36,6 +37,8 @@
<string>0420B86A-AA43-4792-9ED0-6FE0F2B16A13</string>
<string>7265231C-39B4-402C-89E1-16167C4CC990</string>
<string>ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C</string>
<string>DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C</string>
<string>CA351AD8-3176-41CB-875C-42A05C7CDEC7</string>
</array>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
Expand Down

0 comments on commit 401b821

Please sign in to comment.