Skip to content

Commit

Permalink
Add SPM support
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Sep 3, 2021
1 parent 2344a73 commit 1696669
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
_tmp_release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Leo Natan (Wix) on 7/3/20.
//

#import "LNViewHierarchyDumper.h"
#import <LNViewHierarchyDumper/LNViewHierarchyDumper.h>
#include <mach-o/dyld.h>
@import Darwin;

Expand Down
33 changes: 33 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// swift-tools-version:5.1

import PackageDescription

let package = Package(
name: "LNViewHierarchyDumper",
platforms: [
.iOS(.v13)
],
products: [
.library(
name: "LNViewHierarchyDumper",
type: .dynamic,
targets: ["LNViewHierarchyDumper"]),
.library(
name: "LNViewHierarchyDumper-Static",
type: .static,
targets: ["LNViewHierarchyDumper"]),
],
dependencies: [],
targets: [
.target(
name: "LNViewHierarchyDumper",
dependencies: [],
path: "LNViewHierarchyDumper",
exclude: [
"LNViewHierarchyDumper/Info.plist",
"LNViewHierarchyDumper.xcodeproj"
],
publicHeadersPath: "include"
),
]
)
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# LNViewHierarchyDumper

A framework for programmatically dumping the view hierarchy of your app into an Xcode 12-compatible view hierarchy file archive.
A framework for programmatically dumping the view hierarchy of your app into an Xcode 12 and 13 compatible view hierarchy file archive.

![](Screenshot.png)
[![GitHub release](https://img.shields.io/github/release/LeoNatan/LNViewHierarchyDumper.svg)](https://github.com/LeoNatan/LNViewHierarchyDumper/releases) [![GitHub stars](https://img.shields.io/github/stars/LeoNatan/LNViewHierarchyDumper.svg)](https://github.com/LeoNatan/LNViewHierarchyDumper/stargazers) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/LeoNatan/LNViewHierarchyDumper/master/LICENSE) <span class="badge-paypal"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BR68NJEJXGWL6" title="Donate to this project using PayPal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg?style=flat" alt="PayPal Donation Button" /></a></span>

The framework supports targeting iOS, tvOS and watchOS simulators, hardware devices (with developer image mounted), and macOS and Catalyst (with Xcode installed). Under unsupported targets or environments, the frameworks fails silently.
[![GitHub issues](https://img.shields.io/github/issues-raw/LeoNatan/LNViewHierarchyDumper.svg)](https://github.com/LeoNatan/LNViewHierarchyDumper/issues) [![GitHub contributors](https://img.shields.io/github/contributors/LeoNatan/LNPopupController.svg)](https://github.com/LeoNatan/LNViewHierarchyDumper/graphs/contributors) ![](https://img.shields.io/badge/swift%20package%20manager-compatible-green)

<p align="center"><img src="Screenshot.png"/></p>

The framework supports targeting iOS, tvOS and watchOS simulators, hardware devices (**with developer image mounted**), and macOS and Catalyst (with Xcode installed). Under unsupported targets or environments, the frameworks fails silently.

**This framework uses Xcode's internal DebugHierarchyFoundation framework, and is not AppStore safe**, thus you should use with care, only linking against it in development/testing scenarios/builds.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,36 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {

/* Begin PBXBuildFile section */
39114EE726E2C908004FC75B /* LNViewHierarchyDumper in Frameworks */ = {isa = PBXBuildFile; productRef = 39114EE626E2C908004FC75B /* LNViewHierarchyDumper */; };
39114EE826E2C908004FC75B /* LNViewHierarchyDumper in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 39114EE626E2C908004FC75B /* LNViewHierarchyDumper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
39B85D0424AF9C8400EF17BB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39B85D0324AF9C8400EF17BB /* AppDelegate.swift */; };
39B85D0624AF9C8400EF17BB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39B85D0524AF9C8400EF17BB /* SceneDelegate.swift */; };
39B85D0824AF9C8400EF17BB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39B85D0724AF9C8400EF17BB /* ViewController.swift */; };
39B85D0B24AF9C8400EF17BB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 39B85D0924AF9C8400EF17BB /* Main.storyboard */; };
39B85D0D24AF9C8500EF17BB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 39B85D0C24AF9C8500EF17BB /* Assets.xcassets */; };
39B85D1024AF9C8500EF17BB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 39B85D0E24AF9C8500EF17BB /* LaunchScreen.storyboard */; };
39B85D1E24AF9C9200EF17BB /* LNViewHierarchyDumper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39B85D1C24AF9C8B00EF17BB /* LNViewHierarchyDumper.framework */; };
39B85D1F24AF9C9200EF17BB /* LNViewHierarchyDumper.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39B85D1C24AF9C8B00EF17BB /* LNViewHierarchyDumper.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
39B85D1B24AF9C8B00EF17BB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 39B85D1724AF9C8B00EF17BB /* LNViewHierarchyDumper.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 39CA7FF524AEA316009883BC;
remoteInfo = LNViewHierarchyDumper;
};
39B85D2124AF9C9C00EF17BB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 39B85D1724AF9C8B00EF17BB /* LNViewHierarchyDumper.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 39CA7FF424AEA316009883BC;
remoteInfo = LNViewHierarchyDumper;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
39B85D2024AF9C9200EF17BB /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
39B85D1F24AF9C9200EF17BB /* LNViewHierarchyDumper.framework in Embed Frameworks */,
39114EE826E2C908004FC75B /* LNViewHierarchyDumper in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
39114EE326E2C8F6004FC75B /* LNViewHierarchyDumper */ = {isa = PBXFileReference; lastKnownFileType = folder; name = LNViewHierarchyDumper; path = ..; sourceTree = "<group>"; };
39B85D0024AF9C8400EF17BB /* ViewHierarchyDumpTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ViewHierarchyDumpTester.app; sourceTree = BUILT_PRODUCTS_DIR; };
39B85D0324AF9C8400EF17BB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
39B85D0524AF9C8400EF17BB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -57,7 +41,6 @@
39B85D0C24AF9C8500EF17BB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
39B85D0F24AF9C8500EF17BB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
39B85D1124AF9C8500EF17BB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
39B85D1724AF9C8B00EF17BB /* LNViewHierarchyDumper.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = LNViewHierarchyDumper.xcodeproj; path = ../LNViewHierarchyDumper/LNViewHierarchyDumper.xcodeproj; sourceTree = "<group>"; };
39B85D2524AFA74100EF17BB /* ViewHierarchyDumpTester.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ViewHierarchyDumpTester.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand All @@ -66,7 +49,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
39B85D1E24AF9C9200EF17BB /* LNViewHierarchyDumper.framework in Frameworks */,
39114EE726E2C908004FC75B /* LNViewHierarchyDumper in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -76,7 +59,7 @@
39B85CF724AF9C8400EF17BB = {
isa = PBXGroup;
children = (
39B85D1724AF9C8B00EF17BB /* LNViewHierarchyDumper.xcodeproj */,
39114EE326E2C8F6004FC75B /* LNViewHierarchyDumper */,
39B85D0224AF9C8400EF17BB /* ViewHierarchyDumpTester */,
39B85D0124AF9C8400EF17BB /* Products */,
39B85D1D24AF9C9200EF17BB /* Frameworks */,
Expand Down Expand Up @@ -106,14 +89,6 @@
path = ViewHierarchyDumpTester;
sourceTree = "<group>";
};
39B85D1824AF9C8B00EF17BB /* Products */ = {
isa = PBXGroup;
children = (
39B85D1C24AF9C8B00EF17BB /* LNViewHierarchyDumper.framework */,
);
name = Products;
sourceTree = "<group>";
};
39B85D1D24AF9C9200EF17BB /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand All @@ -136,9 +111,12 @@
buildRules = (
);
dependencies = (
39B85D2224AF9C9C00EF17BB /* PBXTargetDependency */,
39114EE526E2C901004FC75B /* PBXTargetDependency */,
);
name = ViewHierarchyDumpTester;
packageProductDependencies = (
39114EE626E2C908004FC75B /* LNViewHierarchyDumper */,
);
productName = ViewHierarchyDumpTester;
productReference = 39B85D0024AF9C8400EF17BB /* ViewHierarchyDumpTester.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -168,29 +146,13 @@
mainGroup = 39B85CF724AF9C8400EF17BB;
productRefGroup = 39B85D0124AF9C8400EF17BB /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 39B85D1824AF9C8B00EF17BB /* Products */;
ProjectRef = 39B85D1724AF9C8B00EF17BB /* LNViewHierarchyDumper.xcodeproj */;
},
);
projectRoot = "";
targets = (
39B85CFF24AF9C8400EF17BB /* ViewHierarchyDumpTester */,
);
};
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
39B85D1C24AF9C8B00EF17BB /* LNViewHierarchyDumper.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = LNViewHierarchyDumper.framework;
remoteRef = 39B85D1B24AF9C8B00EF17BB /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
39B85CFE24AF9C8400EF17BB /* Resources */ = {
isa = PBXResourcesBuildPhase;
Expand Down Expand Up @@ -218,10 +180,9 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
39B85D2224AF9C9C00EF17BB /* PBXTargetDependency */ = {
39114EE526E2C901004FC75B /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = LNViewHierarchyDumper;
targetProxy = 39B85D2124AF9C9C00EF17BB /* PBXContainerItemProxy */;
productRef = 39114EE426E2C901004FC75B /* LNViewHierarchyDumper */;
};
/* End PBXTargetDependency section */

Expand Down Expand Up @@ -431,6 +392,17 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
39114EE426E2C901004FC75B /* LNViewHierarchyDumper */ = {
isa = XCSwiftPackageProductDependency;
productName = LNViewHierarchyDumper;
};
39114EE626E2C908004FC75B /* LNViewHierarchyDumper */ = {
isa = XCSwiftPackageProductDependency;
productName = LNViewHierarchyDumper;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 39B85CF824AF9C8400EF17BB /* Project object */;
}
56 changes: 56 additions & 0 deletions releaseVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -e

if [[ -n $(git status --porcelain) ]]; then
echo -e >&2 "\033[1;31mCannot release version because there are unstaged changes:\033[0m"
git status --short
exit -2
fi

if [[ -n $(git tag --contains $(git rev-parse --verify HEAD)) ]]; then
echo -e >&2 "\033[1;31mThe latest commit is already contained in the following releases:\033[0m"
git tag --contains $(git rev-parse --verify HEAD)
exit -3
fi

# if [[ -n $(git log --branches --not --remotes) ]]; then
# echo -e "\033[1;34mPushing pending commits to git\033[0m"
# git push
# fi

CURRENT_VERSION=$(/usr/libexec/PlistBuddy LNViewHierarchyDumper/LNViewHierarchyDumper/Info.plist -c "Print CFBundleShortVersionString")
NEXT_VERSION=$(echo "$CURRENT_VERSION" | perl -pe 's/^((\d+\.)*)(-?\d+)(.*)$/$1.($3+1).$4/e')

echo -e "\033[1;34mUsing $NEXT_VERSION as release version\033[0m"

echo -e "\033[1;34mCreating release notes\033[0m"

RELEASE_NOTES_FILE=_tmp_release_notes.md

touch "${RELEASE_NOTES_FILE}"
open -Wn "${RELEASE_NOTES_FILE}"

if ! [ -s "${RELEASE_NOTES_FILE}" ]; then
echo >&2 "\033[1;31mNo release notes provided, aborting.\033[0m"
rm -f "${RELEASE_NOTES_FILE}"
exit -1
fi

echo -e "\033[1;34mUpdating framework version\033[0m"

/usr/libexec/PlistBuddy LNViewHierarchyDumper/LNViewHierarchyDumper/Info.plist -c "Set CFBundleShortVersionString $NEXT_VERSION" -c "Set CFBundleVersion 1"

echo -e "\033[1;34mCommitting all changes to Git for release $NEXT_VERSION\033[0m"

git add -A
git commit -m "$NEXT_VERSION"
git tag "$NEXT_VERSION"

git push
git push --tags

echo -e "\033[1;34mCreating a GitHub release\033[0m"

gh release create --repo LeoNatan/LNViewHierarchyDumper "$NEXT_VERSION" --title "v$NEXT_VERSION" --notes-file "${RELEASE_NOTES_FILE}"

rm -f "${RELEASE_NOTES_FILE}"

0 comments on commit 1696669

Please sign in to comment.