Skip to content

Instantly share code, notes, and snippets.

@andrewwoz
andrewwoz / enum_elem.swift
Last active October 15, 2019 06:05
[Enumerating elements in directory] #fs
let resourceKeys: [URLResourceKey] = [.creationDateKey, .nameKey, .fileSizeKey]
let desctopEnumerator = fs.enumerator(at: desctop, includingPropertiesForKeys: resourceKeys)!
for case let fileURL as URL in desctopEnumerator {
guard let resourceProps = try? fileURL.resourceValues(forKeys: Set(resourceKeys)),
let size = resourceProps.fileSize,
let date = resourceProps.creationDate,
let name = resourceProps.name else { continue }
let sizeMB = size / 1_048_576
@andrewwoz
andrewwoz / shell_name.sh
Last active October 15, 2019 06:04
[Determine current shell] #shell
echo $0
@andrewwoz
andrewwoz / codesign_inspect.sh
Last active October 15, 2019 06:04
[Inspect details about codesign of application] #codesign
$ codesign -d --verbose App.app/
@andrewwoz
andrewwoz / verify_code_sign.sh
Last active October 15, 2019 06:01
[Verify Code Signing of application] #codesign
$ codesign -v --verbose=5 /path/to/App.app
@andrewwoz
andrewwoz / code_sign.sh
Last active October 15, 2019 06:01
[Sign an application with a certificate (Code signing)] #codesign
$ codesign -s "iPhone Developer: Team name (TEAM_ID)" /path/to/App.app
@andrewwoz
andrewwoz / inpect_provisioning_provide.sh
Last active October 15, 2019 06:04
[Inspect provisioning profile] #codesign
$ cd ~/Library/MobileDevice/Provisioning\ Profiles/
$ security cms -D -i xxxxxxxx_your_pp_id.mobileprovision
@andrewwoz
andrewwoz / ipa_entitilements.sh
Last active October 15, 2019 06:03
[Inspect entitlement for .ipa archive] #codesign
# to check the entitlements of the .ipa:
# 1. Find the .ipa file and change its the extension to .zip.
# 2. Expand the file .zip. This will produce a Payload folder containing your .app bundle.
# Use the `codesign` tool to check the entitlements on the .app bundle
$ codesign -d --entitlements :- "Payload/YourApp.app"
@andrewwoz
andrewwoz / inspect_entitlement_of_compiled_app.sh
Last active October 15, 2019 06:03
[Inspect Entitlements of compiled application] #codesign
$ codesign -d --entitlements :- PATH_TO_APP.app
@andrewwoz
andrewwoz / p12info.sh
Last active October 15, 2019 06:02
[Get information about certificate and private key from .p12 certificate format] #codesign
$ openssl pkcs12 -info -in mycert.p12
@andrewwoz
andrewwoz / generate_p12.sh
Last active October 15, 2019 06:02
[Export `.cer` certificate to `.p12` certificate with private key in it] Good for backup and shring with other developers #codesign
$ openssl x509 -in #XXXXX#.cer -inform DER -out mycert.pem -outform PEM
$ openssl pkcs12 -export -inkey my.key -in mycert.pem -out mycert.p12