> For the complete documentation index, see [llms.txt](https://gitbook.cdxiaodong.life/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.cdxiaodong.life/ios-ying-yong-an-quan/ru-men-zhi-nan/source-patching.md).

# 源码补丁

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](/files/tniGRPHxwZ8e3AHsj3Ca)

* 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](/files/Zojc70CsspLQkioO1LiR)

## Build & Deploy

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

![xcode-deploy-console-output](/files/6ElRa3WS5u9LHwHRpRZz)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
