Skip to content

Instantly share code, notes, and snippets.

View acalism's full-sized avatar
🏠
Working from home

Dawn Song acalism

🏠
Working from home
  • Tencent, Alibaba
  • Shenzhen City, Guangdong Province, China
View GitHub Profile
@acalism
acalism / AppleDevices.m
Last active October 31, 2022 06:05
How to get Device Model and Model Name(Human readable)
// see my comments
@acalism
acalism / how to verify or read mobile provisioning profile
Created January 19, 2016 03:28
verify or read .mobileprovision file
1. Use openssl
openssl smime -in /path/to/your.mobileprovision -inform der -verify
2. Use security command
security cms -Di /path/to/your.mobileprovision
@acalism
acalism / make-xcframework.sh
Last active May 26, 2022 02:51
best zshell script to create xcframework
#!/bin/zsh
# 必须用 zsh,否则后面的数组操作可能失败
# 需要编译的 scheme,可以改为你自己的,或者给脚本传递 -s 参数
scheme="T4"
configuration=Release
usesFramework=1 # 是否以 framework 为容器。framework 装的也可能是静态库
protocol MakeSelf {
init()
}
class MS: MakeSelf {
static let shared = MS()
required init() {
//
}
}
@acalism
acalism / FindHost.swift
Last active April 4, 2020 00:03
Find hostView or hostViewController
import UIKit
// MARK: - FindHostView
protocol FindHostView {
associatedtype T
var hostView: T? { get }
}
copy these files from Xcode 9 to Xcode 10 like this:
1. copy stdc++*.tbd to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
2. copy stdc++*.dylib to
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
// same with each other
NS_AVAILABLE_IOS(10.0)
__IOS_AVAILABLE(10.0)
@acalism
acalism / confusing-naming-error.m
Last active August 12, 2018 02:41
ld error. It's really difficult to locate the problem.
// in header file
extern struct LALIMtopAPI {
__unsafe_unretained NSString *logout;
__unsafe_unretained NSString *login;
} const kLALIMtopAPI;
// implementation file
@acalism
acalism / LineLimitedTextView.swift
Last active August 11, 2018 13:15
Pitfall in Calculating a line-limited textView's size
textView.attributedText = originalContent
let lineLimit = 5
textView.isEditable = true
textView.isScrollEnabled = false
// eliminate inner paddings, when right is minus number, it seems useless.
// textView.contentInset = UIEdgeInsets(top: 0, left: -5, bottom: 0, right: 0)
textView.textContainer.lineFragmentPadding = 0; // better way
textView.textContainerInset = .zero // default is (8, 0, 8, 0)
textView.textContainer.maximumNumberOfLines = lineLimit // Important condition
@acalism
acalism / LineLimitedLabel.swift
Last active July 12, 2018 14:48
Pitfalls in calculating label size
// 1. 多行文本
let label = UILabel()
label.font = Font.f14
label.numberOfLines = 2 // 若此处的行数限定为0(即可无数行),则以下面的 limitedToNumberOfLines 为准;否则两个行数中较小的那个会生效
label.text = model.svideoInfo.svideoTitle // 多行文本
let titleRect = label.textRect(forBounds: CGRect(origin: .zero, size: CGSize(width: cellWidth - margins.xInset, height: CGFloat.greatestFiniteMagnitude)), limitedToNumberOfLines: 0)
// 事实上,用sizeThatFits(_:)就好了。