Skip to content

Commit

Permalink
chore: remove include folder (#25)
Browse files Browse the repository at this point in the history
* chore(xcframework): binary target simplified & headers mapped

* chore(script): update with new structure
  • Loading branch information
cbrzn authored Jul 13, 2023
1 parent 56ad5ba commit 482c6ae
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 444 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ DerivedData/
/Frameworks/PolywrapClientNative.xcframework/*/PolywrapClientNative.a
.swiftpm
/Sources/PolywrapClient/Resources/wrappers
/Frameworks/PolywrapClientNative.xcframework/*/PolywrapClientNative.framework/PolywrapClientNative.a
/Frameworks/PolywrapClientNative.xcframework/*/PolywrapClientNative.framework/Headers/
/Frameworks/PolywrapClientNative.xcframework/*/Headers/*.h
12 changes: 9 additions & 3 deletions Frameworks/PolywrapClientNative.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
<key>AvailableLibraries</key>
<array>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>PolywrapClientNative.framework/PolywrapClientNative.a</string>
<string>PolywrapClientNative.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -17,10 +19,12 @@
<string>ios</string>
</dict>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>ios-simulator</string>
<key>LibraryPath</key>
<string>PolywrapClientNative.framework/PolywrapClientNative.a</string>
<string>PolywrapClientNative.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -32,10 +36,12 @@
<string>simulator</string>
</dict>
<dict>
<key>HeadersPath</key>
<string>Headers</string>
<key>LibraryIdentifier</key>
<string>macos</string>
<key>LibraryPath</key>
<string>PolywrapClientNative.framework/PolywrapClientNative.a</string>
<string>PolywrapClientNative.a</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PolywrapClientNative {
header "polywrap_nativeFFI.h"
export *
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PolywrapClientNative {
header "polywrap_nativeFFI.h"
export *
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module PolywrapClientNative {
header "polywrap_nativeFFI.h"
export *
}

This file was deleted.

This file was deleted.

16 changes: 7 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let package = Package(
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "PolywrapClient",
targets: ["PolywrapClient", "PolywrapClientNative"]),
targets: ["PolywrapClient"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -22,22 +22,20 @@ let package = Package(
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "PolywrapClient",
dependencies: ["MessagePacker", "PolywrapClientNative", "AsyncObjects"],
publicHeadersPath: "include",
cSettings: [ .headerSearchPath("include") ]
dependencies: ["MessagePacker", "PolywrapClientNative", "AsyncObjects"]
),
.binaryTarget(
name: "PolywrapClientNative",
url: "https://github.com/polywrap/swift-client/releases/download/v0.0.2/PolywrapClientNative.xcframework.zip",
checksum: "e6496955aab8fe74ffa5897449d6fc9d7c272bc84f716c4f1cd33bf9ddf4463e"
path: "Frameworks/PolywrapClientNative.xcframework"
// url: "https://github.com/polywrap/swift-client/releases/download/v0.0.2/PolywrapClientNative.xcframework.zip",
// checksum: "e6496955aab8fe74ffa5897449d6fc9d7c272bc84f716c4f1cd33bf9ddf4463e"
),
.testTarget(
name: "PolywrapClientTests",
dependencies: [
"PolywrapClient",
"PolywrapClient"
],
resources: [ .copy("Cases") ],
cSettings: [ .headerSearchPath("../../Sources/PolywrapClient/include")]
resources: [ .copy("Cases") ]
)
]
)
34 changes: 14 additions & 20 deletions Scripts/build_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e # Helps to give error info
LOCAL_UDL="src/polywrap_native.udl"
UDL_NAME="polywrap_native"
FRAMEWORK_NAME="PolywrapClientNative"
SWIFT_INTERFACE="PolywrapClientLib"
SWIFT_INTERFACE="PolywrapClientNativeLib"

BUILD_PATH="${IOS_PROJ}/Frameworks/PolywrapClientNative.xcframework"

Expand All @@ -16,19 +16,18 @@ cargo build --target x86_64-apple-ios
cargo build --target x86_64-apple-darwin # For macOS w/Intel
cargo build --target aarch64-apple-darwin # For macOS w/M1

IOS_ARM64_FRAMEWORK="$BUILD_PATH/ios-arm64/$FRAMEWORK_NAME.framework"
IOS_SIM_FRAMEWORK="$BUILD_PATH/ios-simulator/$FRAMEWORK_NAME.framework"
MACOS_FRAMEWORK="$BUILD_PATH/macos/$FRAMEWORK_NAME.framework"
IOS_ARM64_FRAMEWORK="$BUILD_PATH/ios-arm64"
IOS_SIM_FRAMEWORK="$BUILD_PATH/ios-simulator"
MACOS_FRAMEWORK="$BUILD_PATH/macos"

# Remove old files if they exist
rm -rf "$IOS_ARM64_FRAMEWORK/Headers"
rm -rf "$IOS_ARM64_FRAMEWORK/Headers/${UDL_NAME}FFI.h"
rm -rf "$IOS_ARM64_FRAMEWORK/$FRAMEWORK_NAME.a"
rm -rf "$IOS_SIM_FRAMEWORK/Headers"
rm -rf "$IOS_SIM_FRAMEWORK/Headers/${UDL_NAME}FFI.h"
rm -rf "$IOS_SIM_FRAMEWORK/$FRAMEWORK_NAME.a"
rm -rf "$MACOS_FRAMEWORK/Headers"
rm -rf "$MACOS_FRAMEWORK/Headers/${UDL_NAME}FFI.h"
rm -rf "$MACOS_FRAMEWORK/$FRAMEWORK_NAME.a"

rm -rf "$IOS_PROJ/Sources/PolywrapClient/include/${UDL_NAME}FFI.h"
rm "$IOS_PROJ/Sources/PolywrapClient/$SWIFT_INTERFACE.swift"

rm -rf ../../target/universal.a
rm -rf include/ios/*
Expand All @@ -37,7 +36,7 @@ rm -rf include/ios/*
mkdir -p include/ios

# UniFfi bindgen
cargo run --bin uniffi-bindgen generate "$LOCAL_UDL" --language swift --out-dir $IOS_PROJ/Sources/PolywrapClient/include/.cache
cargo run --bin uniffi-bindgen generate "$LOCAL_UDL" --language swift --out-dir $IOS_PROJ/Sources/PolywrapClient/.cache

# Make fat lib for sims
lipo -create \
Expand All @@ -52,20 +51,15 @@ lipo -create \
-output ../../target/universal_mac.a

# Move headers
mkdir "$IOS_ARM64_FRAMEWORK/Headers"
cp "$IOS_PROJ/Sources/PolywrapClient/include/.cache/${UDL_NAME}FFI.h" \
cp "$IOS_PROJ/Sources/PolywrapClient/.cache/${UDL_NAME}FFI.h" \
"$IOS_ARM64_FRAMEWORK/Headers/${UDL_NAME}FFI.h"

mkdir "$IOS_SIM_FRAMEWORK/Headers"
cp "$IOS_PROJ/Sources/PolywrapClient/include/.cache/${UDL_NAME}FFI.h" \
cp "$IOS_PROJ/Sources/PolywrapClient/.cache/${UDL_NAME}FFI.h" \
"$IOS_SIM_FRAMEWORK/Headers/${UDL_NAME}FFI.h"

mkdir "$MACOS_FRAMEWORK/Headers"
cp "$IOS_PROJ/Sources/PolywrapClient/include/.cache/${UDL_NAME}FFI.h" \
cp "$IOS_PROJ/Sources/PolywrapClient/.cache/${UDL_NAME}FFI.h" \
"$MACOS_FRAMEWORK/Headers/${UDL_NAME}FFI.h"

cp "$IOS_PROJ/Sources/PolywrapClient/include/.cache/${UDL_NAME}FFI.h" "$IOS_PROJ/Sources/PolywrapClient/include/${UDL_NAME}FFI.h"

# Move binaries
cp "../../target/aarch64-apple-ios/debug/lib${UDL_NAME}.a" \
"$IOS_ARM64_FRAMEWORK/$FRAMEWORK_NAME.a"
Expand All @@ -75,7 +69,7 @@ cp "../../target/universal_mac.a" \
"$MACOS_FRAMEWORK/$FRAMEWORK_NAME.a"

# Move swift interface
sed "s/${UDL_NAME}FFI/$FRAMEWORK_NAME/g" "$IOS_PROJ/Sources/PolywrapClient/include/.cache/$UDL_NAME.swift" > "$IOS_PROJ/Sources/PolywrapClient/include/$SWIFT_INTERFACE.swift"
sed "s/${UDL_NAME}FFI/$FRAMEWORK_NAME/g" "$IOS_PROJ/Sources/PolywrapClient/.cache/$UDL_NAME.swift" > "$IOS_PROJ/Sources/PolywrapClient/$SWIFT_INTERFACE.swift"

# Update include folder and remove unneeded files
rm -rf $IOS_PROJ/Sources/PolywrapClient/include/.cache
rm -rf $IOS_PROJ/Sources/PolywrapClient/.cache
4 changes: 0 additions & 4 deletions Sources/PolywrapClient/include/module.modulemap

This file was deleted.

Loading

0 comments on commit 482c6ae

Please sign in to comment.