Skip to content

Instantly share code, notes, and snippets.

View crespoxiao's full-sized avatar

Chengfei Xiao crespoxiao

View GitHub Profile
@crespoxiao
crespoxiao / gist:79043445cbfff77bf6cb07ef822bb8cf
Created December 5, 2017 01:54
iOS 命令行获取设备 UDID
1. 获取真机 udid
1)
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'
2)
system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\1/p'
3)
#!/bin/bash
#!/bin/sh
PROGNAME=$(basename "$0")
PROGDIR=$(dirname "$0")
usage()
{
echo "Usage: $PROGNAME [option] -p path-of-project"
echo ""
echo "-p Specifyed the path of your project"
@crespoxiao
crespoxiao / gist:e5ec18352d6f59dadf482620dbc53894
Created January 31, 2018 08:38
Showing TODO as warning in Xcode project
1. solution 1 --- add run script
TAGS="TODO:|FIXME:|XXX:"
echo "searching patch is ${SRCROOT}"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
2. solution 2 --- by code
#define STRINGIFY(S) #S
import tinify
import os
import os.path
import sys
print "file name:", sys.argv[0]
for i in range(1, len(sys.argv)):
print "para:", i, sys.argv[i]
sourceFilePath = sys.argv[1] # source path
@crespoxiao
crespoxiao / gist:28c7267cf50fdd87ca30691312c92987
Created November 13, 2017 12:30
bitcode opencore-amr-iOS
#!/bin/sh
### Modified from http://blog.csdn.net/favormm/article/details/6772097
set -xe
DEVELOPER=`xcode-select -print-path`
DEST=`pwd .`"/opencore-amr-iOS"
ARCHS="i386 x86_64 armv7 armv7s arm64"
LIBS="libopencore-amrnb.a libopencore-amrwb.a"
# Note that AMR-NB is for narrow band http://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec
@crespoxiao
crespoxiao / gist:fbd900cf537229fdcf736dfa377d5c7b
Created September 22, 2017 12:10
fix App Icons not included in build from Xcode 9 With CocoaPods
post_install do |installer|
copy_pods_resources_path = "Pods/Target Support Files/Pods-XXX/Pods-XXX-resources.sh"
string_to_replace = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"'
assets_compile_with_app_icon_arguments = '--compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" --app-icon "${ASSETCATALOG_COMPILER_APPICON_NAME}" --output-partial-info-plist "${BUILD_DIR}/assetcatalog_generated_info.plist"'
text = File.read(copy_pods_resources_path)
new_contents = text.gsub(string_to_replace, assets_compile_with_app_icon_arguments)
File.open(copy_pods_resources_path, "w") {|file| file.puts new_contents }
end
#!/bin/bash
#
# 需要安装 Ghostscript,brew install gs
# 使用示例 ./pdf2png.sh xx.xcassets
# TODO: 递归遍历目录,实现全自动化
if [[ $# < 1 ]]; then
echo "Usage:" >&1
echo " convert-assets /assets " >&1
exit 1
@crespoxiao
crespoxiao / gist:d39b31eb96afcd03e6ab7adfa67dcc2c
Created April 21, 2017 10:28 — forked from floriankugler/gist:6870499
Mapping of NSURLConnection to NSURLSession delegate methods. Created by Mattt Thompson.
NSURLConnection | NSURLSession
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connectionShouldUseCredentialStorage: |
------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------
NSURLConnectionDelegate connection:willSendRequestForAuthenticationChallenge: | NSURLSessionDelegate URLSession:didReceiveChallenge:completionHandler:
| N
@crespoxiao
crespoxiao / gist:a4fbd45d2368f20bb4d8
Last active February 10, 2017 03:04 — forked from kwylez/gist:5301597
Custom UIViewTransition Example
- (void)transitionFromViewController:(UIViewController *)fromViewController
toViewController:(UIViewController *)toViewController
withAnimationType:(EPBUIViewAnimationTransition)animation
fromFrame:(CGRect)aFrame
withOverLayImage:(NSString *)overlayName {
static NSInteger standardImageTag = 9999;
if (fromViewController == toViewController) {
return;
@crespoxiao
crespoxiao / gist:0a4519fbf0efd68161d6
Last active February 10, 2017 03:03 — forked from alexandreraulin/gist:f4b1504aec9d25f5af08
Script for iOS Universal Framework compilation with Xcode 6
# This script is based on Jacob Van Order's answer on apple dev forums https://devforums.apple.com/message/971277
# See also http://spin.atomicobject.com/2011/12/13/building-a-universal-framework-for-ios/ for the start
# To get this to work with a Xcode 6 Cocoa Touch Framework, create Framework
# Then create a new Aggregate Target. Throw this script into a Build Script Phrase on the Aggregate
######################
# Options