百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

arkana

> 编程语言
开源

对于 Android 和 iOS 项目,请使用 dotenv 文件。

448 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

对于 Android 和 iOS 项目,请使用 dotenv 文件。

Requirements

Android

Your project must be using the Gradle Build Tool.

iOS

Your project must be using Swift Package Manager or CocoaPods as dependency manager (or both). No support for Carthage.

Note: this gem was only tested in macOS environments.

Preview

Kotlin

Click here to see the Kotlin preview

The image below shows how the auto-generated file looks like.

Usage using the example code above:

kotlin
import com.arkanakeys.MySecrets

// Designed with testability and DI in mind
println(MySecrets.Global.someBooleanSecret)
println(MySecrets.Global.someIntSecret)
println(MySecrets.Global.mySecretAPIKey)

// Simulating environment selection using a random boolean value
val keys = if (Math.random() 

### Swift

Click here to see the Swift preview

The image below shows how the auto-generated file looks like.

Usage using the example code above:

```swift
import ArkanaKeys

// Designed with testability and DI in mind
print(MySecrets.Global().someBooleanSecret)
print(MySecrets.Global().someIntSecret)
print(MySecrets.Global().mySecretAPIKey)

// This is a demo, so we are using Bool.random() to simulate the environment
let keys: MySecretsEnvironmentProtocol = Bool.random() ? MySecrets.Dev() : MySecrets.Staging()
print(keys.serviceKey)

Installation

Add this gem to your Gemfile if you're using bundler (recommended):

ruby
gem 'arkana'

And then run bundle install to install it.

Alternatively, you can install it in your entire system instead (not recommended):

ruby
gem install arkana

Basic Usage

Arkana requires the declaration of a YAML config file. Although you can name it whatever, the convention is to name it .arkana.yml. See template.yml for complete options.

Once you have created your config file, you can run Arkana:

bash
Usage: arkana [options]
    -c /path/to/your/.arkana.yml,    Path to your config file. Defaults to '.arkana.yml'
    -e /path/to/your/.env,           Path to your dotenv file. Defaults to '.env' if one exists.
    -l kotlin                        Language to produce keys for, e.g. kotlin, swift. Defaults to 'swift'.

…

yaml
environments:
  - Release
  - Debug
environment_secrets:
  - apiKey
global_secrets:
  - clientID

Coupled with env vars (or a .env file):

properties
apiKeyDebug = "your_debug_api_key"
apiKeyRelease = "your_release_api_key"
clientID = "your_client_id"

[!IMPORTANT] Notice how arkana needs you to name your env var keys by appending the environment name to the environment secrets, e.g. apiKey environment secret requires apiKeyDebug and apiKeyRelease env vars.

Would generate the following accessors:

swift
// Swift
public extension ArkanaKeys {
    struct Global: ArkanaKeysGlobalProtocol {
        public let clientID: String = {}
    }
}
public extension ArkanaKeys {
    struct Release: ArkanaKeysEnvironmentProtocol {
        public let apiKey: String = {}
    }
}
public extension ArkanaKeys {
    struct Debug: ArkanaKeysEnvironmentProtocol {
        public let apiKey: String = {}
    }
}

…

swift
…
dependencies: [
    …
    .package(name: "ArkanaKeys", path: "path/to/your/dependencies/ArkanaKeys"),
    …
],
…

Via CocoaPods

If you're integrating Arkana via CocoaPods (package_manager is set to cocoapods), Arkana will generate its files as a Development Pod.

Add ArkanaKeys and ArkanaKeysInterfaces (or the pod_name option that you passed in your config file) to your list of dependencies in your Podfile file, like this:

ruby
pod "ArkanaKeys", path: "path/to/your/dependencies/ArkanaKeys"
pod "ArkanaKeysInterfaces", path: "path/to/your/dependencies/ArkanaKeysInterfaces"

…

kotlin
exec {
    commandLine("arkana", "--lang", "kotlin")
}

…

ruby
SecretWithDollarSignEscapedAndAndNoQuotesKey = real_\$lim_shady
SecretWithDollarSignEscapedAndDoubleQuoteKey = "real_\$lim_shady"
SecretWithDollarSignNotEscapedAndSingleQuoteKey = 'real_$lim_shady'

These are not valid:

ruby
SecretWithDollarSignNotEscapedAndDoubleQuotesKey = "real_$lim_shady"
SecretWithDollarSignNotEscapedAndNoQuotesKey = real_$lim_shady

When storing your secret in actual env vars (instead of dotfiles), you will most likely need to escape them too.

Other characters to avoid

  • \ aka backslash: double scaping will be needed
  • " aka double quotes: escaping is needed

Other common special characters that are fine to be used

txt
` ~ ! @ # % ^ & * ( ) _ - + = { [ } } | : ; '  . ? /

…

ruby
`bundle exec arkana --config-filepath /path/to/your/.arkana.yml --dotenv-filepath /path/to/your/.env`

Note: include the back-ticks above, they're required, so that Ruby interprets the snippet as a shell script.

By doing this, your Arkana code generation will be executed everytime you run pod install or pod update.

The only down side of using this strategy is that you wouldn't want to use it if you need to pass in (dynamic) flavors, since it would require you to modify the Podfile on every different flavor you need to build. If that's the case, you should run Arkana before running pod install in your build pipeline, and not use this snippet at all.

References

Did you know?

The word arcanum (pluralized as "arcana", here spelled as "Arkana") came from Latin arcanus, meaning "secret", and entered English as the Dark Ages gave way to the Renaissance.²

Special thanks to @danilobecke for the inspiration and heavy lifting, and to @orta for the creation of https://github.com/orta/cocoapods-keys which this project is based off of.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

To bump the lib's version, run bundle exec rake bump[1.2.3] (replacing the value with the desired version).

To release a new version, make sure the version number in version.rb is the one you want to release (after setting it via bundle exec rake bump as shown above), and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Contributions to Arkana are warmly welcomed. Whether it's bug reports, feature requests, or code contributions, your input is highly valued. Please feel free to submit issues and pull requests with your ideas and I promise to get back to you within 24 hours!

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

For a list of issues worth tackling check out: https://github.com/rogerluan/arkana/issues

Popularity

Explore my other tools

Forget about 'When did release v2.1.3 go live again?' and 'Is the app ready to be tested yet?'

Statused monitors App Store Connect and send you notifications directly on Slack.

Learn more: statused.com

License

This project is open source and covered by a standard 2-clause BSD license. That means you can use (publicly, commercially and privately), modify and distribute this project's content, as long as you mention Roger Oba as the original author of this code and reproduce the LICENSE text inside your app, repository, project or research paper.

Contact

Twitter: @rogerluan_

Issues· 16 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubyandroiddotenvencryptiongem

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言