├── .gitignore ├── LICENSE ├── README.md ├── RubbishCodeDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── RubbishCodeDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── Models │ ├── Person.h │ └── Person.m ├── ViewControllers │ ├── DetailViewController.h │ ├── DetailViewController.m │ ├── ViewController.h │ └── ViewController.m ├── Views │ ├── MyView.h │ └── MyView.m └── main.m └── addRubbishCode ├── .idea ├── addRubbishCode.iml ├── misc.xml ├── modules.xml └── workspace.xml ├── __pycache__ ├── addRandomUI.cpython-36.pyc └── addRandomUI.cpython-37.pyc ├── addRandomUI.py ├── addRubbishCode.py └── word.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots/**/*.png 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 shxlxa 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpamCodeDemo 2 | Add rubbish code for iOS object-c project 3 | 4 | 用python脚本,给iOS代码添加随机生成的垃圾代码 5 | 6 | 由于同一个项目需要为不同的客户生成不同UI的app,而这样直接提交审核会在苹果机审代码时被以马甲包的名义拒掉,而且后果很严重,基本上这个bundle ID就废了,因此,需要对app的代码进行一些处理: 7 | # 在项目中增加垃圾代码混淆 8 | 9 | >添加垃圾代码的逻辑是,用`python`随机生成各种垃圾代码,循环遍历需要添加代码的文件,读取文件内容,在适当的位置添加垃圾代码 10 | 11 | 话不多说,上代码: 12 | ### 一、在`addRandomUI.py`文件中,有以下函数 13 | #### 1.生成一个随机长度的有大小写字母组成的字符串 14 | ```python 15 | # 产生一个satrtIndex到endIndex位长度的随机字符串 16 | def getRandomStr(satrtIndex,endIndex): 17 | numbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 18 | # random.choice()从列表中返回一个随机数 19 | final = (random.choice(numbers)) 20 | # 从(50,100)列表中取出一个随机数 21 | index = random.randint(satrtIndex, endIndex) 22 | for i in range(index): 23 | final += (random.choice(numbers)) 24 | return final 25 | ``` 26 | #### 2.生成NSString类,NSArray类等等 27 | ```python 28 | # 生成NSString类 29 | def addNSString(): 30 | line = '- (NSString *)' + getRandomStr(15,20) + ':(NSString *)' + getRandomStr(15,20) + ' {\n ' 31 | stringName = getRandomStr(15,20) 32 | string = 'NSString *' + stringName + ' = @"' + getRandomStr(50,100) + '";\n return '+ stringName + ';\n}' 33 | return line+string + '\n\n' 34 | 35 | # 生成NSArray类 36 | def addNSArray(): 37 | line = '- (NSArray *)' + getRandomStr(15,20) + ':(NSArray *)' + getRandomStr(15,20) + ' {\n ' 38 | arrayName = getRandomStr(15,20) 39 | arrayString = 'NSArray *' + arrayName + ' = @[\n' 40 | for i in range(1,15): 41 | element = ' @"' + getRandomStr(50,100) + '",\n' 42 | arrayString += element 43 | arrayString += ' ];\n return ' + arrayName + ';\n}' 44 | return line + arrayString 45 | ``` 46 | 47 | #### 3.随机调用生成的垃圾代码 48 | ```python 49 | # 随机调用(addNSString(),addNSArray(),addNSData(),addNSDictionary(),addUIImage())中的某个函数 50 | def addRandomClass(): 51 | index = random.randint(1, 5) 52 | if index == 1: 53 | string = addNSString() 54 | elif index == 2: 55 | string = addNSArray() 56 | elif index == 3: 57 | string = addNSData() 58 | elif index == 4: 59 | string = addNSDictionary() 60 | else: 61 | string = addUIImage() 62 | return string 63 | ``` 64 | 65 | ### 二、在`addRubbishCode.py`文件中 66 | >有了addRandomUI.py可以根据需要随机生成垃圾代码,现在的问题就是把这些代码插入到适当的位置,还要保证能运行不出错误 67 | 68 | 先来看几个函数: 69 | #### 1.由于.h文件和.m文件最后都有`@end`,我们就把垃圾代码添加在最后一个`@end`前面,下面函数获取文件中 `@end` 的总数量 70 | ```python 71 | # 获取文件中 @end 的总数量 72 | def GetMFileEndCount(file_path,old_str): 73 | file_data = "" 74 | print('filePath------'+file_path) 75 | Ropen=open(file_path,'r')#读取文件 76 | flagCount = 0 77 | for line in Ropen: 78 | if old_str in line: 79 | flagCount += 1 80 | return flagCount 81 | ``` 82 | 83 | ### 2.向.h文件中添加属性代码 84 | ```python 85 | #.h文件添加废代码 86 | def HFileAddCode(file_path,old_str,endTotalCount): 87 | # .h文件里属性的类型从这个数组里随机选 88 | classArray = ['NSString', 'UILabel', 'NSDictionary', 'NSData', 'UIScrollView', 'UIView', 'UITextView', 89 | 'UITableView', 'UIImageView'] 90 | file_data = "" 91 | Ropen=open(file_path,'r') 92 | flagCount = 0 93 | for line in Ropen: 94 | nameStr = addRandomUI.getRandomStr(6, 10) 95 | className = random.choice(classArray) 96 | 97 | if old_str in line: 98 | flagCount += 1 99 | if flagCount==endTotalCount: 100 | file_data += '\n@property(nonatomic,strong) '+className +' *'+nameStr+';\n' 101 | file_data += line 102 | else: 103 | file_data += line 104 | file_data += '\n' 105 | Ropen.close() 106 | Wopen=open(file_path,'w') 107 | Wopen.write(file_data) 108 | Wopen.close() 109 | ``` 110 | ### 3.向.m文件添加垃圾代码 111 | ```python 112 | #.m文件添加垃圾代码 113 | def MFileAddCode(file_path,old_str,endTotalCount): 114 | 115 | file_data = "" 116 | print('filePath------'+file_path) 117 | Ropen=open(file_path,'r')#读取文件 118 | flagCount = 0 119 | for line in Ropen: 120 | if old_str in line: 121 | flagCount += 1 122 | # 在最后一个 '@end' 前面加上垃圾代码 123 | if flagCount==endTotalCount: 124 | file_data += addRandomUI.addRandomClass() + '\n\n' 125 | file_data += line 126 | else: 127 | file_data += line 128 | Ropen.close() 129 | Wopen=open(file_path,'w') 130 | Wopen.write(file_data) 131 | Wopen.close() 132 | ``` 133 | 134 | ### 4.循环遍历指定文件夹中的文件 135 | ```python 136 | # 循环递归遍历文件夹 137 | def traverse(file_dir): 138 | fs = os.listdir(file_dir) 139 | for dir in fs: 140 | tmp_path = os.path.join(file_dir, dir) 141 | if not os.path.isdir(tmp_path): 142 | addCode(tmp_path) 143 | else: 144 | # 是文件夹,则递归调用 145 | traverse(tmp_path) 146 | ``` 147 | 148 | ### 5.主调用函数 149 | >可以在这里做相关配置 150 | >`codeCount` :每个文件中添加的代码数量 151 | `file_prefix` :主工程目录 152 | `file_dirs`: 要添加垃圾代码文件所在的文件夹路径 153 | 154 | ```python 155 | def addRubbish(): 156 | global codeCount 157 | # 每个文件中添加的代码数量 158 | codeCount = 5 159 | # 主工程目录 160 | file_prefix = '../RubbishCodeDemo/' 161 | # 要添加垃圾代码文件所在的文件夹路径 162 | file_dirs = ['ViewControllers',"Views","Models"] 163 | for dir in file_dirs: 164 | file_dir = file_prefix + dir 165 | traverse(file_dir) 166 | ``` 167 | 168 | ### 三、其他 169 | #### 1.注意点 170 | >对于那些model文件,需要添加垃圾代码的,需要在model中先导入`UIKit`框架 171 | 172 | #### 2. 使用方法:进入到python脚本文件夹, `python3 addRubbishCode.py`运行脚本 173 | 174 | #### 3.工程只是加了垃圾代码,还不能通过审核,还需要批量修改类名,给类名添加前缀和后缀,请参考 [https://my.oschina.net/FEEDFACF/blog/1627398](https://my.oschina.net/FEEDFACF/blog/1627398) 175 | >我自己通过加垃圾代码和修改类名这两个方法之后,用同一份代码已经上架了6个app 176 | 177 | -------------------------------------------------------------------------------- /RubbishCodeDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F180721D215DD10000122819 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F180721C215DD10000122819 /* AppDelegate.m */; }; 11 | F1807220215DD10000122819 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F180721F215DD10000122819 /* ViewController.m */; }; 12 | F1807223215DD10000122819 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F1807221215DD10000122819 /* Main.storyboard */; }; 13 | F1807225215DD10800122819 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F1807224215DD10800122819 /* Assets.xcassets */; }; 14 | F1807228215DD10800122819 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F1807226215DD10800122819 /* LaunchScreen.storyboard */; }; 15 | F180722B215DD10800122819 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F180722A215DD10800122819 /* main.m */; }; 16 | F1807234215DD16C00122819 /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F1807233215DD16C00122819 /* DetailViewController.m */; }; 17 | F1807237215DD29A00122819 /* MyView.m in Sources */ = {isa = PBXBuildFile; fileRef = F1807236215DD29A00122819 /* MyView.m */; }; 18 | F180723C215DF8C100122819 /* Person.m in Sources */ = {isa = PBXBuildFile; fileRef = F180723B215DF8C100122819 /* Person.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | F1807218215DD10000122819 /* RubbishCodeDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RubbishCodeDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | F180721B215DD10000122819 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | F180721C215DD10000122819 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | F180721E215DD10000122819 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 26 | F180721F215DD10000122819 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 27 | F1807222215DD10000122819 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | F1807224215DD10800122819 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | F1807227215DD10800122819 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | F1807229215DD10800122819 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | F180722A215DD10800122819 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 32 | F1807232215DD16C00122819 /* DetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; 33 | F1807233215DD16C00122819 /* DetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = ""; }; 34 | F1807235215DD29A00122819 /* MyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyView.h; sourceTree = ""; }; 35 | F1807236215DD29A00122819 /* MyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyView.m; sourceTree = ""; }; 36 | F180723A215DF8C100122819 /* Person.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Person.h; sourceTree = ""; }; 37 | F180723B215DF8C100122819 /* Person.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Person.m; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | F1807215215DD10000122819 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | ); 46 | runOnlyForDeploymentPostprocessing = 0; 47 | }; 48 | /* End PBXFrameworksBuildPhase section */ 49 | 50 | /* Begin PBXGroup section */ 51 | F180720F215DD10000122819 = { 52 | isa = PBXGroup; 53 | children = ( 54 | F180721A215DD10000122819 /* RubbishCodeDemo */, 55 | F1807219215DD10000122819 /* Products */, 56 | ); 57 | sourceTree = ""; 58 | }; 59 | F1807219215DD10000122819 /* Products */ = { 60 | isa = PBXGroup; 61 | children = ( 62 | F1807218215DD10000122819 /* RubbishCodeDemo.app */, 63 | ); 64 | name = Products; 65 | sourceTree = ""; 66 | }; 67 | F180721A215DD10000122819 /* RubbishCodeDemo */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | F1807239215DF8AC00122819 /* Models */, 71 | F1807238215DF77400122819 /* Views */, 72 | F1807231215DD11800122819 /* ViewControllers */, 73 | F180721B215DD10000122819 /* AppDelegate.h */, 74 | F180721C215DD10000122819 /* AppDelegate.m */, 75 | F1807221215DD10000122819 /* Main.storyboard */, 76 | F1807224215DD10800122819 /* Assets.xcassets */, 77 | F1807226215DD10800122819 /* LaunchScreen.storyboard */, 78 | F1807229215DD10800122819 /* Info.plist */, 79 | F180722A215DD10800122819 /* main.m */, 80 | ); 81 | path = RubbishCodeDemo; 82 | sourceTree = ""; 83 | }; 84 | F1807231215DD11800122819 /* ViewControllers */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | F180721E215DD10000122819 /* ViewController.h */, 88 | F180721F215DD10000122819 /* ViewController.m */, 89 | F1807232215DD16C00122819 /* DetailViewController.h */, 90 | F1807233215DD16C00122819 /* DetailViewController.m */, 91 | ); 92 | path = ViewControllers; 93 | sourceTree = ""; 94 | }; 95 | F1807238215DF77400122819 /* Views */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | F1807235215DD29A00122819 /* MyView.h */, 99 | F1807236215DD29A00122819 /* MyView.m */, 100 | ); 101 | path = Views; 102 | sourceTree = ""; 103 | }; 104 | F1807239215DF8AC00122819 /* Models */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | F180723A215DF8C100122819 /* Person.h */, 108 | F180723B215DF8C100122819 /* Person.m */, 109 | ); 110 | path = Models; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | F1807217215DD10000122819 /* RubbishCodeDemo */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = F180722E215DD10800122819 /* Build configuration list for PBXNativeTarget "RubbishCodeDemo" */; 119 | buildPhases = ( 120 | F1807214215DD10000122819 /* Sources */, 121 | F1807215215DD10000122819 /* Frameworks */, 122 | F1807216215DD10000122819 /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = RubbishCodeDemo; 129 | productName = RubbishCodeDemo; 130 | productReference = F1807218215DD10000122819 /* RubbishCodeDemo.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | /* End PBXNativeTarget section */ 134 | 135 | /* Begin PBXProject section */ 136 | F1807210215DD10000122819 /* Project object */ = { 137 | isa = PBXProject; 138 | attributes = { 139 | LastUpgradeCheck = 0940; 140 | ORGANIZATIONNAME = cft; 141 | TargetAttributes = { 142 | F1807217215DD10000122819 = { 143 | CreatedOnToolsVersion = 9.4.1; 144 | }; 145 | }; 146 | }; 147 | buildConfigurationList = F1807213215DD10000122819 /* Build configuration list for PBXProject "RubbishCodeDemo" */; 148 | compatibilityVersion = "Xcode 9.3"; 149 | developmentRegion = en; 150 | hasScannedForEncodings = 0; 151 | knownRegions = ( 152 | en, 153 | Base, 154 | ); 155 | mainGroup = F180720F215DD10000122819; 156 | productRefGroup = F1807219215DD10000122819 /* Products */; 157 | projectDirPath = ""; 158 | projectRoot = ""; 159 | targets = ( 160 | F1807217215DD10000122819 /* RubbishCodeDemo */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXResourcesBuildPhase section */ 166 | F1807216215DD10000122819 /* Resources */ = { 167 | isa = PBXResourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | F1807228215DD10800122819 /* LaunchScreen.storyboard in Resources */, 171 | F1807225215DD10800122819 /* Assets.xcassets in Resources */, 172 | F1807223215DD10000122819 /* Main.storyboard in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | F1807214215DD10000122819 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | F180723C215DF8C100122819 /* Person.m in Sources */, 184 | F1807220215DD10000122819 /* ViewController.m in Sources */, 185 | F180722B215DD10800122819 /* main.m in Sources */, 186 | F180721D215DD10000122819 /* AppDelegate.m in Sources */, 187 | F1807234215DD16C00122819 /* DetailViewController.m in Sources */, 188 | F1807237215DD29A00122819 /* MyView.m in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin PBXVariantGroup section */ 195 | F1807221215DD10000122819 /* Main.storyboard */ = { 196 | isa = PBXVariantGroup; 197 | children = ( 198 | F1807222215DD10000122819 /* Base */, 199 | ); 200 | name = Main.storyboard; 201 | sourceTree = ""; 202 | }; 203 | F1807226215DD10800122819 /* LaunchScreen.storyboard */ = { 204 | isa = PBXVariantGroup; 205 | children = ( 206 | F1807227215DD10800122819 /* Base */, 207 | ); 208 | name = LaunchScreen.storyboard; 209 | sourceTree = ""; 210 | }; 211 | /* End PBXVariantGroup section */ 212 | 213 | /* Begin XCBuildConfiguration section */ 214 | F180722C215DD10800122819 /* Debug */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_ENABLE_OBJC_WEAK = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 241 | CLANG_WARN_STRICT_PROTOTYPES = YES; 242 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 243 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | CODE_SIGN_IDENTITY = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = dwarf; 249 | ENABLE_STRICT_OBJC_MSGSEND = YES; 250 | ENABLE_TESTABILITY = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu11; 252 | GCC_DYNAMIC_NO_PIC = NO; 253 | GCC_NO_COMMON_BLOCKS = YES; 254 | GCC_OPTIMIZATION_LEVEL = 0; 255 | GCC_PREPROCESSOR_DEFINITIONS = ( 256 | "DEBUG=1", 257 | "$(inherited)", 258 | ); 259 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 260 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 261 | GCC_WARN_UNDECLARED_SELECTOR = YES; 262 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 263 | GCC_WARN_UNUSED_FUNCTION = YES; 264 | GCC_WARN_UNUSED_VARIABLE = YES; 265 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 266 | MTL_ENABLE_DEBUG_INFO = YES; 267 | ONLY_ACTIVE_ARCH = YES; 268 | SDKROOT = iphoneos; 269 | }; 270 | name = Debug; 271 | }; 272 | F180722D215DD10800122819 /* Release */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_ANALYZER_NONNULL = YES; 277 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 278 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 279 | CLANG_CXX_LIBRARY = "libc++"; 280 | CLANG_ENABLE_MODULES = YES; 281 | CLANG_ENABLE_OBJC_ARC = YES; 282 | CLANG_ENABLE_OBJC_WEAK = YES; 283 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 284 | CLANG_WARN_BOOL_CONVERSION = YES; 285 | CLANG_WARN_COMMA = YES; 286 | CLANG_WARN_CONSTANT_CONVERSION = YES; 287 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 288 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 289 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 290 | CLANG_WARN_EMPTY_BODY = YES; 291 | CLANG_WARN_ENUM_CONVERSION = YES; 292 | CLANG_WARN_INFINITE_RECURSION = YES; 293 | CLANG_WARN_INT_CONVERSION = YES; 294 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 295 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 296 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 297 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 298 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 299 | CLANG_WARN_STRICT_PROTOTYPES = YES; 300 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 301 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 302 | CLANG_WARN_UNREACHABLE_CODE = YES; 303 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 304 | CODE_SIGN_IDENTITY = "iPhone Developer"; 305 | COPY_PHASE_STRIP = NO; 306 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 307 | ENABLE_NS_ASSERTIONS = NO; 308 | ENABLE_STRICT_OBJC_MSGSEND = YES; 309 | GCC_C_LANGUAGE_STANDARD = gnu11; 310 | GCC_NO_COMMON_BLOCKS = YES; 311 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 312 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 313 | GCC_WARN_UNDECLARED_SELECTOR = YES; 314 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 315 | GCC_WARN_UNUSED_FUNCTION = YES; 316 | GCC_WARN_UNUSED_VARIABLE = YES; 317 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 318 | MTL_ENABLE_DEBUG_INFO = NO; 319 | SDKROOT = iphoneos; 320 | VALIDATE_PRODUCT = YES; 321 | }; 322 | name = Release; 323 | }; 324 | F180722F215DD10800122819 /* Debug */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 328 | CODE_SIGN_STYLE = Automatic; 329 | DEVELOPMENT_TEAM = 7Y3TV276B8; 330 | INFOPLIST_FILE = RubbishCodeDemo/Info.plist; 331 | LD_RUNPATH_SEARCH_PATHS = ( 332 | "$(inherited)", 333 | "@executable_path/Frameworks", 334 | ); 335 | PRODUCT_BUNDLE_IDENTIFIER = cn.anc.RubbishCodeDemo; 336 | PRODUCT_NAME = "$(TARGET_NAME)"; 337 | TARGETED_DEVICE_FAMILY = "1,2"; 338 | }; 339 | name = Debug; 340 | }; 341 | F1807230215DD10800122819 /* Release */ = { 342 | isa = XCBuildConfiguration; 343 | buildSettings = { 344 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 345 | CODE_SIGN_STYLE = Automatic; 346 | DEVELOPMENT_TEAM = 7Y3TV276B8; 347 | INFOPLIST_FILE = RubbishCodeDemo/Info.plist; 348 | LD_RUNPATH_SEARCH_PATHS = ( 349 | "$(inherited)", 350 | "@executable_path/Frameworks", 351 | ); 352 | PRODUCT_BUNDLE_IDENTIFIER = cn.anc.RubbishCodeDemo; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | TARGETED_DEVICE_FAMILY = "1,2"; 355 | }; 356 | name = Release; 357 | }; 358 | /* End XCBuildConfiguration section */ 359 | 360 | /* Begin XCConfigurationList section */ 361 | F1807213215DD10000122819 /* Build configuration list for PBXProject "RubbishCodeDemo" */ = { 362 | isa = XCConfigurationList; 363 | buildConfigurations = ( 364 | F180722C215DD10800122819 /* Debug */, 365 | F180722D215DD10800122819 /* Release */, 366 | ); 367 | defaultConfigurationIsVisible = 0; 368 | defaultConfigurationName = Release; 369 | }; 370 | F180722E215DD10800122819 /* Build configuration list for PBXNativeTarget "RubbishCodeDemo" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | F180722F215DD10800122819 /* Debug */, 374 | F1807230215DD10800122819 /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | /* End XCConfigurationList section */ 380 | }; 381 | rootObject = F1807210215DD10000122819 /* Project object */; 382 | } 383 | -------------------------------------------------------------------------------- /RubbishCodeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RubbishCodeDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /RubbishCodeDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /RubbishCodeDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /RubbishCodeDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /RubbishCodeDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Models/Person.h: -------------------------------------------------------------------------------- 1 | // 2 | // Person.h 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | // 对于model需要导入 UIKit 框架,可以给model一个baseModel基类,在基类 import 12 | #import 13 | 14 | @interface Person : NSObject 15 | 16 | @property (nonatomic, copy) NSString *name; 17 | 18 | @property (nonatomic, assign) float height; 19 | 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Models/Person.m: -------------------------------------------------------------------------------- 1 | // 2 | // Person.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import "Person.h" 10 | 11 | @implementation Person 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RubbishCodeDemo/ViewControllers/DetailViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.h 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol DragDelegate 12 | 13 | @optional 14 | - (void)headerRereshing; 15 | - (void)footerRereshing; 16 | @end 17 | 18 | 19 | @interface DetailViewController : UIViewController{ 20 | UIView *view; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /RubbishCodeDemo/ViewControllers/DetailViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DetailViewController.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import "DetailViewController.h" 10 | 11 | @interface DetailViewController () 12 | 13 | @property (nonatomic, strong) NSArray *arr; 14 | 15 | @end 16 | 17 | @implementation DetailViewController{ 18 | UIImageView *img; 19 | } 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | 24 | 25 | } 26 | 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /RubbishCodeDemo/ViewControllers/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /RubbishCodeDemo/ViewControllers/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @interface ViewController () 12 | 13 | @end 14 | 15 | @implementation ViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | // Do any additional setup after loading the view, typically from a nib. 20 | } 21 | 22 | 23 | - (void)didReceiveMemoryWarning { 24 | [super didReceiveMemoryWarning]; 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Views/MyView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyView.h 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MyView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /RubbishCodeDemo/Views/MyView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyView.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import "MyView.h" 10 | 11 | @implementation MyView 12 | 13 | 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /RubbishCodeDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // RubbishCodeDemo 4 | // 5 | // Created by aoni on 2018/9/28. 6 | // Copyright © 2018年 cft. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /addRubbishCode/.idea/addRubbishCode.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /addRubbishCode/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /addRubbishCode/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /addRubbishCode/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | true 64 | DEFINITION_ORDER 65 | 66 | 67 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 105 | 106 | 107 | 108 | 111 | 112 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 145 | 146 | 165 | 166 | 167 | 168 | 169 | 182 | 183 | 196 | 197 | 214 | 215 | 227 | 228 | project 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 263 | 264 | 283 | 284 | 305 | 306 | 328 | 329 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 1536551698701 372 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 406 | 409 | 410 | 411 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | -------------------------------------------------------------------------------- /addRubbishCode/__pycache__/addRandomUI.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shxlxa/RubbishCodeDemo/b1f03b2338879a557afe884686615b5704f7870d/addRubbishCode/__pycache__/addRandomUI.cpython-36.pyc -------------------------------------------------------------------------------- /addRubbishCode/__pycache__/addRandomUI.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shxlxa/RubbishCodeDemo/b1f03b2338879a557afe884686615b5704f7870d/addRubbishCode/__pycache__/addRandomUI.cpython-37.pyc -------------------------------------------------------------------------------- /addRubbishCode/addRandomUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import random 4 | 5 | 6 | # 产生一个satrtIndex到endIndex位长度的随机字符串 7 | def getRandomStr(satrtIndex,endIndex): 8 | numbers = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 9 | # random.choice()从列表中返回一个随机数 10 | final = (random.choice(numbers)) 11 | # 从(50,100)列表中取出一个随机数 12 | index = random.randint(satrtIndex, endIndex) 13 | for i in range(index): 14 | final += (random.choice(numbers)) 15 | return final 16 | 17 | 18 | def getRandomWord(): 19 | file_path = 'word.txt' 20 | try: 21 | f = open(file_path, 'r+') 22 | lines = f.readlines() 23 | return random.choice(lines).strip() 24 | except Exception as e: 25 | print(e) 26 | 27 | # name = getRandomWord()(50,100) 28 | # word = getRandomWord() 29 | # print(word) 30 | 31 | 32 | # 生成NSString类 33 | def addNSString(): 34 | line = '- (NSString *)' + getRandomWord() + ':(NSString *)' + getRandomWord() + ' {\n ' 35 | stringName = getRandomWord() 36 | string = 'NSString *' + stringName + ' = @"' + getRandomWord() + '";\n return '+ stringName + ';\n}' 37 | return line+string + '\n\n' 38 | 39 | # 生成NSArray类 40 | def addNSArray(): 41 | line = '- (NSArray *)' + getRandomWord() + ':(NSArray *)' + getRandomWord() + ' {\n ' 42 | arrayName = getRandomWord() 43 | arrayString = 'NSArray *' + arrayName + ' = @[\n' 44 | for i in range(1,15): 45 | element = ' @"' + getRandomWord() + '",\n' 46 | arrayString += element 47 | arrayString += ' ];\n return ' + arrayName + ';\n}' 48 | return line + arrayString 49 | 50 | 51 | # 生成NSData类 52 | def addNSData(): 53 | line = '- (NSData *)' + getRandomWord() + ':(NSString *)' + getRandomWord() + ' {\n ' 54 | dataName = getRandomWord() 55 | string = 'NSData *' + dataName + ' = [@"' + getRandomWord() + '"' + ' dataUsingEncoding:NSUTF8StringEncoding]' + ';\n return '+ dataName + ';\n}' 56 | return line+string 57 | 58 | 59 | # 生成NSArray类 60 | def addNSDictionary(): 61 | line = '- (NSDictionary *)' + getRandomWord() + ':(NSArray *)' + getRandomWord() + ' {\n ' 62 | dictName = getRandomWord() 63 | dictString = 'NSDictionary *' + dictName + ' = @{\n' 64 | for i in range(1,10): 65 | element = ' @"' + getRandomWord() + '" : ' + '@"' + getRandomWord() + '",\n' 66 | dictString += element 67 | 68 | dictString += ' };\n return ' + dictName + ';\n}' 69 | return line + dictString 70 | 71 | 72 | # 生成UIImage类 73 | def addUIImage(): 74 | line = '- (UIImage *)' + getRandomWord() + ':(UIImage *)' + getRandomWord() + ' {\n ' 75 | dataName = getRandomWord() 76 | imageName = getRandomWord() 77 | string = 'NSData *' + dataName + ' = [@"' + getRandomWord() + '"' + ' dataUsingEncoding:NSUTF8StringEncoding]' + ';\n ' 78 | string += 'UIImage *' + imageName + ' = [UIImage imageWithData:' + dataName + '];\n ' 79 | string += 'return '+ imageName + ';\n}' 80 | 81 | return line+string + '\n\n' 82 | 83 | 84 | # 随机调用(addNSString(),addNSArray(),addNSData(),addNSDictionary(),addUIImage())中的某个函数 85 | def addRandomClass(): 86 | index = random.randint(1, 5) 87 | if index == 1: 88 | string = addNSString() 89 | elif index == 2: 90 | string = addNSArray() 91 | elif index == 3: 92 | string = addNSData() 93 | elif index == 4: 94 | string = addNSDictionary() 95 | else: 96 | string = addUIImage() 97 | return string 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /addRubbishCode/addRubbishCode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import random 4 | import os 5 | import addRandomUI 6 | 7 | 8 | # 获取文件中 @end 的总数量 9 | def GetMFileEndCount(file_path,old_str): 10 | file_data = "" 11 | print('filePath------'+file_path) 12 | Ropen=open(file_path,'r')#读取文件 13 | flagCount = 0 14 | for line in Ropen: 15 | if old_str in line:#如果.h文件中的某一行里包含old_str,则往这一行添加一下语句 16 | flagCount += 1 17 | return flagCount 18 | 19 | #.h文件添加废代码 20 | def HFileAddCode(file_path,old_str,endTotalCount): 21 | # .h文件里属性的类型从这个数组里随机选 22 | classArray = ['NSString', 'UILabel', 'NSDictionary', 'NSData', 'UIScrollView', 'UIView', 'UITextView', 23 | 'UITableView', 'UIImageView'] 24 | file_data = "" 25 | Ropen=open(file_path,'r') 26 | flagCount = 0 27 | for line in Ropen: 28 | nameStr = addRandomUI.getRandomWord() 29 | className = random.choice(classArray) 30 | 31 | if old_str in line: 32 | flagCount += 1 33 | if flagCount==endTotalCount: 34 | file_data += '\n@property(nonatomic,strong) '+className +' *'+nameStr+';\n' 35 | file_data += line 36 | else: 37 | file_data += line 38 | Ropen.close() 39 | Wopen=open(file_path,'w') 40 | Wopen.write(file_data) 41 | Wopen.close() 42 | 43 | 44 | 45 | #.m文件添加垃圾代码 46 | def MFileAddCode(file_path,old_str,endTotalCount): 47 | 48 | file_data = "" 49 | print('filePath------'+file_path) 50 | Ropen=open(file_path,'r')#读取文件 51 | flagCount = 0 52 | for line in Ropen: 53 | if old_str in line: 54 | flagCount += 1 55 | # 在最后一个 '@end' 前面加上垃圾代码 56 | if flagCount==endTotalCount: 57 | file_data += addRandomUI.addRandomClass() + '\n\n' 58 | file_data += line 59 | else: 60 | file_data += line 61 | Ropen.close() 62 | Wopen=open(file_path,'w') 63 | Wopen.write(file_data) 64 | Wopen.close() 65 | 66 | 67 | def addCode(file_path): 68 | global codeCount 69 | if '.h' in file_path: # file_dir+'/'+file含义是file_dir文件夹下的file文件 70 | # 获取文件中 @end 的总数量,在最后一个 @end 前面添加垃圾代码 71 | hCount = GetMFileEndCount(file_path,"@end") 72 | for num in range(codeCount): 73 | HFileAddCode(file_path, "@end", hCount) 74 | 75 | if '.m' in file_path: 76 | mCount = GetMFileEndCount(file_path,"@end") 77 | for num in range(codeCount): 78 | MFileAddCode(file_path, "@end", mCount) 79 | 80 | 81 | # 循环递归遍历文件夹 82 | def traverse(file_dir): 83 | fs = os.listdir(file_dir) 84 | for dir in fs: 85 | tmp_path = os.path.join(file_dir, dir) 86 | if not os.path.isdir(tmp_path): 87 | addCode(tmp_path) 88 | else: 89 | # 是文件夹,则递归调用 90 | traverse(tmp_path) 91 | 92 | 93 | def addRubbish(): 94 | global codeCount 95 | # 每个文件中添加的代码数量 96 | codeCount = 5 97 | # 主工程目录 98 | file_prefix = '../RubbishCodeDemo/' 99 | # 要添加垃圾代码文件所在的文件夹路径 100 | file_dirs = ['ViewControllers',"Views","Models"] 101 | for dir in file_dirs: 102 | file_dir = file_prefix + dir 103 | traverse(file_dir) 104 | 105 | 106 | def main(): 107 | addRubbish() 108 | print('add code success') 109 | 110 | 111 | if __name__ == '__main__': 112 | main() 113 | --------------------------------------------------------------------------------