Skip to content

Instantly share code, notes, and snippets.

View kewlbear's full-sized avatar

Changbeom Ahn kewlbear

View GitHub Profile
@kewlbear
kewlbear / webkit-ios-xcode.md
Last active January 18, 2023 12:22
build webkit for iOS using Xcode
@kewlbear
kewlbear / DuplicateKeyChecker.swift
Created March 11, 2021 05:44
Swift currently crashes at runtime with "Fatal error: "Dictionary literal contains duplicate keys" if you have duplicate keys in a dictionary literal. They even don't print actual duplicate keys. This struct collects all the duplicate keys and print them with count.
struct DuplicateKeyChecker<Key: Hashable, Value>: ExpressibleByDictionaryLiteral {
init(dictionaryLiteral elements: (Key, Value)...) {
var count: [Key: Int] = [:]
for (key, _) in elements {
count[key] = (count[key] ?? 0) + 1
}
print(#function, "duplicate keys:", count.filter { $0.value > 1 })
}
}
#!/bin/sh
xcodebuild archive -scheme "KissXML (iOS)" -destination "generic/platform=iOS" -archivePath iOS SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme "KissXML (iOS)" -destination "platform=macOS,variant=Mac Catalyst" -archivePath catalyst SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
xcodebuild archive -scheme "KissXML (iOS)" -destination "generic/platform=iOS Simulator" -archivePath simulator SKIP_INSTALL=NO BUILD_LIBRARIES_FOR_DISTRIBUTION=YES
FRAMEWORKS=""
for framework in iOS catalyst simulator
do
FRAMEWORKS="$FRAMEWORKS -framework $framework.xcarchive/Products/Library/Frameworks/KissXML.framework"
if let normalized = url.withUnsafeFileSystemRepresentation({ fileSystemRepresentation -> URL? in
guard let bytes = fileSystemRepresentation, let path = String(utf8String: bytes) else {
print("not UTF8?", fileSystemRepresentation)
return nil
}
return URL(fileURLWithPath: path.decomposedStringWithCanonicalMapping)
}),
normalized != url {
do {
try FileManager.default.moveItem(at: url, to: normalized)
@kewlbear
kewlbear / gist:699c3bb15b25eef58df85f8c4f4c1b76
Created May 11, 2017 00:42
Webkit document.querySelector('meta[name=viewport]').content = 'width=320' call flow
...
JSC::callCustomSetter(...)
WebCore::setJSHTMLMetaElementContentFunction(...)
...
WebCore::HTMLMetaElement::process()
WebCore::Document::processViewport(...)
...
WebCore::Chrome::dispatchViewportPropertiesDidChange(...)
WebKit::WebChromeClient::dispatchViewportPropertiesDidChange(...)
WebKit::WebPage::viewportPropertiesDidChange(...)
@kewlbear
kewlbear / gist:394980573ea9dd38e2d5ed96671442b1
Created May 8, 2017 07:30
Fix swift playground unable to find headers used by cocoa pods
In project navigator, navigate to workspace > Pods > Pods > {Pod name here} > Support files > {Pod name here}.xcconfig.
Copy relevant path from HEADER_SEARCH_PATHS and paste at the end of SWIFT_INCLUDE_PATHS.
For Kanna, copy and paste libxml2 include path.
@kewlbear
kewlbear / gist:5d3aa493cd806a3f9f6ea84e6738977c
Created May 8, 2017 07:21
Generate swift playground with cocoa pods for macOS
pod playgrounds --platform osx {Pod name here}
@kewlbear
kewlbear / gist:44ee10fcfdd7c26817a71b12e3e00950
Last active May 8, 2017 07:33
repl.swift:2:1: error: 'URLQueryItem' is only available on OS X 10.10 or newer
error: repl.swift:2:1: error: 'URLQueryItem' is only available on OS X 10.10 or newer
swift -target x86_64-macosx10.12