└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # iOS Command CheatSheet 2 | 3 | This is a console command cheat sheet for iOS developers. 4 | 5 | Command CheetSheet for iOS Developer 6 | 7 | - Certificates / Provisioning Profiles 8 | - CocoaPods 9 | - Carthage 10 | - Fastlane 11 | - Swift Compiler 12 | - SwiftLint 13 | - Xcode 14 | - Simulator 15 | - Homebrew 16 | - .gitignore 17 | - Firebase 18 | 19 | ## Certificates / Provisioning Profiles 20 | 21 | ```bash 22 | # Create Private Key 23 | openssl genrsa -out private.key 2048 24 | 25 | # Create CSR 26 | openssl req -new -key private.key -out CertificateSigningRequest.certSigningRequest -subj "/emailAddress=[YourMailAddress], CN=[CommonName], C=JP" 27 | 28 | # Print certificates in keychain 29 | security find-identity -p codesigning -v 30 | 31 | # Print provisioning profiles 32 | ls ~/Library/MobileDevice/Provisioning\ Profiles/ 33 | ``` 34 | 35 | ## CocoaPods 36 | 37 | ```bash 38 | # Install 39 | sudo gem install cocoapods 40 | 41 | # Delete Pods 42 | rm -rf Pods; rm Podfile; rm Podfile.lock 43 | 44 | # Init Podfile 45 | pod init 46 | 47 | # Install libraries 48 | pod install 49 | 50 | # Update libraries 51 | pod update 52 | 53 | # Create PodSpec 54 | pod spec create pod_name 55 | 56 | # Lint PodSpec 57 | pod lib lint 58 | 59 | # Create your trunk account 60 | pod trunk register mail_address 'your_name' 61 | 62 | # Publish pods 63 | pod trunk push pod_name.podspec 64 | 65 | # Delete caches 66 | pod cache clean --all 67 | rm -rf ~/Library/Caches/CocoaPods/ 68 | ``` 69 | 70 | ## Carthage 71 | 72 | ```bash 73 | # Install 74 | brew install Carthage 75 | 76 | # Install Libraries 77 | carthage bootstrap --platform iOS --cache-builds 78 | 79 | # Update Libraries 80 | carthage update --platform iOS --cache-builds 81 | 82 | # Create XCFileList 83 | ls Carthage/Build/iOS | grep -E .+framework$ | sed 's/.*/$(SRCROOT)\/Carthage\/Build\/iOS\/&/' > Carthage.xcfilelist 84 | 85 | # Build 86 | carthage build --no-skip-current 87 | 88 | # Delete Caches 89 | rm -rf ~/Library/Caches/org.carthage.CarthageKit 90 | rm -rf ~/Library/Caches/carthage 91 | ``` 92 | 93 | ## Fastlane 94 | 95 | ```bash 96 | # Install 97 | brew cask install fastlane 98 | 99 | # Init fastlane 100 | fastlane init 101 | 102 | # Download Metadata 103 | fastlane deliver download_metadata --force 104 | 105 | # Upload Metadata 106 | fastlane deliver --force --skip_screenshots --skip_binary_upload --skip_app_version_update --skip_metadata false 107 | 108 | # Download Screenshot 109 | fastlane deliver download_screenshots --force 110 | 111 | # Create Screenshot 112 | fastlane frameit(path: './fastlane/screenshots/', white: false) 113 | 114 | # Upload Screenshot 115 | fastlane deliver --force --skip_binary_upload --skip_metadata --skip_app_version_update --overwrite_screenshots --skip_screenshots false 116 | 117 | # Upload Binary 118 | fastlane deliver --force --skip_screenshots --skip_metadata --skip_app_version_update 119 | 120 | # Submit for AppStore review 121 | fastlane deliver --force --skip_screenshots --skip_metadata --skip_app_version_update --skip_binary_upload --automatic_release --submit_for_review 122 | 123 | # Delete session cookie 124 | rm ~/.fastlane/spaceship/**/cookie 125 | ``` 126 | 127 | ## Swift Compiler 128 | ```bash 129 | # Parse and type-check input file(s) and pretty print AST(s) 130 | swiftc -print-ast file 131 | # Parse and type-check input file(s) and dump AST(s) 132 | swiftc -dump-ast file 133 | ``` 134 | 135 | ## SwiftLint 136 | 137 | ```bash 138 | # Install 139 | brew install swiftlint 140 | 141 | # Lint 142 | swiftlint 143 | 144 | # AutoCorrect 145 | swiftlint autocorrect 146 | 147 | # Print Docs 148 | swiftlint generate-docs 149 | 150 | # Copy All Opt-In Rules 151 | swiftlint rules | awk -F "|" '$3 ~ "yes" { print $2 }' | tr -d ' ' | sed 's/^/ - /' | pbcopy 152 | 153 | # Delete Caches 154 | rm -rf ~/Library/Caches/SwiftLint 155 | ``` 156 | 157 | ## Xcode 158 | 159 | ```bash 160 | 161 | # Switch the developer path to the specified Xcode application 162 | sudo xcode-select --switch /Applications/Xcode.app 163 | 164 | # Check the number of cores on the system and set the number to use for building 165 | system_profiler SPHardwareDataType | grep "Cores" 166 | defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks [number_of_cores] 167 | 168 | # Enable Xcode to show the build duration 169 | defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES 170 | 171 | # Print out the targets, configurations, and schemes in the current project 172 | xcodebuild -list 173 | 174 | # Print out the available SDKs that Xcode can build against 175 | xcodebuild -showsdks 176 | 177 | # Clean the disk by removing old build archives to save space 178 | rm -rf ~/Library/Developer/Xcode/Archives 179 | 180 | # Remove iOS Device Support data to save disk space 181 | rm -rf ~/Library/Developer/Xcode/iOS DeviceSupport/ 182 | 183 | # Remove old iPhone Simulator data 184 | rm -rf ~/Library/Application Support/iPhone Simulator 185 | 186 | # Clean build by deleting the build cache 187 | xcodebuild -alltargets clean 188 | 189 | # Remove Xcode's derived data to clear any cached build settings or intermediates 190 | rm -rf ~/Library/Developer/Xcode/DerivedData/ 191 | 192 | # Clear Xcode's cache to ensure a clean build environment 193 | rm -rf ~/Library/Caches/com.apple.dt.Xcode/ 194 | 195 | # Remove cache files related to iOS Device Support 196 | rm -rf ~/Library/Developer/Xcode/iOS\ DeviceSupport/*/Symbols/System/Library/Caches 197 | 198 | # Delete Xcode's cache files 199 | xcrun --kill-cache 200 | 201 | # Terminate the Xcode build service to stop any ongoing build processes 202 | killall XCBBuildService 203 | 204 | # Remove Clang module cache to prevent potential conflicts or outdated modules 205 | rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache" 206 | rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache" 207 | 208 | # Remove temporary Clang module cache 209 | rm -rf "$TMPDIR/../C/clang/ModuleCache" 210 | ``` 211 | 212 | ## Simulator 213 | 214 | ```bash 215 | # List all available devices, device types, runtimes, and device pairs 216 | xcrun simctl list 217 | 218 | # List all available device types that can be created 219 | xcrun simctl list devicetypes 220 | 221 | # List only the devices that are currently booted 222 | xcrun simctl list | grep Booted 223 | 224 | # Open a URL in a device with the specified UUID 225 | xcrun simctl openurl 226 | 227 | # Open a URL in the currently booted device 228 | xcrun simctl openurl booted 229 | 230 | # Grant the Photos app permission for the booted device using the specified bundle ID 231 | xcrun simctl privacy booted grant photos 232 | 233 | # Revoke the Photos app permission for the booted device using the specified bundle ID 234 | xcrun simctl privacy booted revoke photos 235 | 236 | # Reset the privacy permissions for all apps on the booted device using the specified bundle ID 237 | xcrun simctl privacy booted reset all 238 | 239 | # Send a simulated push notification to the booted device from the specified payload file 240 | xcrun simctl push booted payload.json 241 | 242 | # Override the status bar display for the booted device to a specific time, cellular bars, network type, and Wi-Fi mode 243 | xcrun simctl status_bar booted override --time 12:01 --cellularBars 1 --dataNetwork 3g --wifiMode failed 244 | 245 | # Clear any status bar overrides and revert to the device's default status bar settings 246 | xcrun simctl status_bar booted clear 247 | 248 | # Add a root certificate to the booted device's keychain from the specified file 249 | xcrun simctl keychain booted add-root-cert myCA.pem 250 | 251 | # Record a video of the booted device's screen and save it to a file 252 | xcrun simctl io booted recordVideo video.mp4 253 | 254 | # Record a video of the booted device's screen with the specified codec and ignore the mask 255 | xcrun simctl io booted recordVideo --codec h264 --mask ignored video.mp4 256 | 257 | # Record a video of an externally displayed screen of the booted device 258 | xcrun simctl io booted recordVideo --display external video.mp4 259 | 260 | # Paste the contents of the device's clipboard to the host machine 261 | xcrun simctl pbpaste booted 262 | 263 | # Synchronize the clipboard content from the host to the booted device 264 | xcrun simctl pbsync host booted 265 | 266 | # Get information about the booted device's clipboard 267 | xcrun simctl pbinfo booted 268 | 269 | # Send a simulated APNS push notification to the booted device using the specified bundle ID and payload 270 | xcrun simctl push booted payload.apns 271 | 272 | # Delete all simulators that are set to show in the device previews 273 | xcrun simctl --set previews delete all 274 | 275 | # Erase all content and settings from all simulators 276 | xcrun simctl erase all 277 | ``` 278 | 279 | ## Homebrew 280 | 281 | ```bash 282 | # Install 283 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 284 | 285 | # Delete Caches 286 | rm -rf ~/Library/Caches/Homebrew 287 | brew cleanup -s 288 | rm -rf $(brew --cache) 289 | ``` 290 | 291 | ## .gitignore 292 | 293 | ```bash 294 | # Create .gitignore 295 | brew install gibo 296 | gibo dump Swift Xcode >> .gitignore 297 | 298 | # Quick Commit .gitignore 299 | git add .gitignore;git commit -m "add .gitignore" 300 | 301 | # Quick Commit Igonored Files 302 | git rm -r --cached .;git add .;git commit -m "rm ignore files" 303 | ``` 304 | 305 | ## Firebase 306 | 307 | ```bash 308 | # Upload dSYM 309 | ./Pods/FirebaseCrashlytics/upload-symbols -gsp GoogleService-Info.plist -p ios ~/Downloads/appDsyms.zip 310 | 311 | Scripts/upload-symbols -gsp GoogleService-Info.plist -p ios ~/Downloads/appDsyms*.zip 312 | 313 | ./Frameworks/Firebase/FirebaseCrashlytics/upload-symbols -gsp GoogleService-Info.plist -p ios ~/Downloads/appDsyms*.zip 314 | ``` 315 | 316 | --------------------------------------------------------------------------------