Skip to content

Commit

Permalink
Add swift-create-sign-upload-xcframework GitHub Action workflow (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adobels authored May 4, 2024
1 parent a378ab7 commit fa2c563
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/swift-create-sign-upload-xcframework.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: swift-create-sign-upload-xcframework

on:
release:
types: [created]
workflow_dispatch:

env:
XCFRAMEWORK_OUTPUT_DIR: .xcframework
XCFRAMEWORK_NAME: UIViewKit
XCFRAMEWORK_NAME_WITH_EXTENSION: UIViewKit.xcframework

jobs:
create-xcframework:
runs-on: macos-latest
steps:
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.CERTIFICATE_P12 }}
p12-password: ${{ secrets.CERTIFICATE_P12_PASSWORD }}
- name: Checkout Project
uses: actions/[email protected]
- name: Build XCFramework
run: ./buildxcf.sh
- name: Upload XCFramework as Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.XCFRAMEWORK_NAME_WITH_EXTENSION }}
path: ${{ env.XCFRAMEWORK_OUTPUT_DIR }}/${{ env.XCFRAMEWORK_NAME_WITH_EXTENSION }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## XCFramework BUILD_DIR
.xcframework

## User settings
xcuserdata/

Expand Down
8 changes: 7 additions & 1 deletion Sources/UIViewKit/IBDebug/IBDebug.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ public final class IBDebug {
}
}

public static func showFrames(of view: UIView, includeGivenView: Bool = true, includeUIKitPrivateViews: Bool = false) {
public static func showFrames(of view: UIView, borderColor: UIColor? = nil, includeGivenView: Bool = true, includeUIKitPrivateViews: Bool = false) {
if includeGivenView {
view.layer.borderWidth = 1
if let borderColor {
view.layer.borderColor = borderColor.cgColor
}
}
allSubviews(of: view, includeUIKitPrivateViews: includeUIKitPrivateViews).forEach {
$0.layer.borderWidth = 1
if let borderColor {
$0.layer.borderColor = borderColor.cgColor
}
}
}

Expand Down
42 changes: 42 additions & 0 deletions Sources/UIViewKit/IBMeasure/IBMeasure.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// IBMeasure.swift
// UIViewKit
//
// Created by Blazej SLEBODA on 11/03/2024.
//

import UIKit

public final class IBMeasure {

private init() {}

@MainActor
public static func printVerticalDistance(from: NSLayoutAnchor<NSLayoutYAxisAnchor>, to: NSLayoutAnchor<NSLayoutYAxisAnchor>, rootView: UIView) {
rootView.ibSubviews {
MeasureView().ibAttributes {
$0.widthAnchor.constraint(equalToConstant: 1)
$0.topAnchor.constraint(equalTo: from)
$0.bottomAnchor.constraint(equalTo: to)
}
}
}

@MainActor
public static func printHorizontalDistance(fromLeft: NSLayoutAnchor<NSLayoutXAxisAnchor>, toRight: NSLayoutAnchor<NSLayoutXAxisAnchor>, rootView: UIView) {
rootView.ibSubviews {
MeasureView().ibAttributes {
$0.heightAnchor.constraint(equalToConstant: 1)
$0.leftAnchor.constraint(equalTo: fromLeft)
$0.rightAnchor.constraint(equalTo: toRight)
}
}
}

private class MeasureView: UIView {
override func layoutSubviews() {
super.layoutSubviews()
print(frame.height)
}
}
}
24 changes: 19 additions & 5 deletions UIViewKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
F27DB4FF2B7ACF4400AD7F66 /* UIViewDSL+Engine.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27DB4EC2B7ACE8000AD7F66 /* UIViewDSL+Engine.swift */; };
F27DB5002B7ACF4400AD7F66 /* UIViewDSL+IBOutlet.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27DB4EB2B7ACE8000AD7F66 /* UIViewDSL+IBOutlet.swift */; };
F27DB5012B7ACF4400AD7F66 /* UIViewDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27DB4EA2B7ACE8000AD7F66 /* UIViewDSL.swift */; };
F29368412BDEB0180063FA4B /* IBMeasure.swift in Sources */ = {isa = PBXBuildFile; fileRef = F293683F2BDEB0180063FA4B /* IBMeasure.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -71,6 +72,7 @@
F27DB4EA2B7ACE8000AD7F66 /* UIViewDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewDSL.swift; sourceTree = "<group>"; };
F27DB4EB2B7ACE8000AD7F66 /* UIViewDSL+IBOutlet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewDSL+IBOutlet.swift"; sourceTree = "<group>"; };
F27DB4EC2B7ACE8000AD7F66 /* UIViewDSL+Engine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIViewDSL+Engine.swift"; sourceTree = "<group>"; };
F293683F2BDEB0180063FA4B /* IBMeasure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IBMeasure.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -122,6 +124,7 @@
children = (
F27DB4992B7A156400AD7F66 /* IBConstraints */,
F27DB4AA2B7A156400AD7F66 /* IBDebug */,
F29368402BDEB0180063FA4B /* IBMeasure */,
F27DB49B2B7A156400AD7F66 /* IBPreviews */,
F27DB4A62B7A156400AD7F66 /* UIKitExtensions */,
F22D2FBB2B7D60440085D819 /* UIViewDSL */,
Expand Down Expand Up @@ -196,6 +199,14 @@
path = AutoresizingStrategy;
sourceTree = "<group>";
};
F29368402BDEB0180063FA4B /* IBMeasure */ = {
isa = PBXGroup;
children = (
F293683F2BDEB0180063FA4B /* IBMeasure.swift */,
);
path = IBMeasure;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -298,6 +309,7 @@
F27DB4FF2B7ACF4400AD7F66 /* UIViewDSL+Engine.swift in Sources */,
F27DB4BE2B7A156400AD7F66 /* HorizontalStack.swift in Sources */,
F27DB4BB2B7A156400AD7F66 /* IBPreview+FullScreenView.swift in Sources */,
F29368412BDEB0180063FA4B /* IBMeasure.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -432,7 +444,8 @@
F22EB0F12ADD8CFC00B70773 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1.9;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -448,7 +461,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.9;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
NEW_SETTING = "";
Expand All @@ -458,6 +471,7 @@
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INSTALL_OBJC_HEADER = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
Expand All @@ -466,7 +480,8 @@
F22EB0F22ADD8CFC00B70773 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1.9;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -482,15 +497,14 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.9;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
PRODUCT_BUNDLE_IDENTIFIER = com.adobels.UIViewKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = CARTAGE;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
Expand Down
38 changes: 38 additions & 0 deletions buildxcf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

echo "::group::Clean previous builds"
rm -rf $XCFRAMEWORK_OUTPUT_DIR
mkdir $XCFRAMEWORK_OUTPUT_DIR
echo "::endgroup::"

echo "::group::Build for iOS"
xcodebuild archive \
-scheme $XCFRAMEWORK_NAME \
-destination 'generic/platform=iOS' \
-archivePath "$XCFRAMEWORK_OUTPUT_DIR/ios" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
echo "::endgroup::"

echo "::group::Build for iOS Simulator"
xcodebuild archive \
-scheme $XCFRAMEWORK_NAME \
-destination 'generic/platform=iOS Simulator' \
-archivePath "$XCFRAMEWORK_OUTPUT_DIR/ios_simulator" \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
echo "::endgroup::"

echo "::group::Create XCFramework"
xcodebuild -create-xcframework \
-framework "$XCFRAMEWORK_OUTPUT_DIR/ios.xcarchive/Products/Library/Frameworks/$XCFRAMEWORK_NAME.framework" \
-framework "$XCFRAMEWORK_OUTPUT_DIR/ios_simulator.xcarchive/Products/Library/Frameworks/$XCFRAMEWORK_NAME.framework" \
-output "$XCFRAMEWORK_OUTPUT_DIR/$XCFRAMEWORK_NAME.xcframework"
echo "::endgroup::"

echo "::group::Sign XCFramework"
codesign -s "iPhone Distribution: Blazej SLEBODA (43VBDTY4E3)" \
--force \
--deep \
-- $XCFRAMEWORK_OUTPUT_DIR/$XCFRAMEWORK_NAME_WITH_EXTENSION
echo "::endgroup::"

0 comments on commit fa2c563

Please sign in to comment.