FLEX README

The project's README from github.com/FLEXTool/FLEX. As one markdown file: README.md.

FLEX

CocoaPods CocoaPods CocoaPods Twitter: @ryanolsonk Build Status Carthage compatible

FLEX (Flipboard Explorer) is a set of in-app debugging and exploration tools for iOS development. When presented, FLEX shows a toolbar that lives in a window above your application. From this toolbar, you can view and modify nearly every piece of state in your running application.

Demo

Give Yourself Debugging Superpowers

Unlike many other debugging tools, FLEX runs entirely inside your app, so you don't need to be connected to LLDB/Xcode or a different remote debugging server. It works well in the simulator and on physical devices.

Usage

In the iOS simulator, you can use keyboard shortcuts to activate FLEX. f will toggle the FLEX toolbar. Hit the ? key for a full list of shortcuts. You can also show FLEX programmatically:

Short version:

// Objective-C
[[FLEXManager sharedManager] showExplorer];
// Swift
FLEXManager.shared.showExplorer()

More complete version:

#if DEBUG
#import "FLEXManager.h"
#endif

...

- (void)handleSixFingerQuadrupleTap:(UITapGestureRecognizer *)tapRecognizer
{
#if DEBUG
    if (tapRecognizer.state == UIGestureRecognizerStateRecognized) {
        // This could also live in a handler for a keyboard shortcut, debug menu item, etc.
        [[FLEXManager sharedManager] showExplorer];
    }
#endif
}

Aside: tvOS

FLEX itself does not support tvOS out of the box. However, others have taken it upon themselves to port FLEX to tvOS. If you need tvOS support, seek out one of these forks. Here is one such fork.

Feature Examples

Modify Views

Once a view is selected, you can tap on the info bar below the toolbar to present more details about the view. From there, you can modify properties and call methods.

Modify Views

Network History

When enabled, network debugging allows you to view all requests made using NSURLConnection or NSURLSession. Settings allow you to adjust what kind of response bodies get cached and the maximum size limit of the response cache. You can choose to have network debugging enabled automatically on app launch. This setting is persisted across launches.

Network History

All Objects on the Heap

FLEX queries malloc for all the live allocated memory blocks and searches for ones that look like objects. You can see everything from here.

Heap/Live Objects Explorer

Explore-at-address

If you get your hands on an arbitrary address, you can try explore the object at that address, and FLEX will open it if it can verify the address points to a valid object. If FLEX isn't sure, it'll warn you and refuse to dereference the pointer. If you know better, however, you can choose to explore it anyway by choosing "Unsafe Explore"

Address Explorer

Simulator Keyboard Shortcuts

Default keyboard shortcuts allow you to activate the FLEX tools, scroll with the arrow keys, and close modals using the escape key. You can also add custom keyboard shortcuts via -[FLEXManager registerSimulatorShortcutWithKey:modifiers:action:description]

Simulator Keyboard Shortcuts

File Browser

View the file system within your app's bundle or sandbox container. FLEX shows file sizes, image previews, and pretty prints .json and .plist files. You can rename and delete files and folders. You can "share" any file if you want to inspect them outside of your app.

File Browser

SQLite Browser

SQLite database files (with either .db or .sqlite extensions), or Realm database files can be explored using FLEX. The database browser lets you view all tables, and individual tables can be sorted by tapping column headers.

SQLite Browser

3D Touch in the Simulator

Using a combination of the command, control, and shift keys, you can simulate different levels of 3D touch pressure in the simulator. Each key contributes 1/3 of maximum possible force. Note that you need to move the touch slightly to get pressure updates.

Simulator 3D Touch

Explore Loaded Libraries

Go digging for all things public and private. To learn more about a class, you can create an instance of it and explore its default state. You can also type in a class name to jump to that class directly if you know which class you're looking for.

Loaded Libraries Exploration

NSUserDefaults Editing

FLEX allows you to edit defaults that are any combination of strings, numbers, arrays, and dictionaries. The input is parsed as JSON. If other kinds of objects are set for a defaults key (i.e. NSDate), you can view them but not edit them.

NSUserDefaults Editing

Learning from Other Apps

The code injection is left as an exercise for the reader. :innocent:

Springboard Lock Screen Springboard Home Screen

Installation

FLEX requires an app that targets iOS 9 or higher. To run the Example project, open a Terminal window in the Example/ folder and run pod install, then open the generated workspace.

CocoaPods

FLEX is available on CocoaPods. Simply add the following line to your podfile:

pod 'FLEX', :configurations => ['Debug']

Carthage

Add the following to your Cartfile:

github "flipboard/FLEX"

Buck

If you're using Buck, you may want to silence some of the warnings emitted by FLEX. You will need to build FLEX as an apple_library and pass the -Wno-unsupported-availability-guard flag, as well as the other warning flags below to disable any other warnings FLEX may have.

Manual

Manually add the files in Classes/ to your Xcode project, or just drag in the entire FLEX/ folder. Be sure to exclude FLEX from Release builds or your app will be rejected.

Silencing warnings

Add the following flags to to Other Warnings Flags in Build Settings:

Swift Package Manager

Include the dependency in the dependencies value of your Package.swift

dependencies: [
    .package(url: "https://github.com/FLEXTool/FLEX.git", .upToNextMajor(from: "4.3.0"))
]

Next, include the library in your target:

.target(
    name: "YourDependency",
    dependencies: [
        "FLEX"
    ]
)

Excluding FLEX from Release (App Store) Builds

FLEX makes it easy to explore the internals of your app, so it is not something you should expose to your users. Fortunately, it is easy to exclude FLEX files from Release builds. The strategies differ depending on how you integrated FLEX in your project, and are described below.

Wrap the places in your code where you integrate FLEX with an #if DEBUG statement to ensure the tool is only accessible in your Debug builds and to avoid errors in your Release builds. For more help with integrating FLEX, see the example project.

CocoaPods

CocoaPods automatically excludes FLEX from release builds if you only specify the Debug configuration for FLEX in your Podfile:

pod 'FLEX', :configurations => ['Debug']

Carthage

  1. Do NOT add FLEX.framework to the embedded binaries of your target, as it would otherwise be included in all builds (therefore also in release ones).

  2. Instead, add $(PROJECT_DIR)/Carthage/Build/iOS to your target Framework Search Paths (this setting might already be present if you already included other frameworks with Carthage). This makes it possible to import the FLEX framework from your source files. It does not harm if this setting is added for all configurations, but it should at least be added for the debug one.

  3. Add a Run Script Phase to your target (inserting it after the existing Link Binary with Libraries phase, for example), and which will embed FLEX.framework in debug builds only:

    if [ "$CONFIGURATION" == "Debug" ]; then
      /usr/local/bin/carthage copy-frameworks
    fi
    

    Finally, add $(SRCROOT)/Carthage/Build/iOS/FLEX.framework as input file of this script phase.

Swift Package Manager

In Xcode, navigate to Build Settings > Build Options > Excluded Source File Names. For your Release configuration, set it to FLEX* like this to exclude all files with the FLEX prefix:

FLEX files added manually to a project

In Xcode, navigate to Build Settings > Build Options > Excluded Source File Names. For your Release configuration, set it to FLEX* like this to exclude all files with the FLEX prefix:

Additional Notes

Thanks & Credits

FLEX builds on ideas and inspiration from open source tools that came before it. The following resources have been particularly helpful:

Contributing

Please see our Contributing Guide.

TODO

FLEX (FLEXTool/FLEX)

Searching Database…

14.6K ·GitHub
这是什么?FLEX(Flipboard Explorer)是一套用于 iOS 应用内部的调试和探索工具。它会在正在运行的应用上方显示一个工具栏窗口,让你几乎可以检查和修改应用中的每一项状态。
这是我要添加到自己应用里的库,还是一个独立的应用?它是一个库,需要集成到你自己的 iOS 应用代码中,而不是一个可以直接安装到设备上的独立应用。
怎样把 FLEX 添加到我的项目里?可以通过 CocoaPods、Carthage、Swift Package Manager 添加,也可以手动把 Classes/ 中的文件或 FLEX/ 文件夹拖进你的 Xcode 项目。
使用 FLEX 需要什么版本的 iOS?你的应用需要以 iOS 9 或更高版本为目标。
我需要做什么特别的设置,才能让 FLEX 不出现在 App Store 的版本中?需要。你必须自己在 Release 版本中排除 FLEX(例如把集成代码包在 #if DEBUG 中,或者在 CocoaPods、Carthage 或 Xcode 的构建设置中只在 Debug 配置下启用),否则你的应用可能被拒审,或者把调试工具发给用户。
它同时支持 Objective-C 和 Swift 项目吗?支持两者。它使用 Objective-C 编写,但也支持 Swift Package Manager,并提供了专门的 Swift 集成方式。
使用 FLEX 的工具栏,我到底能检查或修改什么?你可以查看并修改正在运行的应用中几乎所有的状态,包括通过类似 JSON 的字符串设置实例变量、属性和 NSUserDefaults 条目的值。
FLEX 支持以 3D 方式浏览视图层级吗?支持。FLEX 4 包含一个 3D 视图浏览器,灵感来自 InAppViewDebugger 项目。
如果遇到意外的输入,FLEX 会让我的应用崩溃吗?不会。FLEX 会捕获其调用的函数在处理错误输入时抛出的异常,以避免崩溃。不过这也意味着,正在启用的异常断点可能会被意外触发。
目前是否支持 Swift 运行时的内省?暂不支持。Swift 类和 Swift 堆对象的内省仍列为待办事项(TODO)。
Creator
FLEXTool
Size
30.4 MB
Stars
14.6K
Age
12y
Commits · 90 Days