Skip to content

Commit

Permalink
More experimentation
Browse files Browse the repository at this point in the history
- Click toolbar button
- It injects an iframe that that loads from S3 with a JS file from S3
- That JS posts a message to the parent window
- The injected script in the parent window sends a message to the
  background Swift code
- The background code makes an HTTP request and sends the result back to
  the injected script
- The injected script logs the response to the console
  • Loading branch information
dstillman committed Aug 8, 2019
1 parent c876161 commit 2006e3a
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 29 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Gcc Patch
/*.gcno
199 changes: 194 additions & 5 deletions ExtensionApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,39 @@
B39AD239229FD14D00F97FA9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39AD238229FD14D00F97FA9 /* ViewController.swift */; };
B39AD23B229FD14E00F97FA9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B39AD23A229FD14E00F97FA9 /* Assets.xcassets */; };
B39AD23E229FD14E00F97FA9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B39AD23C229FD14E00F97FA9 /* Main.storyboard */; };
B39AD24D229FD1FB00F97FA9 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B39AD24C229FD1FB00F97FA9 /* Cocoa.framework */; };
B39AD250229FD1FB00F97FA9 /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39AD24F229FD1FB00F97FA9 /* SafariExtensionHandler.swift */; };
B39AD252229FD1FB00F97FA9 /* SafariExtensionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B39AD251229FD1FB00F97FA9 /* SafariExtensionViewController.swift */; };
B39AD255229FD1FB00F97FA9 /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B39AD253229FD1FB00F97FA9 /* SafariExtensionViewController.xib */; };
B39AD258229FD1FB00F97FA9 /* script.js in Resources */ = {isa = PBXBuildFile; fileRef = B39AD257229FD1FB00F97FA9 /* script.js */; };
B39AD25A229FD1FB00F97FA9 /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = B39AD259229FD1FB00F97FA9 /* ToolbarItemIcon.pdf */; };
B39AD25E229FD1FB00F97FA9 /* SafariExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = B39AD24A229FD1FA00F97FA9 /* SafariExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
B39AD25C229FD1FB00F97FA9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B39AD22B229FD14D00F97FA9 /* Project object */;
proxyType = 1;
remoteGlobalIDString = B39AD249229FD1FA00F97FA9;
remoteInfo = SafariExtension;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
B39AD262229FD1FB00F97FA9 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 13;
files = (
B39AD25E229FD1FB00F97FA9 /* SafariExtension.appex in Embed App Extensions */,
);
name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
B39AD233229FD14D00F97FA9 /* ExtensionApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExtensionApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
B39AD236229FD14D00F97FA9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -21,6 +52,15 @@
B39AD23D229FD14E00F97FA9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
B39AD23F229FD14E00F97FA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B39AD240229FD14E00F97FA9 /* ExtensionApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ExtensionApp.entitlements; sourceTree = "<group>"; };
B39AD24A229FD1FA00F97FA9 /* SafariExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SafariExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
B39AD24C229FD1FB00F97FA9 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
B39AD24F229FD1FB00F97FA9 /* SafariExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionHandler.swift; sourceTree = "<group>"; };
B39AD251229FD1FB00F97FA9 /* SafariExtensionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionViewController.swift; sourceTree = "<group>"; };
B39AD254229FD1FB00F97FA9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SafariExtensionViewController.xib; sourceTree = "<group>"; };
B39AD256229FD1FB00F97FA9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B39AD257229FD1FB00F97FA9 /* script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = script.js; sourceTree = "<group>"; };
B39AD259229FD1FB00F97FA9 /* ToolbarItemIcon.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = ToolbarItemIcon.pdf; sourceTree = "<group>"; };
B39AD25B229FD1FB00F97FA9 /* SafariExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SafariExtension.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -31,13 +71,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
B39AD247229FD1FA00F97FA9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B39AD24D229FD1FB00F97FA9 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
B39AD22A229FD14D00F97FA9 = {
isa = PBXGroup;
children = (
B39AD235229FD14D00F97FA9 /* ExtensionApp */,
B39AD24E229FD1FB00F97FA9 /* SafariExtension */,
B39AD24B229FD1FB00F97FA9 /* Frameworks */,
B39AD234229FD14D00F97FA9 /* Products */,
);
sourceTree = "<group>";
Expand All @@ -46,6 +96,7 @@
isa = PBXGroup;
children = (
B39AD233229FD14D00F97FA9 /* ExtensionApp.app */,
B39AD24A229FD1FA00F97FA9 /* SafariExtension.appex */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -63,6 +114,28 @@
path = ExtensionApp;
sourceTree = "<group>";
};
B39AD24B229FD1FB00F97FA9 /* Frameworks */ = {
isa = PBXGroup;
children = (
B39AD24C229FD1FB00F97FA9 /* Cocoa.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
B39AD24E229FD1FB00F97FA9 /* SafariExtension */ = {
isa = PBXGroup;
children = (
B39AD24F229FD1FB00F97FA9 /* SafariExtensionHandler.swift */,
B39AD251229FD1FB00F97FA9 /* SafariExtensionViewController.swift */,
B39AD253229FD1FB00F97FA9 /* SafariExtensionViewController.xib */,
B39AD256229FD1FB00F97FA9 /* Info.plist */,
B39AD257229FD1FB00F97FA9 /* script.js */,
B39AD259229FD1FB00F97FA9 /* ToolbarItemIcon.pdf */,
B39AD25B229FD1FB00F97FA9 /* SafariExtension.entitlements */,
);
path = SafariExtension;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -73,16 +146,35 @@
B39AD22F229FD14D00F97FA9 /* Sources */,
B39AD230229FD14D00F97FA9 /* Frameworks */,
B39AD231229FD14D00F97FA9 /* Resources */,
B39AD262229FD1FB00F97FA9 /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
B39AD25D229FD1FB00F97FA9 /* PBXTargetDependency */,
);
name = ExtensionApp;
productName = ExtensionApp;
productReference = B39AD233229FD14D00F97FA9 /* ExtensionApp.app */;
productType = "com.apple.product-type.application";
};
B39AD249229FD1FA00F97FA9 /* SafariExtension */ = {
isa = PBXNativeTarget;
buildConfigurationList = B39AD25F229FD1FB00F97FA9 /* Build configuration list for PBXNativeTarget "SafariExtension" */;
buildPhases = (
B39AD246229FD1FA00F97FA9 /* Sources */,
B39AD247229FD1FA00F97FA9 /* Frameworks */,
B39AD248229FD1FA00F97FA9 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SafariExtension;
productName = SafariExtension;
productReference = B39AD24A229FD1FA00F97FA9 /* SafariExtension.appex */;
productType = "com.apple.product-type.app-extension";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -91,11 +183,19 @@
attributes = {
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Michal Rentka";
ORGANIZATIONNAME = "Corporation for Digital Scholarship";
TargetAttributes = {
B39AD232229FD14D00F97FA9 = {
CreatedOnToolsVersion = 10.2.1;
};
B39AD249229FD1FA00F97FA9 = {
CreatedOnToolsVersion = 10.2.1;
SystemCapabilities = {
com.apple.Sandbox = {
enabled = 1;
};
};
};
};
};
buildConfigurationList = B39AD22E229FD14D00F97FA9 /* Build configuration list for PBXProject "ExtensionApp" */;
Expand All @@ -112,6 +212,7 @@
projectRoot = "";
targets = (
B39AD232229FD14D00F97FA9 /* ExtensionApp */,
B39AD249229FD1FA00F97FA9 /* SafariExtension */,
);
};
/* End PBXProject section */
Expand All @@ -126,6 +227,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
B39AD248229FD1FA00F97FA9 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B39AD25A229FD1FB00F97FA9 /* ToolbarItemIcon.pdf in Resources */,
B39AD255229FD1FB00F97FA9 /* SafariExtensionViewController.xib in Resources */,
B39AD258229FD1FB00F97FA9 /* script.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand All @@ -138,8 +249,25 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
B39AD246229FD1FA00F97FA9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B39AD252229FD1FB00F97FA9 /* SafariExtensionViewController.swift in Sources */,
B39AD250229FD1FB00F97FA9 /* SafariExtensionHandler.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
B39AD25D229FD1FB00F97FA9 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = B39AD249229FD1FA00F97FA9 /* SafariExtension */;
targetProxy = B39AD25C229FD1FB00F97FA9 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
B39AD23C229FD14E00F97FA9 /* Main.storyboard */ = {
isa = PBXVariantGroup;
Expand All @@ -149,6 +277,14 @@
name = Main.storyboard;
sourceTree = "<group>";
};
B39AD253229FD1FB00F97FA9 /* SafariExtensionViewController.xib */ = {
isa = PBXVariantGroup;
children = (
B39AD254229FD1FB00F97FA9 /* Base */,
);
name = SafariExtensionViewController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -270,37 +406,81 @@
B39AD244229FD14E00F97FA9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ExtensionApp/ExtensionApp.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 8AQ7YSWBDJ;
DEVELOPMENT_TEAM = 2NXF962MMK;
INFOPLIST_FILE = ExtensionApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.michalrentka.ExtensionApp;
PRODUCT_BUNDLE_IDENTIFIER = org.zotero.SafariExtensionApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
B39AD245229FD14E00F97FA9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = ExtensionApp/ExtensionApp.entitlements;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 8AQ7YSWBDJ;
DEVELOPMENT_TEAM = 2NXF962MMK;
INFOPLIST_FILE = ExtensionApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.michalrentka.ExtensionApp;
PRODUCT_BUNDLE_IDENTIFIER = org.zotero.SafariExtensionApp;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
};
name = Release;
};
B39AD260229FD1FB00F97FA9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SafariExtension/SafariExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2NXF962MMK;
INFOPLIST_FILE = SafariExtension/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = org.zotero.SafariExtensionApp.SafariExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
B39AD261229FD1FB00F97FA9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_ENTITLEMENTS = SafariExtension/SafariExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2NXF962MMK;
INFOPLIST_FILE = SafariExtension/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = org.zotero.SafariExtensionApp.SafariExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
Expand All @@ -326,6 +506,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
B39AD25F229FD1FB00F97FA9 /* Build configuration list for PBXNativeTarget "SafariExtension" */ = {
isa = XCConfigurationList;
buildConfigurations = (
B39AD260229FD1FB00F97FA9 /* Debug */,
B39AD261229FD1FB00F97FA9 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = B39AD22B229FD14D00F97FA9 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>SafariExtension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>
3 changes: 1 addition & 2 deletions ExtensionApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// AppDelegate.swift
// ExtensionApp
//
// Created by Michal Rentka on 30/05/2019.
// Copyright © 2019 Michal Rentka. All rights reserved.
// Copyright © 2019 Corporation for Digital Scholarship
//

import Cocoa
Expand Down
2 changes: 1 addition & 1 deletion ExtensionApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Michal Rentka. All rights reserved.</string>
<string>Copyright © 2019 Corporation for Digital Scholarship</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
Expand Down
Loading

0 comments on commit 2006e3a

Please sign in to comment.