Skip to content

Instantly share code, notes, and snippets.

View SongJiaqiang's full-sized avatar
🌴
On vacation

Jarvis SongJiaqiang

🌴
On vacation
View GitHub Profile
# TARGET_NAME = "MyApp"
# Clean and Building both architectures.
xcodebuild -configuration "Release" -target "${TARGET_NAME}" -sdk iphoneos clean build
xcodebuild -configuration "Release" -target "${TARGET_NAME}" -sdk iphonesimulator clean build
# Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product.
lipo -create "${DEVICE_DIR}/${FMK_NAME}.a" "${SIMULATOR_DIR}/${FMK_NAME}.a" -output "${INSTALL_DIR}/${FMK_NAME}.a"
# Search supported architectures of library
lipo -info "/library/file/path"
@SongJiaqiang
SongJiaqiang / countries_languages.m
Created July 22, 2018 09:45
[iOS设备支持的国际和语言列表] #country #language
+ (NSArray<NSString *> *)allSupportedCountries {
NSArray<NSString *> *codes = NSLocale.ISOCountryCodes;
NSMutableArray<NSString *> *names = [NSMutableArray arrayWithCapacity:codes.count];
for (NSString *code in codes ) {
NSString *name = [code uppercaseString];
[names addObject:name];
NSLog(@"country >> code:%@ - name:%@", code, name);
}
return [names copy];
@SongJiaqiang
SongJiaqiang / CompressImage.m
Created July 10, 2018 02:31
ITCodeShare图片压缩到指定大小
/**
作者:ITCodeShare
链接:https://www.jianshu.com/p/99c3e6a6c033
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
*/
- (NSData *)compressQualityWithMaxLength:(NSInteger)maxLength {
CGFloat compression = 1;
// https://blog.helftone.com/demystifying-inner-shadows-in-quartz/
// Drawing the shadow in the same image
func roundedImage(for image: UIImage, bounds: CGRect, withShadow shadow: Bool) -> UIImage {
UIGraphicsBeginImageContextWithOptions(bounds.size, false, 0.0)
defer {
UIGraphicsEndImageContext()
}
let context = UIGraphicsGetCurrentContext()
@SongJiaqiang
SongJiaqiang / AppendStringToFile.swift
Last active July 6, 2018 02:57
在文件后面追加字符串
func appendStringToFile() {
let dir:NSURL = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.CachesDirectory, inDomains: NSSearchPathDomainMask.UserDomainMask).last as NSURL
let fileurl = dir.URLByAppendingPathComponent("file.txt")
let string = "\(NSDate())\n"
let data = string.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
if NSFileManager.defaultManager().fileExistsAtPath(fileurl.path!) {
var error:NSError?
if let fileHandle = NSFileHandle(forWritingToURL: fileurl, error: &error) {
func test() {
print("Lepton Test")
}
@SongJiaqiang
SongJiaqiang / OpenAppStoreWithAppID.m
Created April 27, 2018 08:20
打开app在appstore的介绍页面
/** 跳转AppStore app */
- (void)goAppStore:(NSString *)appId {
if (!appId || appId.length == 0) {
logError(@">> TTAD: AppId不能为空");
return;
}
logInfo(@">> TTAD: 跳转到内置appstore页: %@", appId);
NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", appId];
NSURL *openURL = [NSURL URLWithString:urlStr];
@SongJiaqiang
SongJiaqiang / OpenAppStoreWithAppID.m
Created April 27, 2018 08:20
打开app在appstore的介绍页面
/** 跳转AppStore app */
- (void)goAppStore:(NSString *)appId {
if (!appId || appId.length == 0) {
logError(@">> TTAD: AppId不能为空");
return;
}
logInfo(@">> TTAD: 跳转到内置appstore页: %@", appId);
NSString *urlStr = [NSString stringWithFormat:@"https://itunes.apple.com/cn/app/id%@", appId];
NSURL *openURL = [NSURL URLWithString:urlStr];
// Create a UIImage from sample buffer data
- (UIImage *) imageFromSampleBuffer:(CMSampleBufferRef) sampleBuffer {
// Get a CMSampleBuffer's Core Video image buffer for the media data
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
// Lock the base address of the pixel buffer
CVPixelBufferLockBaseAddress(imageBuffer, 0);
// Get the number of bytes per row for the pixel buffer
void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer);
@SongJiaqiang
SongJiaqiang / gif.swift
Last active October 16, 2019 05:39
保存gif到相册
import AssetsLibrary
import MobileCoreServices
/// 保存gif图到相册
func saveGif2Album() {
let gifPath = Bundle.main.path(forResource: "name", ofType: "gif")
let gifData = NSData(contentsOfFile: gifPath!) as Data
let library = ALAssetsLibrary()