Xcode更新,插件失效的统一解决方法

13 篇文章 0 订阅

每次Xcode 更新都要对每个插件进行添加UUID的操作,实在太麻烦了,就写了个小程序,只需要运行一下本程序,再重启一下Xcode,之前安装的各种插件就都能工作了,非常方便~


//
//  main.m
//  xcplugin
//
//  Created by Macro on 10/23/15.
//  Copyright © 2015 Macro. All rights reserved.
//

#import <Foundation/Foundation.h>

#define XCODE_PATH @"/Applications/Xcode.app/Contents/Info.plist"

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        
        NSString *username = NSUserName();
        NSString *pluginPath = [NSString stringWithFormat:@"/Users/%@/Library/Application Support/Developer/Shared/Xcode/Plug-ins", username];
        
        NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:XCODE_PATH];
        NSString *xcodeUUID = dictionary[@"DVTPlugInCompatibilityUUID"];

        NSFileManager *fm = [NSFileManager defaultManager];
        NSError *error;
        NSArray *pathArray = [fm contentsOfDirectoryAtPath:pluginPath error:&error];
        if (error) {
            NSLog(@"路径错误");
            return 0;
        }
        for (NSString *name  in pathArray) {
            if ([name hasSuffix:@".xcplugin"]) {
                NSString *pluginPlistPath = [NSString stringWithFormat:@"%@/%@/Contents/Info.plist", pluginPath, name];
                NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:pluginPlistPath];
                NSMutableArray *arr = [NSMutableArray arrayWithArray:dictionary[@"DVTPlugInCompatibilityUUIDs"]];
                
                if (![arr containsObject:xcodeUUID]) {
                    [arr addObject:xcodeUUID];
                    [dictionary setValue:arr forKey:@"DVTPlugInCompatibilityUUIDs"];
                    [dictionary writeToFile:pluginPlistPath atomically:YES];
                }
            }
        }
    }
    NSLog(@"XCode适配已成功,所有插件都可以正常使用了~");
    return 0;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值