Skip to content

Commit

Permalink
Add 'Move to Apps' window at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingajda committed Apr 4, 2020
1 parent 0b53cd7 commit 9c394eb
Show file tree
Hide file tree
Showing 7 changed files with 669 additions and 8 deletions.
42 changes: 42 additions & 0 deletions Covid-19 Status.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
D30A829024345C9F0023B9C3 /* RegionsMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30A828F24345C9F0023B9C3 /* RegionsMenu.swift */; };
D30B91F02433373E00E21774 /* showError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D30B91EF2433373E00E21774 /* showError.swift */; };
D317DE6324356D3900BD100A /* distribution in Resources */ = {isa = PBXBuildFile; fileRef = D317DE6224356D3900BD100A /* distribution */; };
D317DE672436A5D000BD100A /* PFMoveApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = D317DE662436A5D000BD100A /* PFMoveApplication.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
D317DE6A2436A8A300BD100A /* MoveApplication.strings in Resources */ = {isa = PBXBuildFile; fileRef = D317DE692436A8A300BD100A /* MoveApplication.strings */; };
D3C1A3552427BF8900B69DCB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3C1A3542427BF8900B69DCB /* AppDelegate.swift */; };
D3C1A3592427BF8B00B69DCB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D3C1A3582427BF8B00B69DCB /* Assets.xcassets */; };
D3C1A35C2427BF8B00B69DCB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D3C1A35A2427BF8B00B69DCB /* Main.storyboard */; };
Expand All @@ -27,6 +29,10 @@
D30A828F24345C9F0023B9C3 /* RegionsMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionsMenu.swift; sourceTree = "<group>"; };
D30B91EF2433373E00E21774 /* showError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = showError.swift; sourceTree = "<group>"; };
D317DE6224356D3900BD100A /* distribution */ = {isa = PBXFileReference; lastKnownFileType = folder; path = distribution; sourceTree = "<group>"; };
D317DE652436A5CF00BD100A /* BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BridgingHeader.h; sourceTree = "<group>"; };
D317DE662436A5D000BD100A /* PFMoveApplication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PFMoveApplication.m; sourceTree = "<group>"; };
D317DE682436A64200BD100A /* PFMoveApplication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PFMoveApplication.h; sourceTree = "<group>"; };
D317DE692436A8A300BD100A /* MoveApplication.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = MoveApplication.strings; sourceTree = "<group>"; };
D3C1A3512427BF8900B69DCB /* Covid-19 Status.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Covid-19 Status.app"; sourceTree = BUILT_PRODUCTS_DIR; };
D3C1A3542427BF8900B69DCB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
D3C1A3582427BF8B00B69DCB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -57,6 +63,33 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
D317DE642436A59F00BD100A /* LetsMove */ = {
isa = PBXGroup;
children = (
D317DE6C2436AFB100BD100A /* pl.lproj */,
D317DE662436A5D000BD100A /* PFMoveApplication.m */,
D317DE682436A64200BD100A /* PFMoveApplication.h */,
);
path = LetsMove;
sourceTree = "<group>";
};
D317DE6B2436A97100BD100A /* vendors */ = {
isa = PBXGroup;
children = (
D317DE652436A5CF00BD100A /* BridgingHeader.h */,
D317DE642436A59F00BD100A /* LetsMove */,
);
path = vendors;
sourceTree = "<group>";
};
D317DE6C2436AFB100BD100A /* pl.lproj */ = {
isa = PBXGroup;
children = (
D317DE692436A8A300BD100A /* MoveApplication.strings */,
);
path = pl.lproj;
sourceTree = "<group>";
};
D3C1A3482427BF8900B69DCB = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -93,6 +126,7 @@
D3C1A36C2429934700B69DCB /* src */ = {
isa = PBXGroup;
children = (
D317DE6B2436A97100BD100A /* vendors */,
D30B91EF2433373E00E21774 /* showError.swift */,
D3C1A371242AE35700B69DCB /* AboutViewController.swift */,
D3C1A3542427BF8900B69DCB /* AppDelegate.swift */,
Expand Down Expand Up @@ -138,6 +172,7 @@
TargetAttributes = {
D3C1A3502427BF8900B69DCB = {
CreatedOnToolsVersion = 11.3.1;
LastSwiftMigration = 1130;
};
};
};
Expand Down Expand Up @@ -169,6 +204,7 @@
D3C1A3592427BF8B00B69DCB /* Assets.xcassets in Resources */,
D317DE6324356D3900BD100A /* distribution in Resources */,
D3C1A377242BD81700B69DCB /* Localizable.strings in Resources */,
D317DE6A2436A8A300BD100A /* MoveApplication.strings in Resources */,
D3C1A35C2427BF8B00B69DCB /* Main.storyboard in Resources */,
D3EB91C524303F0C00514AB3 /* LICENSE in Resources */,
);
Expand Down Expand Up @@ -203,6 +239,7 @@
files = (
D30A829024345C9F0023B9C3 /* RegionsMenu.swift in Sources */,
D3C1A36E2429942200B69DCB /* Notificator.swift in Sources */,
D317DE672436A5D000BD100A /* PFMoveApplication.m in Sources */,
D3C1A3692429908300B69DCB /* StatsFormatter.swift in Sources */,
D3C1A36B2429921800B69DCB /* fetchData.swift in Sources */,
D3C1A3672429904F00B69DCB /* Types.swift in Sources */,
Expand Down Expand Up @@ -355,6 +392,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Covid-19 Status/Covid_19_Status.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
Expand All @@ -369,6 +407,8 @@
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "pl.mgdevelop.covid-19-status";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Covid-19 Status/src/vendors/BridgingHeader.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
Expand All @@ -377,6 +417,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Covid-19 Status/Covid_19_Status.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
Expand All @@ -391,6 +432,7 @@
MARKETING_VERSION = 1.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "pl.mgdevelop.covid-19-status";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Covid-19 Status/src/vendors/BridgingHeader.h";
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down
9 changes: 1 addition & 8 deletions Covid-19 Status/Covid_19_Status.entitlements
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
<dict/>
</plist>
2 changes: 2 additions & 0 deletions Covid-19 Status/src/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ aNotification: Notification) {
PFMoveToApplicationsFolderIfNecessary()

let statusBar = NSStatusBar.system
statusBarItem = statusBar.statusItem(withLength: NSStatusItem.variableLength)

Expand Down
6 changes: 6 additions & 0 deletions Covid-19 Status/src/vendors/BridgingHeader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//


#import "./LetsMove/PFMoveApplication.h"
32 changes: 32 additions & 0 deletions Covid-19 Status/src/vendors/LetsMove/PFMoveApplication.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// PFMoveApplication.h, version 1.24
// LetsMove
//
// Created by Andy Kim at Potion Factory LLC on 9/17/09
//
// The contents of this file are dedicated to the public domain.

#ifdef __cplusplus
extern "C" {
#endif

#import <Foundation/Foundation.h>

/**
Moves the running application to ~/Applications or /Applications if the former does not exist.
After the move, it relaunches app from the new location.
DOES NOT work for sandboxed applications.
Call from \c NSApplication's delegate method \c -applicationWillFinishLaunching: method. */
void PFMoveToApplicationsFolderIfNecessary(void);

/**
Check whether an app move is currently in progress.
Returns YES if LetsMove is currently in-progress trying to move the app to the Applications folder, or NO otherwise.
This can be used to work around a crash with apps that terminate after last window is closed.
See https://github.com/potionfactory/LetsMove/issues/64 for details. */
BOOL PFMoveIsInProgress(void);

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit 9c394eb

Please sign in to comment.