Skip to content

Add precompiled xcframework binary option for SPM #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions FlexLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -577,6 +578,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
Expand Down Expand Up @@ -638,6 +640,7 @@
24DA376F1EF843C500D1AB2F /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
Expand Down Expand Up @@ -673,6 +676,7 @@
24DA37701EF843C500D1AB2F /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUILD_LIBRARY_FOR_DISTRIBUTION = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
Expand Down Expand Up @@ -708,6 +712,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 2B210ECFE9D7665DACB8E8A7 /* Pods-FlexLayoutTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
DEVELOPMENT_TEAM = F37Y9H9E46;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
Expand All @@ -724,6 +729,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 38E690AA4AF8EDFC95DB6626 /* Pods-FlexLayoutTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
DEVELOPMENT_TEAM = F37Y9H9E46;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
Expand Down
6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let package = Package(
name: "FlexLayout",
products: [
.library(name: "FlexLayout", targets: ["FlexLayout"]),
.library(name: "FlexLayoutBinary", targets: ["FlexLayoutBinary"]),
.library(name: "FlexLayoutYoga", targets: ["FlexLayoutYoga"]),
.library(name: "FlexLayoutYogaKit", targets: ["FlexLayoutYogaKit"])
],
Expand All @@ -29,6 +30,11 @@ let package = Package(
.define("FLEXLAYOUT_SWIFT_PACKAGE")
]
),
.binaryTarget(
name: "FlexLayoutBinary",
url: "https://github.com/woohyunjin06/FlexLayout/releases/download/1.3.33/FlexLayout.xcframework.zip",
checksum: "9e81b4565e20cfed0d1c15ebfda181cd068f568fb1a2d627b407e96349eafe76"
),
.target(
name: "FlexLayoutYoga",
dependencies: [],
Expand Down
2 changes: 0 additions & 2 deletions Sources/Swift/YGLayoutExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import CoreGraphics
import FlexLayoutYoga
#endif

postfix operator %

extension Int {
public static postfix func % (value: Int) -> YGValue {
return YGValue(value: Float(value), unit: .percent)
Expand Down
43 changes: 43 additions & 0 deletions make_xcframework.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

FRAMEWORK_NAME="FlexLayout"
BUILD_DIRECTORY="Build"
DEVICE_ARCHIVE_DIRECTORY="$BUILD_DIRECTORY/device.xcarchive"
SIMULATOR_ARCHIVE_DIRECTORY="$BUILD_DIRECTORY/simulator.xcarchive"
XCFRAMEWORK_PATH="$BUILD_DIRECTORY/$FRAMEWORK_NAME.xcframework"

if [ ! -d "$BUILD_DIRECTORY" ]; then
mkdir $BUILD_DIRECTORY
fi

# Archive
xcodebuild archive\
-scheme "FlexLayout"\
-destination="device"\
-sdk iphoneos\
-archivePath "$DEVICE_ARCHIVE_DIRECTORY"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive\
-scheme "FlexLayout"\
-destination="simulator"\
-sdk iphonesimulator\
-archivePath "$SIMULATOR_ARCHIVE_DIRECTORY"\
SKIP_INSTALL=NO\
BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild -create-xcframework\
-framework "$DEVICE_ARCHIVE_DIRECTORY/Products/Library/Frameworks/$FRAMEWORK_NAME.framework"\
-framework "$SIMULATOR_ARCHIVE_DIRECTORY/Products/Library/Frameworks/$FRAMEWORK_NAME.framework"\
-output "$XCFRAMEWORK_PATH"

# Compress
zip -r -X "$XCFRAMEWORK_PATH.zip" "$XCFRAMEWORK_PATH/"

# Save the checksum
swift package compute-checksum "$XCFRAMEWORK_PATH.zip" >> $BUILD_DIRECTORY/checksum

# Clean up
rm -r $BUILD_DIRECTORY/*.xcframework
rm -r $BUILD_DIRECTORY/*.xcarchive