# 源码补丁

In order to start analyzing and managing an iOS app without jailbreak, the app's source code itself needs to be patched to load the FridaGadget.dylib on start. In these cases, you can simply load the FridaGadget.dylib as part of the Xcode project and deploy it on an iOS device or simulator.

## Add FridaGadget.dylib to project

To add FridaGadget.dylib to project in XCode:

* Create a Frameworks folder in the project root.

  ```bash
  $ mkdir Frameworks
  $ cd Frameworks
  ```
* Download FridaGadget.dylib from [here](https://github.com/frida/frida/releases) and extract it.

  ```bash
  $ curl -Lo FridaGadget.dylib.xz https://github.com/frida/frida/releases/download/<version>/frida-gadget-<version>-ios-universal.dylib.xz
  $ unxz FridaGadget.dylib.xz
  ```
* Go to the project's root and select the `Build Phases`, find the section title `Link Binary With Libraries` and drag the dylib from the Frameworks folder on the left of Xcode to the existing list.

![xcode-link-dylib](https://2241975275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7lonY2zgW7DNoIQMqYtw%2Fuploads%2Fgit-blob-3cae679ef1ddc62a377212d7cc3bf0e8ddb8dc13%2Fxcode-link-dylib.png?alt=media)

* Go to the project's root and select the `General`, find the section title `Frameworks, Libraries, and Embedded Content` and set FridaGadget.dylib in the `Embed` column to `Embed & Sign`.

![xcode-embed-sign-dyli](https://2241975275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7lonY2zgW7DNoIQMqYtw%2Fuploads%2Fgit-blob-27c495b3a8badd348f7bd52e7232a1e9daa76ece%2Fxcode-embed-sign-dylib.png?alt=media)

## Build & Deploy

You can now build the project and deploy it to an iOS device or simulator.

![xcode-deploy-console-output](https://2241975275-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7lonY2zgW7DNoIQMqYtw%2Fuploads%2Fgit-blob-8c84c593911062b529d33c5bfbeb69c043239e06%2Fxcode-deploy-console-output.png?alt=media)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.cdxiaodong.life/ios-ying-yong-an-quan/ru-men-zhi-nan/source-patching.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
