Skip to content

Commit

Permalink
redo download-payload script to create XCFramework
Browse files Browse the repository at this point in the history
  • Loading branch information
mbullington committed Mar 6, 2021
1 parent 0c6a4f6 commit 98a18c9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 14 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
skiasharp*
.build
DerivedData
xcuserdata
.DS_Store

skiasharp*
build
SkiaSharpMacFramework/libSkiaSharp.dylib
SkiaSharpMacFramework/SkiaSharpMacFramework.framework*
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<true/>
</dict>
</plist>
38 changes: 38 additions & 0 deletions MacOSFramework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>19F101</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>libSkiaSharp</string>
<key>CFBundleIdentifier</key>
<string>xamarin.libskia-macos</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>libSkiaSharp</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTSDKBuild</key>
<string>10.15</string>
<key>DTSDKName</key>
<string>macosx10.15</string>
<key>DTXcode</key>
<string>1160</string>
<key>DTXcodeBuild</key>
<string>11E708</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
94 changes: 81 additions & 13 deletions download-payload.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,93 @@
#!/bin/sh
V=2.80.0-preview.3
#!/bin/bash

# Must be ran on macOS due to use of xcodebuild and lipo.

# Cleanup from last time.
rm -rf SkiaSharp.xcframework

V=2.80.3-preview.40
DIR=skiasharp-$V
FILE=skiasharp-$V.zip
URL=https://www.nuget.org/api/v2/package/SkiaSharp/$V
if test ! -e $FILE; then
curl -L -o skiasharp-$V.zip https://www.nuget.org/api/v2/package/SkiaSharp/$V
fi
unzip -d skiasharp-$V $FILE

download_nuget() {
if test ! -e $FILE; then
curl -L -o skiasharp-$V.zip https://www.nuget.org/api/v2/package/SkiaSharp/$V
fi
unzip -d skiasharp-$V $FILE
}
download_nuget

# used below in build methods
lipo_skiasharp() {
local folder_name="$1"
local arch="$2"
local path=$folder_name/libSkiaSharp.framework/libSkiaSharp

lipo -extract $arch $path -output $path
}

mkdir build

# iOS
monodis --output=dummy $DIR/lib/xamarinios1.0/SkiaSharp.dll
unzip -d SkiaKit/iOS/libSkiaSharp.framework libSkiaSharp.framework
rm libSkiaSharp.framework
build_ios() {
mkdir build/iOS
cp -a $DIR/build/xamarinios1.0/libSkiaSharp.framework build/iOS/libSkiaSharp.framework

# Painfully separate all architectures.
cp -a build/iOS build/iOS-x86_64
cp -a build/iOS build/iOS-arm64
rm -rf build/iOS

# Remove other architectures.
lipo_skiasharp build/iOS-x86_64 x86_64
lipo_skiasharp build/iOS-arm64 arm64
}
build_ios

# tvOS
monodis --output=dummy $DIR/lib/xamarintvos1.0/SkiaSharp.dll
unzip -d SkiaKit/tvOS/libSkiaSharp.framework libSkiaSharp.framework
rm libSkiaSharp.framework
build_tvos() {
mkdir build/tvOS
cp -a $DIR/build/xamarintvos1.0/libSkiaSharp.framework build/tvOS/libSkiaSharp.framework

# Painfully separate all architectures.
cp -a build/tvOS build/tvOS-x86_64
cp -a build/tvOS build/tvOS-arm64
rm -rf build/tvOS

# Remove other architectures.
lipo_skiasharp build/tvOS-x86_64 x86_64
lipo_skiasharp build/tvOS-arm64 arm64
}
build_tvos

# macOS
cp $DIR/runtimes/osx/native/libSkiaSharp.dylib SkiaKit/macOS
build_macos() {
mkdir -p build/macOS-x86_64/libSkiaSharp.framework

cp $DIR/runtimes/osx/native/libSkiaSharp.dylib .
# https://stackoverflow.com/questions/57755276/create-ios-framework-with-dylib
lipo libSkiaSharp.dylib -output libSkiaSharp -create
install_name_tool -id @rpath/libSkiaSharp.framework/libSkiaSharp libSkiaSharp

mv libSkiaSharp build/macOS-x86_64/libSkiaSharp.framework/
rm libSkiaSharp.dylib

cp MacOSFramework/Info.plist build/macOS-x86_64/libSkiaSharp.framework/Info.plist
}
build_macos

create_xcframework() {
# Create XCFramework.
xcodebuild -create-xcframework \
-framework build/iOS-x86_64/libSkiaSharp.framework \
-framework build/iOS-arm64/libSkiaSharp.framework \
-framework build/tvOS-x86_64/libSkiaSharp.framework \
-framework build/tvOS-arm64/libSkiaSharp.framework \
-framework build/macOS-x86_64/libSkiaSharp.framework \
-output SkiaSharp.xcframework
}
create_xcframework

# Cleanup
rm -rf skiasharp-* build

0 comments on commit 98a18c9

Please sign in to comment.