Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cordova/apple): move tun2socks and other dependencies into local swift package #1536

Merged
merged 17 commits into from
Jan 9, 2023

Conversation

elenadoty
Copy link
Contributor

@elenadoty elenadoty commented Jan 5, 2023

This PR packages the Outline Tun2Socks binary into a Swift package target so that we can depend on the frameworks through SPM.

@elenadoty elenadoty requested review from a team as code owners January 5, 2023 00:43
@github-actions github-actions bot added the size/L label Jan 5, 2023
Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting!

src/cordova/plugin/apple/src/OutlineConnectivity.swift Outdated Show resolved Hide resolved
src/cordova/plugin/apple/src/OutlineSentryLogger.swift Outdated Show resolved Hide resolved
src/cordova/plugin/apple/vpn/PacketTunnelProvider.h Outdated Show resolved Hide resolved
src/cordova/plugin/apple/vpn/OutlineTunnelStore.swift Outdated Show resolved Hide resolved
@@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CocoaLumberjack/CocoaLumberjack",
"state" : {
"revision" : "80ada1f753b0d53d9b57c465936a7c4169375002",
"version" : "3.7.4"
"revision" : "0188d31089b5881a269e01777be74c7316924346",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert this for now. No need to upgrade the dependencies. It's already an intrusive change.

5F7F90AE0E924FD7B065C415 /* CDVStatusBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 0394302BA6114B2AB648D4FF /* CDVStatusBar.m */; };
6AFF5BF91D6E424B00AB3073 /* CDVLaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6AFF5BF81D6E424B00AB3073 /* CDVLaunchScreen.storyboard */; };
7213383E07114591931284F8 /* OutlineConnectivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 119806AF98394D7D8749BB30 /* OutlineConnectivity.swift */; };
F693A5582965FE3800079DBD /* OutlineTun2Socks in Frameworks */ = {isa = PBXBuildFile; productRef = F693A5572965FE3800079DBD /* OutlineTun2Socks */; };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should happen to macos too.
It can be in another PR, but we should make sure it works, in case we need a different approach.

src/cordova/plugin/apple/src/OutlinePlugin.swift Outdated Show resolved Hide resolved
@github-actions github-actions bot added size/M and removed size/L labels Jan 5, 2023
@github-actions github-actions bot added size/XXL and removed size/M labels Jan 5, 2023
@github-actions github-actions bot added size/XS and removed size/XXL labels Jan 5, 2023
@github-actions github-actions bot added size/S and removed size/XS labels Jan 5, 2023
@elenadoty elenadoty requested a review from fortuna January 5, 2023 21:06
@elenadoty elenadoty changed the title [WIP] chore(apple): move tun2socks and other dependencies into local swift package chore(apple): move tun2socks and other dependencies into local swift package Jan 5, 2023
@elenadoty elenadoty changed the title chore(apple): move tun2socks and other dependencies into local swift package chore(cordova/apple): move tun2socks and other dependencies into local swift package Jan 5, 2023
Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems you are getting a build error. Strangely enough, it's only on iOS, not macOS.

@@ -0,0 +1,9 @@
.DS_Store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed even without the project?

@@ -0,0 +1,22 @@
// swift-tools-version: 5.7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I think you need to downgrade this to 5.6 to fix the build.

#include "VpnExtension-Swift.h"
@import Tun2socks;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this doesn't break macOS.

Should we update the macOS project in this PR as well? I'd expect the same project change. Might be easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - should I delete the third party Tun2socks directory then as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes it clear we are not using it anymore. It seems you already did it!

@github-actions github-actions bot added size/M and removed size/S labels Jan 6, 2023
#include "VpnExtension-Swift.h"
@import Tun2socks;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes it clear we are not using it anymore. It seems you already did it!

@elenadoty elenadoty merged commit ebfe9ec into master Jan 9, 2023
@elenadoty elenadoty deleted the elenadoty/tun2socks-framework branch January 9, 2023 17:03
sbruens added a commit that referenced this pull request Aug 17, 2023
* Replace the `copy-www-build-step` script with build phases.

* Add Mac Catalyst as a destination.

* Update README to load xcworkspace from `./src/cordova/apple/` instead of `./platforms/ios/`.

* Set separate bundle identifier for the Mac app built with Mac Catalyst.

* Add `Package.resolved` back. It was likely accidentally removed in #1536.

* Update local storage source directory for UIWebView->WKWebView migration for catalyst.

* Pin `cordova-ios` dep to fix for splashscreen aspect ratio.

* Rename `Images.xcassets` to `Assets.xcassets`.

* Add the status bar button images.

* Use `LSUIElement` to indicate this is a background app and shouldn't appear in the Dock.

* Add an AppKit bridge and use it to create a status bar menu in catalyst.

* Re-open the application window when use selects "Open" command from the status menu.

* Stop any VPN connections on app termination.

* Use `clang-format` to format Objective-C files.

* Use `SwiftFormat` to format Swift files.

* Set separate bundle identifier for the Mac Catalyst app built for release.

Previously set it on the `Debug` build, but need to also set it on `Release` build.

* Configure the app window to be a specific size.

* Enable the embedded app launcher as a login item.

* Use the macos app group in `PacketTunnelProvider` when on Catalyst.

* Add some logs to the `OutlineStatusItemController` for easier debugging.

* Do not try and add a `StatusItemController` automatically on AppKitBridge loads.

We'll need to re-use this bridge in the upcoming launcher, which should not add its own menu item to the status bar.

* Ignore locally loaded XCFramework bundles.

* Add launcher to Catalyst.

We set the launcher as a login item in Catalyst, and open the app if there Outline was connected at shutdown.

* Run `clang-format` over `.m` files.

* Ensure Sentry logs the right app group on Catalyst.

* Run macos code on Catalyst in a few more places.

* Do not run some code for `macOS` on `Catalyst`.

* Add prefix to log message for consistency.

* Use the `NETunnelProviderManager` to determine whether Outline was connected and the launcher should launch the application.

* Automatic project data changes made by Xcode.

* Set miminum macos deployment target to 10.15.

* Set bundle ID for launcher to `launcher3`.

* Move `AppDelegate` logic to category extension instead of overwriting the `AppDelegate` file auto-generated by Cordova.

* Move Catalyst specific `AppDelegate` code to Swift.

* Use `SwiftFormat` to format Swift files.

* Replace `NSLog` with `DDLog`.

* Use `SwiftFormat` to format Swift files.

* Fix notifications for macos bundle and undo formatting to make the diff smaller.

* Remove local `Tun2socks.xcframework` which got accidentally committed.

* Undo README changes as they have already been updated in a previous PR.

* Move catalyst code into `OutlineAppleLib`.

* Remove reference to `OutlineLauncher`'s plist.

* Fix some bad merges.

* Remove an unnecessary `#if` guard.

* Add a TODO to i18n the menu strings, which will happen in a fast-follow.

* Review changes.

* More changes for review.

* Mark static function as public.

* More changes.

* Use enum instead of boolean to represent connection status.

* Clean up some entitlement changes that aren't actually needed.

* Undo some entitlement changes that were needed to create outgoing connections on macos.

* Remove a single unneeded entitlement.

* Only compile `OutlineCatalystApp` on Catalyst.

* Fix ios build.

* Add some method docs and change  methods to standalone functions where no state is needed.

* Remove unneeded `Sources` sections.

* Revert "Remove unneeded `Sources` sections."

This reverts commit 863ac93.

* Remove unneeded build phases.

* Remove seemingly unneeded info list items.

* Add the "compile sources" build phase back to the `AppKitBridge` bundle.

* Fix macos build.

* Move `OutlineCatalystApp` target into `OutlineAppleLib` product.

* Rely on `NSNotification` extension from `OutlineAppleLib`.

* Remove `Tun2socks` and `OutlineTunnel` dependency from launcher and add "compile sources" buildphase back in.

* Select "Optimize interface for Mac" at the project level for Mac Catalyst.

* Move much of the OutlinePlugin into a Swift package, leaving only Cordova-specific code in the plugin, renamed as `CDVOutline`.

* Move status menu assets into Swift package.

* No need to explicitly state resources for the Assets catalog as Xcode treats these as resources automatically.

* Update the macos client to use the renamed `CDVOutline` plugin.

* Revert `OutlinePlugin` changes and instead use a `NSNotification` target.

* `OutlineNotifications` to `OutlineNotification`.

* Add some TODOs.

* Remove unnecessary parameter.
sbruens added a commit that referenced this pull request Aug 17, 2023
* Replace the `copy-www-build-step` script with build phases.

* Add Mac Catalyst as a destination.

* Update README to load xcworkspace from `./src/cordova/apple/` instead of `./platforms/ios/`.

* Set separate bundle identifier for the Mac app built with Mac Catalyst.

* Add `Package.resolved` back. It was likely accidentally removed in #1536.

* Update local storage source directory for UIWebView->WKWebView migration for catalyst.

* Pin `cordova-ios` dep to fix for splashscreen aspect ratio.

* Rename `Images.xcassets` to `Assets.xcassets`.

* Add the status bar button images.

* Use `LSUIElement` to indicate this is a background app and shouldn't appear in the Dock.

* Add an AppKit bridge and use it to create a status bar menu in catalyst.

* Re-open the application window when use selects "Open" command from the status menu.

* Stop any VPN connections on app termination.

* Use `clang-format` to format Objective-C files.

* Use `SwiftFormat` to format Swift files.

* Set separate bundle identifier for the Mac Catalyst app built for release.

Previously set it on the `Debug` build, but need to also set it on `Release` build.

* Configure the app window to be a specific size.

* Enable the embedded app launcher as a login item.

* Use the macos app group in `PacketTunnelProvider` when on Catalyst.

* Add some logs to the `OutlineStatusItemController` for easier debugging.

* Do not try and add a `StatusItemController` automatically on AppKitBridge loads.

We'll need to re-use this bridge in the upcoming launcher, which should not add its own menu item to the status bar.

* Ignore locally loaded XCFramework bundles.

* Add launcher to Catalyst.

We set the launcher as a login item in Catalyst, and open the app if there Outline was connected at shutdown.

* Run `clang-format` over `.m` files.

* Ensure Sentry logs the right app group on Catalyst.

* Run macos code on Catalyst in a few more places.

* Do not run some code for `macOS` on `Catalyst`.

* Add prefix to log message for consistency.

* Use the `NETunnelProviderManager` to determine whether Outline was connected and the launcher should launch the application.

* Automatic project data changes made by Xcode.

* Set miminum macos deployment target to 10.15.

* Set bundle ID for launcher to `launcher3`.

* Move `AppDelegate` logic to category extension instead of overwriting the `AppDelegate` file auto-generated by Cordova.

* Move Catalyst specific `AppDelegate` code to Swift.

* Use `SwiftFormat` to format Swift files.

* Replace `NSLog` with `DDLog`.

* Use `SwiftFormat` to format Swift files.

* Fix notifications for macos bundle and undo formatting to make the diff smaller.

* Remove local `Tun2socks.xcframework` which got accidentally committed.

* Undo README changes as they have already been updated in a previous PR.

* Move catalyst code into `OutlineAppleLib`.

* Remove reference to `OutlineLauncher`'s plist.

* Fix some bad merges.

* Remove an unnecessary `#if` guard.

* Add a TODO to i18n the menu strings, which will happen in a fast-follow.

* Review changes.

* More changes for review.

* Mark static function as public.

* More changes.

* Use enum instead of boolean to represent connection status.

* Clean up some entitlement changes that aren't actually needed.

* Undo some entitlement changes that were needed to create outgoing connections on macos.

* Remove a single unneeded entitlement.

* Only compile `OutlineCatalystApp` on Catalyst.

* Fix ios build.

* Add some method docs and change  methods to standalone functions where no state is needed.

* Remove unneeded `Sources` sections.

* Revert "Remove unneeded `Sources` sections."

This reverts commit 863ac93.

* Remove unneeded build phases.

* Remove seemingly unneeded info list items.

* Add the "compile sources" build phase back to the `AppKitBridge` bundle.

* Fix macos build.

* Move `OutlineCatalystApp` target into `OutlineAppleLib` product.

* Rely on `NSNotification` extension from `OutlineAppleLib`.

* Remove `Tun2socks` and `OutlineTunnel` dependency from launcher and add "compile sources" buildphase back in.

* Select "Optimize interface for Mac" at the project level for Mac Catalyst.

* Move much of the OutlinePlugin into a Swift package, leaving only Cordova-specific code in the plugin, renamed as `CDVOutline`.

* Move status menu assets into Swift package.

* No need to explicitly state resources for the Assets catalog as Xcode treats these as resources automatically.

* Update the macos client to use the renamed `CDVOutline` plugin.

* Revert `OutlinePlugin` changes and instead use a `NSNotification` target.

* `OutlineNotifications` to `OutlineNotification`.

* Add some TODOs.

* Remove unnecessary parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants