Skip to content

Commit

Permalink
Completely automate the build process.
Browse files Browse the repository at this point in the history
Detect CLI installs and omit the launch of the utility in these circumstances
Launch the utility using the bundle-id
  • Loading branch information
rodyager committed Jan 16, 2023
1 parent e96242f commit 5a819c0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 26 deletions.
29 changes: 19 additions & 10 deletions PDFWriter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "PDFWriter Utility/PDFWriter_Utility.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"PDFWriter Utility/Preview Content\"";
DEVELOPMENT_TEAM = H2LX99GBPZ;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = H2LX99GBPZ;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -345,7 +347,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = "au.rwts.PDFWriter-Utility";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -361,11 +363,13 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "PDFWriter Utility/PDFWriter_Utility.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"PDFWriter Utility/Preview Content\"";
DEVELOPMENT_TEAM = H2LX99GBPZ;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = H2LX99GBPZ;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -376,10 +380,11 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.0.3;
MARKETING_VERSION = 2.0.4;
PRODUCT_BUNDLE_IDENTIFIER = "au.rwts.PDFWriter-Utility";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
};
Expand All @@ -388,9 +393,11 @@
5506A7DB285FE2BC00C5BDF5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Mac Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = H2LX99GBPZ;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = H2LX99GBPZ;
ENABLE_HARDENED_RUNTIME = YES;
INSTALL_PATH = /;
MACOSX_DEPLOYMENT_TARGET = 11.0;
Expand All @@ -403,9 +410,11 @@
5506A7DC285FE2BC00C5BDF5 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = H2LX99GBPZ;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = H2LX99GBPZ;
ENABLE_HARDENED_RUNTIME = YES;
INSTALL_PATH = /;
MACOSX_DEPLOYMENT_TARGET = 11.0;
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

An OSX print to pdf-file printer driver

### [![](https://raw.githubusercontent.com/rodyager/RWTS-PDFwriter/master/build/PDFwriter.iconset/icon_256x256.png "Click to download installer pkg") Click to download the installer pkg](https://github.com/rodyager/RWTS-PDFwriter/releases/download/v2.0.3/RWTS-PDFwriter.pkg)
### [![](https://raw.githubusercontent.com/rodyager/RWTS-PDFwriter/master/build/PDFwriter.iconset/icon_256x256.png "Click to download installer pkg") Click to download the installer pkg](https://github.com/rodyager/RWTS-PDFwriter/releases/download/v2.0.4/RWTS-PDFwriter.pkg)

## About RWTS PDFwriter
**RWTS PDFwriter** is an OSX 11.0+ compatible print driver that enables you to “print” your documents directly to a pdf file. It has similar functionality to [CutePDF](http://www.cutepdf.com) on Windows.
Expand All @@ -30,16 +30,12 @@ If you want to uninstall **PDFwriter**, open the **PDFWriter Utility** (see abov
## Compiling from sources
In the event that you want to compile your own copy, you can clone this repository.

Use XCode to archive the **PDFWriter Utility** target. In XCode's organizer, choose to distribute the **PDFWriter Utility** with Developer ID, and export the Notarized app to the build folder.

Use XCode to archive the **pdfwriter** target. In XCode's organizer, choose to distribute **pdfwriter** as Built Products and copy the binary into the build folder.

If anyone can contribute additions to the buildcript to automate the previous two steps, it would be appreciated.

The signed and notarized product installer can then be compiled by executing the script
A signed and notarized product installer can be compiled by executing the script

` build/buildscript.sh -s "<Your DeveloperID>" -n "<Your Keychain Profile>" `

Omit the -n if you do not wish to notarize the components, and omit the -s if you do not want to sign the components.

You can create a "Keychain Profile" by generating an app-specific password at https://appleid.apple.com then executing

` xcrun altool --username "<Your AppleID>" --password "<Your app-specific password>" --list-providers `
Expand Down
33 changes: 29 additions & 4 deletions build/buildscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PDFWRITERDIR="pkgroot/Library/Printers/RWTS/PDFwriter"
UTILITIESDIR="pkgroot/Library/Printers/RWTS/Utilities"
PPDDIR="pkgroot/Library/Printers/PPDs/Contents/Resources"
UTILITYAPP="PDFWriter Utility.app"
UTILITYZIP="PDFWriter Utility.zip"
PPDFILE="RWTS PDFwriter"

while getopts "s:n:" opt; do
Expand All @@ -30,7 +31,31 @@ while getopts "s:n:" opt; do
esac
done



cd "$(dirname "$0")"

cd ../
echo "### building Utility and printer driver"
xcodebuild -alltargets archive

cd build

echo "### copying binaries from tempory build folder"
cp -r "Release/$UTILITYAPP" ./
cp -r "Release/pdfwriter" ./

if [ ! -z "$SIGNSTRING" ]; then echo "#### notarizing Utility";
ditto -c -k --keepParent "$UTILITYAPP" "$UTILITYZIP";
xcrun notarytool submit "$UTILITYZIP" --keychain-profile "$NOTARYSTRING" --wait;
xcrun stapler staple "$UTILITYAPP;"
rm "$UTILITYZIP";
fi

echo "### clean up build artefacts"

rm -r EagerLinkingTBDs PDFWriter.build Release XCBuildData

echo "#### making directory structure"
mkdir pkgroot resources scripts
mkdir -m 775 pkgroot/Library pkgroot/Library/Printers pkgroot/Library/Printers/RWTS
Expand Down Expand Up @@ -74,10 +99,10 @@ pkgutil --expand product.pkg expanded
cp -r README.rtfd expanded/Resources/
pkgutil --flatten expanded RWTS-PDFwriter.pkg

if [ $SIGNSTRING ]; then echo "#### signing product";
productsign --sign $SIGNSTRING RWTS-PDFwriter.pkg ../RWTS-PDFwriter.pkg > /dev/null;
if [ $NOTARYSTRING ]; then echo "#### notarizing product";
xcrun notarytool submit ../RWTS-PDFwriter.pkg --keychain-profile $NOTARYSTRING --wait;
if [ ! -z "$SIGNSTRING" ]; then echo "#### signing product";
productsign --sign "$SIGNSTRING" RWTS-PDFwriter.pkg ../RWTS-PDFwriter.pkg > /dev/null;
if [ ! -z "$NOTARYSTRING" ]; then echo "#### notarizing product";
xcrun notarytool submit ../RWTS-PDFwriter.pkg --keychain-profile "$NOTARYSTRING" --wait;
xcrun stapler staple ../RWTS-PDFwriter.pkg;
fi
else mv RWTS-PDFwriter.pkg ../RWTS-PDFwriter.pkg; fi
Expand Down
8 changes: 5 additions & 3 deletions build/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist
# install printer
lpadmin -p PDFwriter -E -v pdfwriter:/ -P /Library/Printers/PPDs/Contents/Resources/RWTS\ PDFwriter.gz -o printer-is-shared=false

# don't launch Utility if CLI install
[ "$COMMAND_LINE_INSTALL" == "1" ] && exit 0

# open the Utility with correct environment
uid=$(id -u "$USER")
if [ $uid -ne 0 ]; then
launchctl asuser $uid su "$USER" -c "/Library/Printers/RWTS/Utilities/PDFWriter\ Utility.app/Contents/MacOS/PDFWriter\ Utility"
fi
launchctl asuser $uid sudo -u "$USER" open -b au.rwts.PDFWriter-Utility

2 changes: 1 addition & 1 deletion pdfwriter/pdfwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@



#define VERSION "2.0.3"
#define VERSION "2.0.4"

#define CPERROR 1
#define CPSTATUS 2
Expand Down

0 comments on commit 5a819c0

Please sign in to comment.