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

feat: migrate from cocoapods-keys to ArkanaKeys #484

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .arkana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package_manager: cocoapods
result_path: 'Pods'
environments:
- Debug
- Release
environment_secrets:
- NotificationEndpoint
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NotificationEndpointRelease=
NotificationEndpointDebug=
5 changes: 2 additions & 3 deletions .github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ gem install bundler:2.3.11
# Install Ruby Gems
bundle install

# stub keys. DO NOT use in production
bundle exec pod keys set notification_endpoint "<endpoint>"
bundle exec pod keys set notification_endpoint_debug "<endpoint>"
# Install the sample .env file, which should have blank keys
cp .env.sample .env

bundle exec pod install
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ xcuserdata

# Localization/StringsConvertor/input
Localization/StringsConvertor/output
.DS_Store
.DS_Store

### Arkana Keys ###
# Ignore the .env file as it contains user-specific settings
.env
8 changes: 3 additions & 5 deletions AppShared/AppSecret.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import CryptoKit
import KeychainAccess
import Keys
import ArkanaKeys
import MastodonCommon

public final class AppSecret {
Expand All @@ -36,12 +36,10 @@ public final class AppSecret {
}()

init() {
let keys = MastodonKeys()

#if DEBUG
self.notificationEndpoint = keys.notification_endpoint_debug
self.notificationEndpoint = ArkanaKeys.Debug().notificationEndpoint
#else
self.notificationEndpoint = keys.notification_endpoint
self.notificationEndpoint = ArkanaKeys.Release().notificationEndpoint
#endif
}

Expand Down
39 changes: 23 additions & 16 deletions Documentation/Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
- Xcode 13+
- Swift 5.5+
- iOS 14.0+
- [Homebrew package manager](https://brew.sh)


Intell the latest version of Xcode from the App Store or Apple Developer Download website. Also, we assert you have the [Homebrew](https://brew.sh) package manager.
Install the latest version of Xcode from the App Store or Apple Developer Download website as well as [Homebrew](https://brew.sh) from its website.

This guide may not suit your machine and actually setup procedure may change in the future. Please file the issue or Pull Request if there are any problems.
This guide may change in the future. Please [create an issue](https://github.com/mastodon/mastodon-ios/issues/new/choose) or [open a pull request](https://github.com/mastodon/mastodon-ios/blob/main/Documentation/CONTRIBUTING.md) if there are any problems.

## CocoaPods
The app use [CocoaPods]() and [CocoaPods-Keys](https://github.com/orta/cocoapods-keys). Ruby Gems are managed through Bundler. The M1 Mac needs virtual ruby env to workaround compatibility issues.
The app uses [CocoaPods](https://cocoapods.org/) and [CocoaPods-Keys](https://github.com/orta/cocoapods-keys). Ruby Gems are managed through Bundler.

The M1 Mac needs a virtual ruby environment to work around compatibility issues.

#### Intel Mac

Expand All @@ -24,22 +27,25 @@ bundle install
#### M1 Mac

```zsh
# install the rbenv
# Install the rbenv package
brew install rbenv
which ruby
# > /usr/bin/ruby

# These instructions only work for ZSH (macOS default shell); adjust for your shell
echo 'eval "$(rbenv init -)"' >> ~/.zprofile
source ~/.zprofile
which ruby
# > /Users/mainasuk/.rbenv/shims/ruby

# select ruby
# Select a Ruby version to install
rbenv install --list
# here we use the latest 3.0.x version
rbenv install 3.0.3
rbenv global 3.0.3

# Here we select the latest version in the 3.0.x series
rbenv install 3.0.4
rbenv global 3.0.4
which ruby
# > /Users/mainasuk/.rbenv/shims/ruby
ruby --version
# > ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [arm64-darwin21]
# > ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [arm64-darwin22]

gem install bundler
bundle install
Expand All @@ -48,6 +54,9 @@ bundle install
## Bootstrap

```zsh
# copy .env.sample to .env (see Push Notifications below)
cp .env.sample .env

# make a clean build
bundle install
bundle exec pod clean
Expand All @@ -59,14 +68,12 @@ bundle exec pod install --repo-update
open Mastodon.xcworkspace
```

The CocoaPods-Key plugin will request the push notification endpoint. You can fufill the empty string and set it later. To setup the push notification. Please check section `Push Notification` below.

The app requires the `App Group` capability. To make sure it works for your developer membership. Please check [AppSecret.swift](../AppShared/AppSecret.swift) file and set another unique `groupID` and update `App Group` settings.

#### Push Notification (Optional)
The app is compatible with [toot-relay](https://github.com/DagAgren/toot-relay) APNs. You can set your push notification endpoint via Cocoapod-Keys. There are two endpoints:
- notification_endpoint: for `RELEASE` usage
- notification_endpoint_debug: for `DEBUG` usage
The app is compatible with [toot-relay](https://github.com/DagAgren/toot-relay) APNs. You can set your push notification endpoint via the `.env` file copied above. There are two endpoints which can be configured:
- NotificationEndpointRelease: for `RELEASE` usage
- NotificationEndpointDebug: for `DEBUG` usage

Please check the [Establishing a Certificate-Based Connection to APNs
](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns) document to generate the certificate and exports the p12 file.
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ source "https://rubygems.org"

gem "cocoapods"
gem "cocoapods-clean"
gem "cocoapods-keys"

gem "arkana"
16 changes: 7 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ GEM
specs:
CFPropertyList (3.0.5)
rexml
RubyInline (3.12.5)
ZenTest (~> 4.3)
ZenTest (4.12.1)
activesupport (6.1.5.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
Expand All @@ -17,6 +14,10 @@ GEM
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
arkana (1.2.0)
colorize (~> 0.8)
dotenv (~> 2.7)
yaml (~> 0.2)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.11.3)
Expand Down Expand Up @@ -50,9 +51,6 @@ GEM
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-keys (2.2.1)
dotenv
osx_keychain
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
Expand All @@ -61,6 +59,7 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
colorize (0.8.1)
concurrent-ruby (1.1.10)
dotenv (2.7.6)
escape (0.0.4)
Expand All @@ -79,8 +78,6 @@ GEM
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
osx_keychain (1.0.2)
RubyInline (~> 3)
public_suffix (4.0.7)
rexml (3.2.5)
ruby-macho (2.5.1)
Expand All @@ -95,15 +92,16 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
yaml (0.2.0)
zeitwerk (2.5.4)

PLATFORMS
ruby

DEPENDENCIES
arkana
cocoapods
cocoapods-clean
cocoapods-keys

BUNDLED WITH
2.3.11
13 changes: 6 additions & 7 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
platform :ios, '14.0'

`bundle exec arkana`

target 'Mastodon' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
Expand Down Expand Up @@ -31,17 +33,14 @@ target 'Mastodon' do
end

target 'AppShared' do
# secret management
pod "ArkanaKeys", path: "Pods/ArkanaKeys"
pod "ArkanaKeysInterfaces", path: "Pods/ArkanaKeysInterfaces"

# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
end

plugin 'cocoapods-keys', {
:project => "Mastodon",
:keys => [
"notification_endpoint",
"notification_endpoint_debug"
]
}

post_install do |installer|
installer.pods_project.targets.each do |target|
Expand Down
18 changes: 12 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PODS:
- ArkanaKeys (1.0.0):
- ArkanaKeysInterfaces (~> 1.0.0)
- ArkanaKeysInterfaces (1.0.0)
- DateToolsSwift (5.0.0)
- FLEX (4.4.1)
- Kanna (5.2.7)
- Keys (1.0.1)
- Sourcery (1.6.1):
- Sourcery/CLI-Only (= 1.6.1)
- Sourcery/CLI-Only (1.6.1)
Expand All @@ -11,10 +13,11 @@ PODS:
- XLPagerTabStrip (9.0.0)

DEPENDENCIES:
- ArkanaKeys (from `Pods/ArkanaKeys`)
- ArkanaKeysInterfaces (from `Pods/ArkanaKeysInterfaces`)
- DateToolsSwift (~> 5.0.0)
- FLEX (~> 4.4.0)
- Kanna (~> 5.2.2)
- Keys (from `Pods/CocoaPodsKeys`)
- Sourcery (~> 1.6.1)
- SwiftGen (~> 6.4.0)
- "UITextField+Shake (~> 1.2)"
Expand All @@ -31,19 +34,22 @@ SPEC REPOS:
- XLPagerTabStrip

EXTERNAL SOURCES:
Keys:
:path: Pods/CocoaPodsKeys
ArkanaKeys:
:path: Pods/ArkanaKeys
ArkanaKeysInterfaces:
:path: Pods/ArkanaKeysInterfaces

SPEC CHECKSUMS:
ArkanaKeys: 12db54228739f04493a460f81523d9aff660e288
ArkanaKeysInterfaces: 5e9e823069ea2515c320dfac0958e0bd3fe34aeb
DateToolsSwift: 4207ada6ad615d8dc076323d27037c94916dbfa6
FLEX: 7ca2c8cd3a435ff501ff6d2f2141e9bdc934eaab
Kanna: 01cfbddc127f5ff0963692f285fcbc8a9d62d234
Keys: a576f4c9c1c641ca913a959a9c62ed3f215a8de9
Sourcery: f3759f803bd0739f74fc92a4341eed0473ce61ac
SwiftGen: 67860cc7c3cfc2ed25b9b74cfd55495fc89f9108
"UITextField+Shake": 298ac5a0f239d731bdab999b19b628c956ca0ac3
XLPagerTabStrip: 61c57fd61f611ee5f01ff1495ad6fbee8bf496c5

PODFILE CHECKSUM: 1ac960a2c981ef98f7c24a3bba57bdabc1f66103
PODFILE CHECKSUM: 1e1c0511bf134a031299a0a1c51a4e14fd7895de

COCOAPODS: 1.11.3