Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90233b6a21 | ||
|
|
45b09a13d3 | ||
|
|
1632e5fbd4 | ||
|
|
18b63cbd19 | ||
|
|
4371f051aa | ||
|
|
2c09157448 | ||
|
|
8e26f0a066 | ||
|
|
db947b1827 | ||
|
|
e53cde7f60 | ||
|
|
62e36359b8 | ||
|
|
265d393cdc |
@@ -0,0 +1,5 @@
|
||||
ASC_KEY_ID=
|
||||
ASC_ISSUER_ID=
|
||||
ASC_KEY=
|
||||
MATCH_PASSWORD=
|
||||
MATCH_GIT_BASIC_AUTHORIZATION=
|
||||
@@ -0,0 +1,35 @@
|
||||
name: TestFlight
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "release/ios/v*"
|
||||
- "Attractor-*"
|
||||
|
||||
jobs:
|
||||
testflight:
|
||||
name: Build and upload
|
||||
runs-on: macos-arm64
|
||||
timeout-minutes: 90
|
||||
|
||||
steps:
|
||||
- name: Check out the release tag
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: "3.3.11"
|
||||
bundler-cache: true
|
||||
|
||||
- name: Build and upload to TestFlight
|
||||
env:
|
||||
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
|
||||
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
|
||||
ASC_KEY: ${{ secrets.ASC_KEY }}
|
||||
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
|
||||
MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
|
||||
CI: "true"
|
||||
FASTLANE_SKIP_UPDATE_CHECK: "1"
|
||||
FASTLANE_HIDE_CHANGELOG: "1"
|
||||
run: bundle exec fastlane ios beta
|
||||
@@ -0,0 +1,5 @@
|
||||
.env
|
||||
.bundle/
|
||||
build/
|
||||
fastlane/README.md
|
||||
fastlane/report.xml
|
||||
@@ -795,7 +795,7 @@ extension BrowserViewController: UITextFieldDelegate
|
||||
|
||||
currentTab.beginLoadingURL(url)
|
||||
} else {
|
||||
let searchURL = Settings.shared.searchProvider.provider().searchURLWithQuery(text)
|
||||
let searchURL = Settings.shared.currentSearchProvider().searchURLWithQuery(text)
|
||||
currentTab.beginLoadingURL(searchURL)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// AddSearchEngineViewController.swift
|
||||
// App
|
||||
//
|
||||
// Created by James Magahern on 9/29/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
@MainActor
|
||||
struct AddSearchEngineView: View
|
||||
{
|
||||
@State var model: ViewModel
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
HStack {
|
||||
Text("Name")
|
||||
TextField("Name", text: $model.name)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.autocorrectionDisabled()
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
HStack {
|
||||
Text("URL")
|
||||
TextField("https://example.com/query=%q", text: $model.url)
|
||||
.multilineTextAlignment(.trailing)
|
||||
.autocorrectionDisabled()
|
||||
.textContentType(.none)
|
||||
}
|
||||
} footer: {
|
||||
Text("URL must contain %q, which will be replaced by the query. ")
|
||||
}
|
||||
|
||||
Section {
|
||||
Toggle("Set as default", isOn: $model.makeDefault)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Add Search Engine")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Observable
|
||||
class ViewModel
|
||||
{
|
||||
var name: String = ""
|
||||
var url: String = ""
|
||||
var makeDefault: Bool = false
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
class AddSearchEngineViewController: UIHostingController<AddSearchEngineView>
|
||||
{
|
||||
public var viewModel: AddSearchEngineView.ViewModel
|
||||
|
||||
init() {
|
||||
self.viewModel = AddSearchEngineView.ViewModel()
|
||||
super.init(rootView: AddSearchEngineView(model: viewModel))
|
||||
}
|
||||
|
||||
@MainActor @preconcurrency required dynamic init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
@Previewable @State var model = AddSearchEngineView.ViewModel()
|
||||
AddSearchEngineView(model: model)
|
||||
}
|
||||
@@ -23,8 +23,8 @@ struct AmberSettingsView: View {
|
||||
@Environment(\.presentationMode)
|
||||
@Binding private var presentationMode
|
||||
|
||||
@State private var searchProvider = Settings.shared.searchProvider {
|
||||
didSet { Settings.shared.searchProvider = searchProvider }
|
||||
@State private var defaultSearchEngineName = Settings.shared.defaultSearchEngineName {
|
||||
didSet { Settings.shared.defaultSearchEngineName = defaultSearchEngineName }
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -35,12 +35,12 @@ struct AmberSettingsView: View {
|
||||
})
|
||||
|
||||
Section(header: Text("Search Provider"), content: {
|
||||
ForEach(Settings.SearchProviderSetting.allCases, id: \.self, content: { setting in
|
||||
Button(action: { searchProvider = setting }, label: {
|
||||
ForEach(Array(Settings.shared.searchEngines.keys).sorted(), id: \.self, content: { name in
|
||||
Button(action: { defaultSearchEngineName = name }, label: {
|
||||
HStack {
|
||||
Text(setting.rawValue)
|
||||
Text(name)
|
||||
Spacer()
|
||||
if searchProvider == setting {
|
||||
if defaultSearchEngineName == name {
|
||||
Image(systemName: "checkmark")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,55 +109,56 @@ class GeneralSettingsViewController: UIViewController
|
||||
case searchEngine = "Search Engine"
|
||||
case syncServer = "Sync Server"
|
||||
}
|
||||
|
||||
|
||||
typealias Item = String
|
||||
|
||||
|
||||
static let SearchProviderPopupItem = "searchProvider.popup"
|
||||
static let SyncServerItem = "syncServer.field"
|
||||
|
||||
|
||||
let dataSource: UICollectionViewDiffableDataSource<Section, Item>
|
||||
let collectionView: UICollectionView
|
||||
|
||||
let viewModel: ViewModel
|
||||
|
||||
static func createLayout(forIdiom idiom: UIUserInterfaceIdiom) -> UICollectionViewLayout {
|
||||
#if targetEnvironment(macCatalyst)
|
||||
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
|
||||
heightDimension: .fractionalHeight(1.0))
|
||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
|
||||
heightDimension: .fractionalHeight(1.0))
|
||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||
|
||||
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.60),
|
||||
heightDimension: .absolute(44))
|
||||
|
||||
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 1)
|
||||
group.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(1.0), top: nil, trailing: nil, bottom: nil)
|
||||
|
||||
let insets = NSDirectionalEdgeInsets(top: 24.0, leading: 64.0, bottom: 24.0, trailing: 64.0)
|
||||
|
||||
let headerFooterSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.40),
|
||||
heightDimension: .estimated(44.0))
|
||||
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(
|
||||
layoutSize: headerFooterSize,
|
||||
elementKind: UICollectionView.elementKindSectionHeader,
|
||||
alignment: .topLeading,
|
||||
absoluteOffset: CGPoint(x: insets.leading, y: insets.top + 5.0)
|
||||
)
|
||||
sectionHeader.extendsBoundary = false
|
||||
sectionHeader.contentInsets = insets
|
||||
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.60),
|
||||
heightDimension: .absolute(44))
|
||||
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
// section.interGroupSpacing = spacing
|
||||
section.contentInsets = insets
|
||||
section.supplementariesFollowContentInsets = true
|
||||
section.boundarySupplementaryItems = [ sectionHeader ]
|
||||
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize, subitem: item, count: 1)
|
||||
group.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(1.0), top: nil, trailing: nil, bottom: nil)
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout(section: section)
|
||||
return layout
|
||||
#else
|
||||
var listConfiguration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
|
||||
listConfiguration.headerMode = .supplementary
|
||||
return UICollectionViewCompositionalLayout.list(using: listConfiguration)
|
||||
#endif
|
||||
let insets = NSDirectionalEdgeInsets(top: 24.0, leading: 64.0, bottom: 24.0, trailing: 64.0)
|
||||
|
||||
let headerFooterSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.40),
|
||||
heightDimension: .estimated(44.0))
|
||||
let sectionHeader = NSCollectionLayoutBoundarySupplementaryItem(
|
||||
layoutSize: headerFooterSize,
|
||||
elementKind: UICollectionView.elementKindSectionHeader,
|
||||
alignment: .topLeading,
|
||||
absoluteOffset: CGPoint(x: insets.leading, y: insets.top + 5.0)
|
||||
)
|
||||
sectionHeader.extendsBoundary = false
|
||||
sectionHeader.contentInsets = insets
|
||||
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
// section.interGroupSpacing = spacing
|
||||
section.contentInsets = insets
|
||||
section.supplementariesFollowContentInsets = true
|
||||
section.boundarySupplementaryItems = [ sectionHeader ]
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout(section: section)
|
||||
return layout
|
||||
#else
|
||||
var listConfiguration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
|
||||
listConfiguration.headerMode = .supplementary
|
||||
return UICollectionViewCompositionalLayout.list(using: listConfiguration)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static func sectionHeaderConfiguration(forIdiom idiom: UIUserInterfaceIdiom, sectionName: String) -> UIContentConfiguration {
|
||||
if idiom == .mac {
|
||||
return LabelContentConfiguration(
|
||||
@@ -166,33 +167,41 @@ class GeneralSettingsViewController: UIViewController
|
||||
textAlignment: .right
|
||||
)
|
||||
} else {
|
||||
var config = UIListContentConfiguration.plainHeader()
|
||||
var config = UIListContentConfiguration.header()
|
||||
config.text = sectionName
|
||||
return config
|
||||
}
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
#if targetEnvironment(macCatalyst)
|
||||
static let staticIdiom = UIUserInterfaceIdiom.mac
|
||||
#else
|
||||
#else
|
||||
static let staticIdiom = UIUserInterfaceIdiom.pad
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
init() {
|
||||
let actionHandler = { (action: UIAction) in
|
||||
let providerString = action.title
|
||||
let provider = Settings.SearchProviderSetting(rawValue: providerString)!
|
||||
Settings.shared.searchProvider = provider
|
||||
let engineName = action.title
|
||||
Settings.shared.defaultSearchEngineName = engineName
|
||||
}
|
||||
|
||||
|
||||
let viewModel = ViewModel()
|
||||
let itemCellRegistry = UICollectionView.CellRegistration<UICollectionViewCell, Item> { cell, indexPath, identifier in
|
||||
if identifier == Self.SearchProviderPopupItem {
|
||||
let menu = UIMenu(children: Settings.SearchProviderSetting.allCases.map { provider in
|
||||
let action = UIAction(title: provider.rawValue, handler: actionHandler)
|
||||
action.state = Settings.shared.searchProvider == provider ? .on : .off
|
||||
let names = Settings.shared.searchEngines.keys.sorted()
|
||||
var engineMenuItems: [UIMenuElement] = names.map { name in
|
||||
let action = UIAction(title: name, handler: actionHandler)
|
||||
action.state = (Settings.shared.defaultSearchEngineName == name) ? .on : .off
|
||||
return action
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
engineMenuItems.append(UIMenu(options: .displayInline, children: [
|
||||
UIAction(title: "Manage Search Engines…", handler: { _ in
|
||||
viewModel.onManageSearchEngines()
|
||||
})
|
||||
]))
|
||||
|
||||
let menu = UIMenu(children: engineMenuItems)
|
||||
cell.contentConfiguration = ButtonContentConfiguration(menu: menu)
|
||||
} else if identifier == Self.SyncServerItem {
|
||||
cell.contentConfiguration = TextFieldContentConfiguration(
|
||||
@@ -206,58 +215,114 @@ class GeneralSettingsViewController: UIViewController
|
||||
returnKeyType: .done
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
cell.backgroundConfiguration = UIBackgroundConfiguration.listGroupedCell()
|
||||
cell.backgroundConfiguration = UIBackgroundConfiguration.listCell()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
let sectionHeaderRegistry = UICollectionView.SupplementaryRegistration<UICollectionViewCell>(elementKind: UICollectionView.elementKindSectionHeader, handler: {
|
||||
(cell, string, indexPath) in
|
||||
(cell, string, indexPath) in
|
||||
let sectionName = Section.allCases[indexPath.section].rawValue
|
||||
cell.contentConfiguration = Self.sectionHeaderConfiguration(forIdiom: Self.staticIdiom, sectionName: sectionName)
|
||||
})
|
||||
|
||||
|
||||
let layout = Self.createLayout(forIdiom: Self.staticIdiom)
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.backgroundColor = .systemGroupedBackground
|
||||
|
||||
|
||||
dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) {
|
||||
(collectionView, indexPath, identifier) in
|
||||
(collectionView, indexPath, identifier) in
|
||||
return collectionView.dequeueConfiguredReusableCell(using: itemCellRegistry, for: indexPath, item: identifier)
|
||||
}
|
||||
|
||||
|
||||
dataSource.supplementaryViewProvider = { collectionView, elementKind, indexPath in
|
||||
return collectionView.dequeueConfiguredReusableSupplementary(using: sectionHeaderRegistry, for: indexPath)
|
||||
}
|
||||
|
||||
|
||||
self.viewModel = viewModel
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
||||
|
||||
collectionView.delegate = self
|
||||
tabBarItem.title = "General"
|
||||
tabBarItem.image = UIImage(systemName: "gear")
|
||||
|
||||
let resetPopup = { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems([ Self.SearchProviderPopupItem ])
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
|
||||
viewModel.onManageSearchEngines = { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
// Reset menu item (to show currently selected search engine)
|
||||
resetPopup()
|
||||
|
||||
let viewController = ManageSearchEnginesViewController()
|
||||
viewController.title = "Manage Search Engines"
|
||||
|
||||
viewController.model.onAddSearchEngine = { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
let addSearchEngineViewController = AddSearchEngineViewController()
|
||||
let navController = UINavigationController(rootViewController: addSearchEngineViewController)
|
||||
|
||||
// Cancel
|
||||
addSearchEngineViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(systemItem: .cancel, primaryAction: UIAction { _ in
|
||||
navController.dismiss(animated: true)
|
||||
})
|
||||
|
||||
// Done
|
||||
addSearchEngineViewController.navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .done, primaryAction: UIAction { [weak self] _ in
|
||||
self?.saveCustomSearchEngine(model: addSearchEngineViewController.viewModel)
|
||||
navController.dismiss(animated: true)
|
||||
|
||||
resetPopup()
|
||||
viewController.model.reloadConfiguredEngines()
|
||||
})
|
||||
|
||||
self.present(navController, animated: true)
|
||||
}
|
||||
|
||||
viewController.model.onChangeEngines = {
|
||||
resetPopup()
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
let alertController = UIAlertController(title: "Not yet implemented for macOS.", message: nil, preferredStyle: .alert)
|
||||
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in alertController.dismiss(animated: true) }))
|
||||
present(alertController, animated: true)
|
||||
#else
|
||||
navigationController?.pushViewController(viewController, animated: true)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
|
||||
override func loadView() {
|
||||
self.view = collectionView
|
||||
}
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.appendSections(Section.allCases)
|
||||
// iOS
|
||||
// snapshot.appendItems(Settings.SearchProviderSetting.allCases.map { $0.rawValue }, toSection: .searchEngine)
|
||||
snapshot.appendItems([ Self.SearchProviderPopupItem ], toSection: .searchEngine)
|
||||
snapshot.appendItems([ Self.SyncServerItem ], toSection: .syncServer)
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
applySnapshot(animatingDifferences: false)
|
||||
}
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
@MainActor
|
||||
@Observable
|
||||
class ViewModel
|
||||
{
|
||||
var onManageSearchEngines: () -> Void = {}
|
||||
}
|
||||
}
|
||||
|
||||
extension GeneralSettingsViewController : UICollectionViewDelegate {
|
||||
@@ -265,3 +330,36 @@ extension GeneralSettingsViewController : UICollectionViewDelegate {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private extension GeneralSettingsViewController {
|
||||
func applySnapshot(animatingDifferences: Bool) {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections(Section.allCases)
|
||||
snapshot.appendItems([ Self.SearchProviderPopupItem ], toSection: .searchEngine)
|
||||
snapshot.appendItems([ Self.SyncServerItem ], toSection: .syncServer)
|
||||
dataSource.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
}
|
||||
|
||||
func saveCustomSearchEngine(model: AddSearchEngineView.ViewModel) {
|
||||
let name = model.name.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let url = model.url.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
guard !name.isEmpty, !url.isEmpty else { return }
|
||||
|
||||
// Require placeholder
|
||||
guard url.contains("%q") || url.contains("%s") else { return }
|
||||
|
||||
// Save
|
||||
var engines = Settings.shared.searchEngines
|
||||
engines[name] = url
|
||||
Settings.shared.searchEngines = engines
|
||||
|
||||
if model.makeDefault {
|
||||
Settings.shared.defaultSearchEngineName = name
|
||||
}
|
||||
|
||||
// Reset inputs and refresh UI
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reloadItems([ Self.SearchProviderPopupItem ])
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// ManageSearchEnginesViewController.swift
|
||||
// App
|
||||
//
|
||||
// Created by James Magahern on 9/29/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import UIKit
|
||||
|
||||
@MainActor
|
||||
struct ManageSearchEnginesView: View
|
||||
{
|
||||
@State var model: ViewModel
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
Section {
|
||||
List($model.configuredEngines, editActions: .delete) { row in
|
||||
HStack {
|
||||
Image(uiImage: .checkmark)
|
||||
.opacity(row.wrappedValue.isDefault ? 1.0 : 0.0)
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text(row.wrappedValue.name)
|
||||
.font(.body)
|
||||
.bold()
|
||||
|
||||
Text(row.wrappedValue.url)
|
||||
.font(.caption)
|
||||
}
|
||||
}
|
||||
.id(row.id)
|
||||
|
||||
.swipeActions(edge: .leading) {
|
||||
Button { model.makeDefault(row.id) } label: {
|
||||
Label("Make Default", systemImage: "checkmark")
|
||||
}
|
||||
.tint(.blue)
|
||||
}
|
||||
|
||||
.swipeActions(edge: .trailing) {
|
||||
Button(role: .destructive) { model.deleteEngine(row.id) } label: {
|
||||
Label("Delete", systemImage: "trash")
|
||||
}
|
||||
.disabled(model.configuredEngines.count <= 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section {
|
||||
Button("Add Search Engine…") {
|
||||
model.onAddSearchEngine()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Types
|
||||
|
||||
@MainActor
|
||||
@Observable
|
||||
class ViewModel
|
||||
{
|
||||
var configuredEngines: [ConfiguredEngine] = []
|
||||
var onAddSearchEngine: () -> Void = {}
|
||||
var onChangeEngines: () -> Void = {}
|
||||
|
||||
init() {
|
||||
reloadConfiguredEngines()
|
||||
}
|
||||
|
||||
func reloadConfiguredEngines() {
|
||||
let defaultEngine = Settings.shared.defaultSearchEngineName
|
||||
self.configuredEngines = Settings.shared.searchEngines.map { val in
|
||||
ConfiguredEngine(
|
||||
name: val.key,
|
||||
url: val.value,
|
||||
isDefault: val.key == defaultEngine
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func deleteEngine(_ id: ConfiguredEngine.ID) {
|
||||
let engine = configuredEngines.first { $0.url == id }!
|
||||
|
||||
var engines = Settings.shared.searchEngines
|
||||
engines.removeValue(forKey: engine.name)
|
||||
Settings.shared.searchEngines = engines
|
||||
|
||||
if engine.isDefault {
|
||||
// Pick another default
|
||||
if let firstEngine = engines.first {
|
||||
Settings.shared.defaultSearchEngineName = firstEngine.key
|
||||
}
|
||||
}
|
||||
|
||||
reloadConfiguredEngines()
|
||||
onChangeEngines()
|
||||
}
|
||||
|
||||
func makeDefault(_ id: ConfiguredEngine.ID) {
|
||||
let engineName = configuredEngines.first { $0.url == id }!.name
|
||||
Settings.shared.defaultSearchEngineName = engineName
|
||||
|
||||
reloadConfiguredEngines()
|
||||
onChangeEngines()
|
||||
}
|
||||
}
|
||||
|
||||
struct ConfiguredEngine: Identifiable
|
||||
{
|
||||
let name: String
|
||||
let url: String
|
||||
let isDefault: Bool
|
||||
|
||||
var id: String { url }
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
class ManageSearchEnginesViewController: UIHostingController<ManageSearchEnginesView>
|
||||
{
|
||||
let model: ManageSearchEnginesView.ViewModel
|
||||
|
||||
init() {
|
||||
self.model = ManageSearchEnginesView.ViewModel()
|
||||
super.init(rootView: ManageSearchEnginesView(model: model))
|
||||
}
|
||||
|
||||
required dynamic init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
@Previewable @State var model = ManageSearchEnginesView.ViewModel()
|
||||
ManageSearchEnginesView(model: model)
|
||||
}
|
||||
+19
-17
@@ -74,26 +74,28 @@ extension String: RawRepresentable {
|
||||
class Settings
|
||||
{
|
||||
static let shared = Settings()
|
||||
|
||||
public enum SearchProviderSetting: String, CaseIterable {
|
||||
case google = "Google"
|
||||
case duckduckgo = "DuckDuckGo"
|
||||
case searxnor = "Searx.nor"
|
||||
case whoogle = "Whoogle.nor"
|
||||
|
||||
func provider() -> SearchProvider {
|
||||
switch self {
|
||||
case .google: return SearchProvider.google
|
||||
case .duckduckgo: return SearchProvider.duckduckgo
|
||||
case .searxnor: return SearchProvider.searxnor
|
||||
case .whoogle: return SearchProvider.whoogle
|
||||
}
|
||||
|
||||
// Map of search engine name -> URL template containing %q or %s placeholder
|
||||
// Defaults preserve the previous built-in engines
|
||||
@SettingProperty(key: "searchEngines")
|
||||
public var searchEngines: [String: String] = [
|
||||
"Google": "https://google.com/search?q=%q&gbv=1",
|
||||
"DuckDuckGo": "https://html.duckduckgo.com/html/?q=%q",
|
||||
]
|
||||
|
||||
// Name of the default search engine from `searchEngines`
|
||||
@SettingProperty(key: "defaultSearchEngine")
|
||||
public var defaultSearchEngineName: String = "Searx.nor"
|
||||
|
||||
// Convenience to build a SearchProvider from current default
|
||||
func currentSearchProvider() -> SearchProvider {
|
||||
if let template = searchEngines[defaultSearchEngineName] {
|
||||
return SearchProvider.fromTemplate(template)
|
||||
}
|
||||
// Fallback to Google if something goes wrong
|
||||
return SearchProvider.fromTemplate("https://google.com/search?q=%q&gbv=1")
|
||||
}
|
||||
|
||||
@SettingProperty(key: "searchProvider")
|
||||
public var searchProvider: SearchProviderSetting = .searxnor
|
||||
|
||||
@SettingProperty(key: "redirectRules")
|
||||
public var redirectRules: [String: String] = [:]
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
||||
@@ -2,6 +2,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.developer.web-browser</key>
|
||||
<true/>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
|
||||
+10
-20
@@ -19,7 +19,6 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
|
||||
public var tabInfo: TabInfo {
|
||||
get {
|
||||
updateMetadata()
|
||||
return _tabInfo
|
||||
}
|
||||
}
|
||||
@@ -39,18 +38,14 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
}
|
||||
public var policyManager: ResourcePolicyManager
|
||||
|
||||
private var _tabInfo: TabInfo = TabInfo()
|
||||
// Persisted snapshot of visible tab metadata; do not recompute on read.
|
||||
var _tabInfo: TabInfo = TabInfo()
|
||||
|
||||
private var loadedWebView: WKWebView? = nil
|
||||
public var title: String? { get { tabInfo.title } }
|
||||
public var url: URL? {
|
||||
get {
|
||||
if let urlString = tabInfo.urlString {
|
||||
return URL(string: urlString)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
if let urlString = tabInfo.urlString { return URL(string: urlString) }
|
||||
return nil
|
||||
}
|
||||
|
||||
public var javaScriptEnabled: Bool = false {
|
||||
@@ -110,6 +105,10 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
super.init()
|
||||
|
||||
bridge.delegate = self
|
||||
|
||||
// Initialize snapshot metadata
|
||||
_tabInfo.identifier = self.identifier
|
||||
if let url { _tabInfo.urlString = url.absoluteString }
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -117,6 +116,8 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
}
|
||||
|
||||
func beginLoadingURL(_ url: URL) {
|
||||
// Update snapshot immediately so UI keeps URL even if process jettisons.
|
||||
_tabInfo.urlString = url.absoluteString
|
||||
let request = URLRequest(url: url)
|
||||
webView.load(request)
|
||||
}
|
||||
@@ -150,15 +151,4 @@ class Tab: NSObject, SBRProcessBundleBridgeDelegate
|
||||
.assign(to: \.favicon, on: self)
|
||||
}
|
||||
}
|
||||
|
||||
private func updateMetadata() {
|
||||
guard contentProcessTerminated == false else { return }
|
||||
|
||||
_tabInfo = TabInfo(
|
||||
title: loadedWebView?.title,
|
||||
urlString: loadedWebView?.url?.absoluteString ?? self.homeURL?.absoluteString,
|
||||
faviconData: self.favicon?.pngData(),
|
||||
identifier: self.identifier
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,16 +49,28 @@ class TabController
|
||||
tabs.append(tab)
|
||||
}
|
||||
|
||||
// Title observation
|
||||
// Title observation: update snapshot and notify delegate.
|
||||
tab.titleObservation = tab.webView.observe(\.title, changeHandler: { [weak tab, weak self] (webView, change) in
|
||||
if let tab = tab, let self = self, let delegate = self.controllerDelegate {
|
||||
guard let tab = tab else { return }
|
||||
if let newTitle = webView.title, !newTitle.isEmpty {
|
||||
tab._tabInfo.title = newTitle
|
||||
}
|
||||
if let self = self, let delegate = self.controllerDelegate {
|
||||
delegate.tabController(self, didUpdateTitle: webView.title ?? "", forTab: tab)
|
||||
}
|
||||
})
|
||||
|
||||
// URL observation: persist the latest URL in the snapshot.
|
||||
tab.urlObservation = tab.webView.observe(\.url, changeHandler: { [weak tab] (webView, change) in
|
||||
guard let tab = tab else { return }
|
||||
tab._tabInfo.urlString = webView.url?.absoluteString ?? tab._tabInfo.urlString
|
||||
})
|
||||
|
||||
// Favicon Observation
|
||||
tab.faviconObservation = tab.$favicon.receive(on: RunLoop.main).sink { [weak tab, weak self] val in
|
||||
if let tab = tab, let self = self, let delegate = self.controllerDelegate {
|
||||
guard let tab = tab else { return }
|
||||
tab._tabInfo.faviconData = val?.pngData()
|
||||
if let self = self, let delegate = self.controllerDelegate {
|
||||
delegate.tabController(self, didUpdateFavicon: val, forTab: tab)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "Hacks.h"
|
||||
|
||||
#import <OSLog/OSLog.h>
|
||||
#import <stdatomic.h>
|
||||
|
||||
#import <WebKit/_WKRemoteObjectInterface.h>
|
||||
#import <WebKit/_WKRemoteObjectRegistry.h>
|
||||
@@ -19,10 +20,28 @@
|
||||
#import <WebKit/WKProcessPoolPrivate.h>
|
||||
#import <WebKit/WKWebViewPrivate.h>
|
||||
#import <WebKit/WKWebViewConfigurationPrivate.h>
|
||||
#import <WebKit/WKContentRuleListStore.h>
|
||||
|
||||
#define WKUserStyleSheet id
|
||||
#define WKUserStyleSheetEncodedClassName "X1dLVXNlclN0eWxlU2hlZXQ="
|
||||
|
||||
NSArray<NSString *> *CommonCDNList(void) {
|
||||
static dispatch_once_t onceToken;
|
||||
static NSArray<NSString *> *commonCDNList = nil;
|
||||
dispatch_once(&onceToken, ^{
|
||||
commonCDNList = @[
|
||||
@"cdn.jsdelivr.net",
|
||||
@"fsdn.net",
|
||||
@"cdnjs.com",
|
||||
@"osscdn.com",
|
||||
@"code.jquery.com",
|
||||
@"bootstrapcdn.com"
|
||||
];
|
||||
});
|
||||
|
||||
return commonCDNList;
|
||||
}
|
||||
|
||||
@interface StyleSheet : NSObject <NSCopying>
|
||||
@property (nonatomic, readonly, copy) NSString *source;
|
||||
@property (nonatomic, readonly, copy) NSURL *baseURL;
|
||||
@@ -31,6 +50,9 @@
|
||||
- (instancetype)initWithSource:(NSString *)source forMainFrameOnly:(BOOL)forMainFrameOnly;
|
||||
@end
|
||||
|
||||
// Note: We no longer proxy http/https via WKURLSchemeHandler; we use
|
||||
// WebKit content blocking rules instead.
|
||||
|
||||
@interface WKUserContentController (Private)
|
||||
- (void)__addUserStyleSheet:(WKUserStyleSheet)userStyleSheet;
|
||||
- (void)__removeUserStyleSheet:(WKUserStyleSheet)userStyleSheet;
|
||||
@@ -68,6 +90,13 @@
|
||||
#define LOG_DEBUG(format, ...) os_log_debug(_log, format, ##__VA_ARGS__)
|
||||
#define LOG_ERROR(format, ...) os_log_error(_log, format, ##__VA_ARGS__)
|
||||
|
||||
static os_log_t _log;
|
||||
|
||||
__attribute__((constructor))
|
||||
static void initialize_log(void) {
|
||||
_log = os_log_create("net.buzzert.attractor.webview", "bridge");
|
||||
}
|
||||
|
||||
@interface NSURLResponse (BridgeAdditions)
|
||||
@property (nonatomic, readonly) BOOL isJavascriptResponse;
|
||||
@end
|
||||
@@ -91,13 +120,11 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface SBRProcessBundleBridge () <WKURLSchemeHandler>
|
||||
@interface SBRProcessBundleBridge ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation SBRProcessBundleBridge {
|
||||
os_log_t _log;
|
||||
|
||||
WKWebView *_webView;
|
||||
WKWebViewConfiguration *_webViewConfiguration;
|
||||
WKProcessPool *_processPool;
|
||||
@@ -107,17 +134,21 @@
|
||||
|
||||
NSArray<WKUserScript *> *_userScripts;
|
||||
|
||||
dispatch_queue_t _dataTasksAccessQueue;
|
||||
NSMutableDictionary<NSURLRequest *, NSURLSessionDataTask *> *_dataTasks;
|
||||
|
||||
// These come from settings.
|
||||
WKUserStyleSheet _customizedUserStylesheet;
|
||||
WKUserScript *_customizedUserScript;
|
||||
|
||||
// Content blocking
|
||||
WKContentRuleList *_activeScriptRuleList;
|
||||
void *_urlKVOContext;
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
// This was used to unregister the delegate with the web process.
|
||||
if (_webView) {
|
||||
@try { [_webView removeObserver:self forKeyPath:@"URL" context:_urlKVOContext]; }
|
||||
@catch (__unused NSException *ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithWebViewConfiguration:(WKWebViewConfiguration *)webViewConfiguration
|
||||
@@ -125,8 +156,6 @@
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if (!webViewConfiguration) {
|
||||
_log = os_log_create("net.buzzert.attractor.webview", "bridge");
|
||||
|
||||
webViewConfiguration = [[WKWebViewConfiguration alloc] init];
|
||||
|
||||
// Set up process pool
|
||||
@@ -135,12 +164,7 @@
|
||||
|
||||
webViewConfiguration._waitsForPaintAfterViewDidMoveToWindow = NO;
|
||||
webViewConfiguration._applePayEnabled = YES;
|
||||
|
||||
_dataTasks = [NSMutableDictionary dictionary];
|
||||
_dataTasksAccessQueue = dispatch_queue_create("net.buzzert.attractor.dataTasksAccess", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
[webViewConfiguration setURLSchemeHandler:self forURLScheme:@"http"];
|
||||
[webViewConfiguration setURLSchemeHandler:self forURLScheme:@"https"];
|
||||
// No http/https interception — rely on content blocking rules instead.
|
||||
}
|
||||
|
||||
_webViewConfiguration = webViewConfiguration;
|
||||
@@ -161,6 +185,11 @@
|
||||
}
|
||||
|
||||
_webView = webView;
|
||||
_urlKVOContext = &_urlKVOContext; // unique context pointer
|
||||
[_webView addObserver:self forKeyPath:@"URL" options:(NSKeyValueObservingOptionNew) context:_urlKVOContext];
|
||||
|
||||
// Initialize content blocking rules for current host
|
||||
[self rebuildContentBlockingRulesForCurrentHost];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -223,97 +252,18 @@
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark <WKURLSchemeHandler>
|
||||
|
||||
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask
|
||||
{
|
||||
NSString *hostOrigin = [[_webView URL] host];
|
||||
NSURLRequest *request = [urlSchemeTask request];
|
||||
|
||||
LOG_DEBUG("Start URL scheme task: request: %@", request);
|
||||
|
||||
__weak __auto_type welf = self;
|
||||
NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error)
|
||||
{
|
||||
if (!welf) return;
|
||||
__strong __auto_type sself = welf;
|
||||
|
||||
if (error != nil) {
|
||||
[urlSchemeTask didFailWithError:error];
|
||||
} else if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
|
||||
NSURL *requestURL = [request URL];
|
||||
NSString *resourceOrigin = [requestURL host];
|
||||
const __auto_type allowResource = ^{
|
||||
os_log_debug(sself->_log, "Allowing resource: %@", requestURL.lastPathComponent);
|
||||
[urlSchemeTask didReceiveResponse:response];
|
||||
[urlSchemeTask didReceiveData:data];
|
||||
[urlSchemeTask didFinish];
|
||||
|
||||
[self webProcessDidAllowScriptWithOrigin:resourceOrigin];
|
||||
};
|
||||
|
||||
const __auto_type denyResource = ^{
|
||||
os_log_debug(sself->_log, "Blocking resource: %@", requestURL.lastPathComponent);
|
||||
NSHTTPURLResponse *altResponse = [[NSHTTPURLResponse alloc] initWithURL:requestURL
|
||||
MIMEType:@"application/javascript"
|
||||
expectedContentLength:0 textEncodingName:@"utf8"];
|
||||
[urlSchemeTask didReceiveResponse:altResponse];
|
||||
[urlSchemeTask didReceiveData:[NSData data]];
|
||||
[urlSchemeTask didFinish];
|
||||
|
||||
[self webProcessDidBlockScriptWithOrigin:resourceOrigin];
|
||||
};
|
||||
|
||||
// Check MIME type for JavaScript responses.
|
||||
if ([response isJavascriptResponse] && ![sself allowAllScripts]) {
|
||||
dispatch_async(sself->_dataTasksAccessQueue, ^{
|
||||
NSDictionary<NSString *, NSNumber *> *policyTypes = [sself->_policyDataSource scriptPolicyTypeByOrigin];
|
||||
NSNumber *policyType = [policyTypes objectForKey:hostOrigin];
|
||||
|
||||
SBRScriptPolicy *policy = [[SBRScriptPolicy alloc] initWithSecurityOrigin:hostOrigin policyType:[policyType integerValue]];
|
||||
if ([policy allowsExternalJavaScriptResourceOrigin:resourceOrigin]) {
|
||||
allowResource();
|
||||
} else {
|
||||
denyResource();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
allowResource();
|
||||
}
|
||||
} else {
|
||||
[urlSchemeTask didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:nil]];
|
||||
}
|
||||
|
||||
[sself->_dataTasks removeObjectForKey:request];
|
||||
}];
|
||||
|
||||
[_dataTasks setObject:dataTask forKey:request];
|
||||
[dataTask resume];
|
||||
}
|
||||
|
||||
- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask
|
||||
{
|
||||
NSURLRequest *request = [urlSchemeTask request];
|
||||
NSURLSessionDataTask *dataTask = [_dataTasks objectForKey:request];
|
||||
if (dataTask) {
|
||||
if ([dataTask state] != NSURLSessionTaskStateCanceling) {
|
||||
[dataTask cancel];
|
||||
}
|
||||
|
||||
[_dataTasks removeObjectForKey:request];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark Actions
|
||||
|
||||
- (void)policyDataSourceDidChange
|
||||
{
|
||||
// This was used when we had to signal the process bundle.
|
||||
// Rebuild content blocking rules when policy changes.
|
||||
[self rebuildContentBlockingRulesForCurrentHost];
|
||||
}
|
||||
|
||||
- (void)setAllowAllScripts:(BOOL)allowAllScripts
|
||||
{
|
||||
_allowAllScripts = allowAllScripts;
|
||||
[self rebuildContentBlockingRulesForCurrentHost];
|
||||
}
|
||||
|
||||
- (void)setDarkModeEnabled:(BOOL)darkModeEnabled
|
||||
@@ -360,4 +310,119 @@
|
||||
}];
|
||||
}
|
||||
|
||||
// MARK: - Content Blocking Rules
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
|
||||
{
|
||||
if (context == _urlKVOContext && [keyPath isEqualToString:@"URL"]) {
|
||||
[self rebuildContentBlockingRulesForCurrentHost];
|
||||
return;
|
||||
}
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
|
||||
- (void)rebuildContentBlockingRulesForCurrentHost
|
||||
{
|
||||
NSString *hostOrigin = _webView.URL.host;
|
||||
if (!hostOrigin) {
|
||||
// No page loaded yet; clear any existing rules
|
||||
[self applyContentRuleListJSON:nil withName:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine policy for this host
|
||||
NSNumber *policyType = nil;
|
||||
@synchronized (_policyDataSource) {
|
||||
NSDictionary<NSString *, NSNumber *> *policyTypes = [_policyDataSource scriptPolicyTypeByOrigin];
|
||||
policyType = [policyTypes objectForKey:hostOrigin] ?: @(0);
|
||||
}
|
||||
|
||||
// Alpha=0 Bravo=1 Charlie=2 Delta=3 Echo=4
|
||||
SBRScriptOriginPolicyType type = [policyType integerValue];
|
||||
if (_allowAllScripts || type >= SBRScriptOriginPolicyTypeEcho) {
|
||||
// Echo or shields down: no blocking
|
||||
[self applyContentRuleListJSON:nil withName:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
// Base trigger applies only to this page's domain
|
||||
NSMutableArray *rules = [NSMutableArray array];
|
||||
NSDictionary *baseScriptTrigger = @{
|
||||
@"resource-type" : @[ @"script" ],
|
||||
@"if-domain" : @[ hostOrigin ]
|
||||
};
|
||||
|
||||
if (type <= SBRScriptOriginPolicyTypeBravo) {
|
||||
// Alpha or Bravo: block all external script subresources (inline JS is controlled via preferences elsewhere)
|
||||
[rules addObject:@{ @"trigger": baseScriptTrigger, @"action": @{ @"type": @"block" } }];
|
||||
} else {
|
||||
// Charlie/Delta: block third-party scripts
|
||||
NSMutableDictionary *trigger = [baseScriptTrigger mutableCopy];
|
||||
trigger[@"load-type"] = @[ @"third-party" ];
|
||||
[rules addObject:@{ @"trigger": trigger, @"action": @{ @"type": @"block" } }];
|
||||
|
||||
if (type >= SBRScriptOriginPolicyTypeDelta) {
|
||||
// Delta: add allowlist for common CDNs
|
||||
for (NSString *cdn in CommonCDNList()) {
|
||||
NSString *escaped = [NSRegularExpression escapedPatternForString:cdn];
|
||||
NSString *pattern = [NSString stringWithFormat:@".*://([^.]*\\.)?%@/", escaped];
|
||||
[rules addObject:@{
|
||||
@"trigger": @{
|
||||
@"url-filter": pattern,
|
||||
@"if-domain": @[ hostOrigin ],
|
||||
@"resource-type": @[ @"script" ]
|
||||
},
|
||||
@"action": @{ @"type": @"ignore-previous-rules" }
|
||||
}];
|
||||
}
|
||||
|
||||
// Heuristic: allow cdn.<anything-with-family-name>/* where family name is the second-level label
|
||||
NSArray<NSString *> *components = [hostOrigin componentsSeparatedByString:@"."];
|
||||
if (components.count > 1) {
|
||||
NSString *family = components[components.count - 2];
|
||||
NSString *escapedFamily = [NSRegularExpression escapedPatternForString:family];
|
||||
NSString *familyPattern = [NSString stringWithFormat:@".*://cdn\\.[^/]*%@[^/]*/", escapedFamily];
|
||||
[rules addObject:@{
|
||||
@"trigger": @{
|
||||
@"url-filter": familyPattern,
|
||||
@"if-domain": @[ hostOrigin ],
|
||||
@"resource-type": @[ @"script" ]
|
||||
},
|
||||
@"action": @{ @"type": @"ignore-previous-rules" }
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:rules options:0 error:nil];
|
||||
NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||
NSString *name = [NSString stringWithFormat:@"net.buzzert.attractor.rules.%@", hostOrigin];
|
||||
[self applyContentRuleListJSON:json withName:name];
|
||||
}
|
||||
|
||||
- (void)applyContentRuleListJSON:(NSString *)json withName:(NSString *)name
|
||||
{
|
||||
WKUserContentController *controller = [_webViewConfiguration userContentController];
|
||||
if (_activeScriptRuleList) {
|
||||
[controller removeContentRuleList:_activeScriptRuleList];
|
||||
_activeScriptRuleList = nil;
|
||||
}
|
||||
|
||||
if (!json || !name) { return; }
|
||||
|
||||
WKContentRuleListStore *store = [WKContentRuleListStore defaultStore];
|
||||
[store compileContentRuleListForIdentifier:name encodedContentRuleList:json completionHandler:^(WKContentRuleList * _Nullable ruleList, NSError * _Nullable error) {
|
||||
if (error) {
|
||||
LOG_ERROR("Failed to compile content rule list: %@", error.localizedDescription);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self->_activeScriptRuleList = ruleList;
|
||||
[controller addContentRuleList:ruleList];
|
||||
LOG_DEBUG("Applied content rule list: %@", name);
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,6 +9,18 @@ import Foundation
|
||||
|
||||
class SearchProvider
|
||||
{
|
||||
// Build a provider from a URL template. Template should contain %q or %s
|
||||
// which will be replaced with the sanitized query string.
|
||||
static func fromTemplate(_ template: String) -> SearchProvider {
|
||||
SearchProvider(resolver: { query in
|
||||
let sanitized = query.sanitized()
|
||||
let replaced = template
|
||||
.replacingOccurrences(of: "%q", with: sanitized)
|
||||
.replacingOccurrences(of: "%s", with: sanitized)
|
||||
return URL(string: replaced) ?? URL(string: "https://google.com/search?q=\(sanitized)&gbv=1")!
|
||||
})
|
||||
}
|
||||
|
||||
static let google = SearchProvider(resolver: { query in
|
||||
// gbv=1: no JS
|
||||
URL(string: "https://google.com/search?q=\(query.sanitized())&gbv=1")!
|
||||
|
||||
+244
@@ -0,0 +1,244 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.8)
|
||||
abbrev (0.1.2)
|
||||
addressable (2.9.0)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1274.0)
|
||||
aws-sdk-core (3.254.0)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.130.0)
|
||||
aws-sdk-core (~> 3, >= 3.254.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.228.1)
|
||||
aws-sdk-core (~> 3, >= 3.254.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.3.0)
|
||||
benchmark (0.5.0)
|
||||
bigdecimal (4.1.2)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
csv (3.3.6)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
domain_name (0.6.20240107)
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
excon (1.6.0)
|
||||
logger
|
||||
faraday (1.10.6)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.8)
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (>= 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.2.0)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.4)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.1)
|
||||
fastlane (2.237.0)
|
||||
CFPropertyList (>= 2.3, < 5.0.0)
|
||||
abbrev (~> 0.1)
|
||||
addressable (>= 2.9.0, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
aws-sdk-s3 (~> 1.197)
|
||||
babosa (>= 1.0.3, < 2.0.0)
|
||||
base64 (~> 0.2)
|
||||
benchmark (>= 0.1.0)
|
||||
bundler (>= 2.4.0, < 5.0.0)
|
||||
colored (~> 1.2)
|
||||
commander (~> 4.6)
|
||||
csv (~> 3.3)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 2.0.0)
|
||||
faraday (~> 1.0)
|
||||
faraday-cookie_jar (~> 0.0.6)
|
||||
faraday_middleware (~> 1.0)
|
||||
fastimage (>= 2.1.0, < 3.0.0)
|
||||
fastlane-sirp (>= 1.1.0)
|
||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||
google-apis-androidpublisher_v3 (~> 0.3)
|
||||
google-apis-playcustomapp_v1 (~> 0.1)
|
||||
google-cloud-env (>= 1.6.0, < 2.3.0)
|
||||
google-cloud-storage (~> 1.31)
|
||||
highline (~> 2.0)
|
||||
http-cookie (~> 1.0.5)
|
||||
json (< 3.0.0)
|
||||
jwt (>= 2.10.3, < 4)
|
||||
logger (>= 1.6, < 2.0)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multi_json (~> 1.12)
|
||||
multipart-post (>= 2.0.0, < 3.0.0)
|
||||
mutex_m (~> 0.3)
|
||||
naturally (~> 2.2)
|
||||
nkf (~> 0.2)
|
||||
optparse (>= 0.1.1, < 1.0.0)
|
||||
ostruct (>= 0.1.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.5)
|
||||
simctl (~> 1.6.3)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-table (~> 3)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.4.1)
|
||||
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
|
||||
fastlane-sirp (1.1.0)
|
||||
gh_inspector (1.1.3)
|
||||
google-apis-androidpublisher_v3 (0.106.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-core (0.18.0)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (~> 1.9)
|
||||
httpclient (>= 2.8.3, < 3.a)
|
||||
mini_mime (~> 1.0)
|
||||
mutex_m
|
||||
representable (~> 3.0)
|
||||
retriable (>= 2.0, < 4.a)
|
||||
google-apis-iamcredentials_v1 (0.28.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-playcustomapp_v1 (0.18.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-apis-storage_v1 (0.65.0)
|
||||
google-apis-core (>= 0.15.0, < 2.a)
|
||||
google-cloud-core (1.9.0)
|
||||
google-cloud-env (>= 1.0, < 3.a)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (2.2.2)
|
||||
base64 (~> 0.2)
|
||||
faraday (>= 1.0, < 3.a)
|
||||
google-cloud-errors (1.7.0)
|
||||
google-cloud-storage (1.62.0)
|
||||
addressable (~> 2.8)
|
||||
digest-crc (~> 0.4)
|
||||
google-apis-core (>= 0.18, < 2)
|
||||
google-apis-iamcredentials_v1 (~> 0.18)
|
||||
google-apis-storage_v1 (>= 0.42)
|
||||
google-cloud-core (~> 1.6)
|
||||
googleauth (~> 1.9)
|
||||
mini_mime (~> 1.0)
|
||||
google-logging-utils (0.2.0)
|
||||
googleauth (1.17.2)
|
||||
faraday (>= 1.0, < 3.a)
|
||||
google-cloud-env (~> 2.2)
|
||||
google-logging-utils (~> 0.1)
|
||||
jwt (>= 1.4, < 4.0)
|
||||
os (>= 0.9, < 2.0)
|
||||
pstore (~> 0.1)
|
||||
signet (>= 0.16, < 2.a)
|
||||
highline (2.0.3)
|
||||
http-cookie (1.0.8)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.21.1)
|
||||
jwt (3.2.0)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.21.1)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.3.0)
|
||||
nkf (0.3.0)
|
||||
optparse (0.8.1)
|
||||
os (1.1.4)
|
||||
ostruct (0.6.3)
|
||||
plist (3.7.2)
|
||||
pstore (0.2.1)
|
||||
public_suffix (7.0.5)
|
||||
rake (13.4.2)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.8.0)
|
||||
rexml (3.4.4)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.22.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 4.0)
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
naturally
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (3.0.2)
|
||||
unicode-display_width (>= 1.1.1, < 3)
|
||||
trailblazer-option (0.1.2)
|
||||
tty-cursor (0.7.1)
|
||||
tty-screen (0.8.2)
|
||||
tty-spinner (0.9.3)
|
||||
tty-cursor (~> 0.7)
|
||||
uber (0.1.0)
|
||||
unicode-display_width (2.6.0)
|
||||
word_wrap (1.0.0)
|
||||
xcodeproj (1.28.1)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
base64
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.4.0)
|
||||
nkf
|
||||
rexml (>= 3.3.6, < 4.0)
|
||||
xcpretty (0.4.1)
|
||||
rouge (~> 3.28.0)
|
||||
xcpretty-travis-formatter (1.0.1)
|
||||
xcpretty (~> 0.2, >= 0.0.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
fastlane (= 2.237.0)
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.23
|
||||
@@ -26,3 +26,10 @@ Attractor operates in five "security modes":
|
||||
- Custom redirect rules
|
||||
- Catalyst and iPadOS support
|
||||
|
||||
## Deployment
|
||||
|
||||
TestFlight deployment is handled by Fastlane and the Gitea workflow at `.gitea/workflows/testflight.yml`.
|
||||
|
||||
Required Gitea secrets match the local `.env.example`: `ASC_KEY_ID`, `ASC_ISSUER_ID`, `ASC_KEY`, `MATCH_PASSWORD`, and `MATCH_GIT_BASIC_AUTHORIZATION`.
|
||||
|
||||
Push a tag like `release/ios/v4.2` or `Attractor-4.2` to build and upload to TestFlight.
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
CD361CF6271A3718006E9CA5 /* SBRScriptPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = CD361CF5271A3718006E9CA5 /* SBRScriptPolicy.m */; };
|
||||
CD470C4225DE056600AFBE0E /* BrowserViewController+WebKitDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD470C4125DE056600AFBE0E /* BrowserViewController+WebKitDelegate.swift */; };
|
||||
CD470C4425DE070400AFBE0E /* BrowserViewController+Keyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD470C4325DE070400AFBE0E /* BrowserViewController+Keyboard.swift */; };
|
||||
CD4930D92E8B390200ADDE99 /* AddSearchEngineViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4930D82E8B38FC00ADDE99 /* AddSearchEngineViewController.swift */; };
|
||||
CD4930DB2E8B3F6500ADDE99 /* ManageSearchEnginesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4930DA2E8B3F5B00ADDE99 /* ManageSearchEnginesViewController.swift */; };
|
||||
CD7313E22705349700053347 /* ScriptPolicyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD7313E12705349700053347 /* ScriptPolicyViewController.swift */; };
|
||||
CD7313E4270534B800053347 /* ScriptPolicyViewControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD7313E3270534B800053347 /* ScriptPolicyViewControllerDelegate.swift */; };
|
||||
CD7A7E9D2686A9A500E20BA3 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD7A7E9C2686A9A500E20BA3 /* SettingsViewController.swift */; };
|
||||
@@ -143,6 +145,8 @@
|
||||
CD3D6CED2DA9F8910099667F /* WebKitDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebKitDefines.h; sourceTree = "<group>"; };
|
||||
CD470C4125DE056600AFBE0E /* BrowserViewController+WebKitDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrowserViewController+WebKitDelegate.swift"; sourceTree = "<group>"; };
|
||||
CD470C4325DE070400AFBE0E /* BrowserViewController+Keyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrowserViewController+Keyboard.swift"; sourceTree = "<group>"; };
|
||||
CD4930D82E8B38FC00ADDE99 /* AddSearchEngineViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSearchEngineViewController.swift; sourceTree = "<group>"; };
|
||||
CD4930DA2E8B3F5B00ADDE99 /* ManageSearchEnginesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageSearchEnginesViewController.swift; sourceTree = "<group>"; };
|
||||
CD7313E12705349700053347 /* ScriptPolicyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptPolicyViewController.swift; sourceTree = "<group>"; };
|
||||
CD7313E3270534B800053347 /* ScriptPolicyViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScriptPolicyViewControllerDelegate.swift; sourceTree = "<group>"; };
|
||||
CD7A7E9C2686A9A500E20BA3 /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
@@ -477,6 +481,8 @@
|
||||
CD7A7E9C2686A9A500E20BA3 /* SettingsViewController.swift */,
|
||||
CD7A7E9E2686B29100E20BA3 /* GeneralSettingsViewController.swift */,
|
||||
CD7A7EA02686B2E600E20BA3 /* RedirectRulesSettingsViewController.swift */,
|
||||
CD4930D82E8B38FC00ADDE99 /* AddSearchEngineViewController.swift */,
|
||||
CD4930DA2E8B3F5B00ADDE99 /* ManageSearchEnginesViewController.swift */,
|
||||
CDF3468F276C14BD00FB3141 /* CodeEditorSettingsViewController.swift */,
|
||||
);
|
||||
path = Settings;
|
||||
@@ -569,6 +575,7 @@
|
||||
files = (
|
||||
1ADFF46024C7DE53006DC7AE /* AppDelegate.swift in Sources */,
|
||||
1AD3104325254FB900A4A952 /* FindOnPageViewController.swift in Sources */,
|
||||
CD4930D92E8B390200ADDE99 /* AddSearchEngineViewController.swift in Sources */,
|
||||
1A03811424E73EB300826501 /* SegmentedReliefButton.swift in Sources */,
|
||||
1A03811024E71CF000826501 /* ReliefButton.swift in Sources */,
|
||||
CD8ACBC22DC9A2F7008BF856 /* Hacks.m in Sources */,
|
||||
@@ -604,6 +611,7 @@
|
||||
CD853BCE24E7763900D2BDCC /* BrowserHistory.swift in Sources */,
|
||||
1A03810B24E71C5600826501 /* ToolbarButtonContainerView.swift in Sources */,
|
||||
CD8DBE7B2A85D892006A0FE0 /* LayoutLatch.swift in Sources */,
|
||||
CD4930DB2E8B3F6500ADDE99 /* ManageSearchEnginesViewController.swift in Sources */,
|
||||
CD7A7EA12686B2E600E20BA3 /* RedirectRulesSettingsViewController.swift in Sources */,
|
||||
1ADFF4CB24CB8278006DC7AE /* ScriptControllerIconView.swift in Sources */,
|
||||
CD7A8915251975B70075991E /* AutocompleteViewController.swift in Sources */,
|
||||
@@ -782,9 +790,9 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "App/Supporting Files/SBrowser.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
CURRENT_PROJECT_VERSION = 6;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = DQQH5H6GBD;
|
||||
DEVELOPMENT_TEAM = 3SJALV9BQ7;
|
||||
INFOPLIST_FILE = "App/Supporting Files/Info.plist";
|
||||
INFOPLIST_KEY_CFBundleDisplayName = Attractor;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
|
||||
@@ -793,7 +801,7 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 4.0;
|
||||
MARKETING_VERSION = 4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.attractor;
|
||||
PRODUCT_NAME = Attractor;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -815,9 +823,9 @@
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = "App/Supporting Files/SBrowser.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
CODE_SIGN_IDENTITY = "Apple Distribution";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_PROJECT_VERSION = 6;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = DQQH5H6GBD;
|
||||
INFOPLIST_FILE = "App/Supporting Files/Info.plist";
|
||||
@@ -828,10 +836,10 @@
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 4.0;
|
||||
MARKETING_VERSION = 4.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = net.buzzert.attractor;
|
||||
PRODUCT_NAME = Attractor;
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "Attractor AppStore CI";
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = YES;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
app_identifier("net.buzzert.attractor")
|
||||
team_id("DQQH5H6GBD")
|
||||
@@ -0,0 +1,40 @@
|
||||
default_platform(:ios)
|
||||
|
||||
platform :ios do
|
||||
desc "Build a release tag and upload it to TestFlight"
|
||||
lane :beta do
|
||||
setup_ci
|
||||
|
||||
match(type: "appstore")
|
||||
|
||||
tag = ENV.fetch("GITHUB_REF_NAME")
|
||||
version = tag[%r{\A(?:release/ios/v|Attractor-)(\d+(?:\.\d+){1,2})\z}, 1]
|
||||
UI.user_error!("Expected a tag like release/ios/v4.2 or Attractor-4.2; got #{tag.inspect}") unless version
|
||||
|
||||
build_number = ENV.fetch("GITHUB_RUN_NUMBER")
|
||||
UI.user_error!("GITHUB_RUN_NUMBER must be a positive integer") unless build_number.match?(/\A[1-9]\d*\z/)
|
||||
|
||||
update_info_plist(
|
||||
plist_path: "App/Supporting Files/Info.plist",
|
||||
block: proc do |plist|
|
||||
plist["CFBundleShortVersionString"] = version
|
||||
plist["CFBundleVersion"] = build_number
|
||||
end
|
||||
)
|
||||
|
||||
api_key = app_store_connect_api_key(
|
||||
key_id: ENV.fetch("ASC_KEY_ID"),
|
||||
issuer_id: ENV.fetch("ASC_ISSUER_ID"),
|
||||
key_content: ENV.fetch("ASC_KEY"),
|
||||
is_key_content_base64: true
|
||||
)
|
||||
|
||||
build_app(scheme: "Attractor")
|
||||
|
||||
upload_to_testflight(
|
||||
api_key: api_key,
|
||||
skip_waiting_for_build_processing: true,
|
||||
uses_non_exempt_encryption: false
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,7 @@
|
||||
git_url("https://code.buzzert.dev/buzzert/fastlane-match.git")
|
||||
storage_mode("git")
|
||||
type("appstore")
|
||||
|
||||
app_identifier(["net.buzzert.attractor"])
|
||||
team_id("DQQH5H6GBD")
|
||||
profile_name("Attractor AppStore CI")
|
||||
@@ -0,0 +1,18 @@
|
||||
simulator := "platform=iOS Simulator,name=iPhone 17e,OS=latest"
|
||||
derived_data := "build/DerivedData"
|
||||
|
||||
default:
|
||||
@just build
|
||||
|
||||
build:
|
||||
if command -v xcbeautify >/dev/null 2>&1; then \
|
||||
xcodebuild -project SBrowser.xcodeproj -scheme Attractor -destination '{{simulator}}' | xcbeautify; \
|
||||
else \
|
||||
xcodebuild -project SBrowser.xcodeproj -scheme Attractor -destination '{{simulator}}'; \
|
||||
fi
|
||||
|
||||
beta:
|
||||
bundle exec fastlane ios beta
|
||||
|
||||
setup-signing:
|
||||
bundle exec fastlane ios setup_signing
|
||||
Reference in New Issue
Block a user