Class: BabybusInstallEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb

Instance Method Summary collapse

Instance Method Details

#copyCocosPackageObject

2D母包替换



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb', line 93

def copyCocosPackage
    puts "===拷贝Cocos母包文件操作===>".yellow
    rootPath = getProjectRootPath
    bundleIdentifier = getProjectBundleIdentifier
    cocosResName
    cocosSrcName
    sourceRespath = File.join(rootPath, "Configs", "#{bundleIdentifier}/#{cocosResName}")
    sourceSrcpath = File.join(rootPath, "Configs", "#{bundleIdentifier}/#{cocosSrcName}")
    if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
        sourceRespath = File.join(rootPath, "Configs/Cocos", "#{bundleIdentifier}/#{cocosResName}")
        sourceSrcpath = File.join(rootPath, "Configs/Cocos", "#{bundleIdentifier}/#{cocosSrcName}")
        if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
            sourceRespath = File.join(rootPath, "Configs/Cocos", "#{cocosResName}")
            sourceSrcpath = File.join(rootPath, "Configs/Cocos", "#{cocosSrcName}")
            if !File.directory?(sourceRespath) || !File.directory?(sourceSrcpath)
                sourceRespath = File.join(rootPath, "game_package/develop", "#{cocosResName}")
                sourceSrcpath = File.join(rootPath, "game_package/develop", "#{cocosSrcName}")
            end
        end
    end
    if File.directory?(sourceRespath) && File.directory?(sourceSrcpath)
        puts "link cocos res path:#{sourceRespath}\r\nsrc path:#{sourceSrcpath}"
        descResPath = cocosResPath
        desrcSrcPath = cocosSrcPath
        link(sourceRespath, descResPath)
        link(sourceSrcpath, desrcSrcPath)
        puts "替换cocos母包文件成功".yellow
    end
end

#copyPlistMacroObject

v3.bbcloud.babybus.com/team/184/wiki/11667 使用工程目录下的BBPlistMacro 文件替换掉./Pods/BBBaseSDK/Pod/Classes/Macros/Macros/BBPlistMacro (为了工程新拉下来时候不用手动替换该文件) 注意点1:BBPlistMacro 和BBBaseSDK下存在差异时,如果工程已打开的情况需要重启工程文件才能被Xcode识别到 注意点2:BBPlistMacro 有任何的改动,都需要即使同步到 ../<包名>_BBPlistMacro.h 下面



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb', line 11

def copyPlistMacro
    puts "===拷贝PlistMacro文件操作===>".yellow
    rootPath = getProjectRootPath
    bundleIdentifier = getProjectBundleIdentifier
    path = File.join(rootPath, "Configs", "#{bundleIdentifier}/BBPlistMacro.h")
    puts "查找PlistMacro文件1:#{path}"
    if !File.file?(path)
        path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}/BBPlistMacro.h")
        puts "查找PlistMacro文件2:#{path}"
        if !File.file?(path)
            path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}_BBPlistMacro.h")
            puts "查找PlistMacro文件3:#{path}"
            if !File.file?(path)
                path = File.join(rootPath, "Configs/PlistMacro", "BBPlistMacro.h")
                puts "查找PlistMacro文件4:#{path}"
            end
        end
    end
    if File.file?(path)
        replaceFilePath = "./Pods/BBBaseSDK/Pod/Classes/Macros/Macros/BBPlistMacro.h"
        system "chmod 755 #{replaceFilePath}"
        system "cp -avf #{path} #{replaceFilePath}"
        puts "替换PlistMacro文件成功".yellow
    else
        puts "找不到PlistMacro配置文件,替换失败path:#{path}".red
    end
end

#copyUnityFrameworkObject

3D替换产物



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb', line 53

def copyUnityFramework
    puts "===拷贝3D产物文件操作===>".yellow
    rootPath = getProjectRootPath
    bundleIdentifier = getProjectBundleIdentifier
    path = File.join(rootPath, "Configs", "#{bundleIdentifier}/UnityFramework.framework")
    puts "查找UnityFramework产物1:#{path}"
    if !File.file?(path)
        path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}/UnityFramework.framework")
        puts "查找UnityFramework产物2:#{path}"
        if !File.directory?(path)
            path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}_UnityFramework.framework")
            puts "查找UnityFramework产物3:#{path}"
            if !File.directory?(path)
                path = File.join(rootPath, "Configs/UnityFramework", "UnityFramework.framework")
                puts "查找UnityFramework产物4:#{path}"
            end
        end
    end
    if File.directory?(path)
        replaceFilePath = "./Pods/BBUnityFramework/UnityFramework.framework"
        # step.1 获取原目录下没有资源
        system "cp -af #{replaceFilePath}/Info.plist #{path}/Info.plist"
        oldModules = "#{replaceFilePath}/Modules"
        newModules = "#{path}/Modules"
        if !File.directory?(newModules)
            system "cp -af #{oldModules} #{newModules}"
        end
        oldheaders = "#{replaceFilePath}/Headers"
        newHeaders = "#{path}/Headers"
        if !File.directory?(newHeaders)
            system "cp -af #{oldheaders} #{newHeaders}"
        end
        system "chmod 755 #{replaceFilePath}"
        system "rm -rf #{replaceFilePath}; cp -af #{path} #{replaceFilePath}"
        puts "替换UnityFramework文件成功".yellow
    else
        puts "找不到UnityFramework产物文件,替换失败".red
    end
end

#createCocosResourceObject

3D 打包res src 被删除但索引未删除需要重新添加文件夹



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb', line 39

def createCocosResource
    resPath = cocosResPath
    srcPath = cocosSrcPath
    if (File.exist?(resPath)) then
#            system "rm -rf #{resPath}/* #{srcPath}/*"
        puts "已存在 删除res src内容"
    else
        # 避免untify产物删除资源,工程依赖异常
        system "mkdir -p #{resPath}"
        system "mkdir -p #{srcPath}"
        puts "生成res src资源文件夹"
    end
end