Skip to content

Repository files navigation

WLOC — Apple 开发者定位测试工具

中文 | English


中文

项目简介

WLOC 是一款面向 Apple 平台开发者的定位测试工具,主要用于在开发与 QA 环境中模拟不同地理位置,帮助开发者验证地图、区域化内容、位置触发逻辑及其他定位相关功能。

本项目包含一个 iOS 主应用和一个 Packet Tunnel Extension。它在用户明确授权并完成测试环境配置后,通过受限的网络定位响应重写流程提供测试位置。它不会直接修改 GPS 硬件读数,实际效果可能受到系统定位策略、GPS 信号、网络环境和系统缓存影响。

仅限授权测试: 本项目仅可用于你拥有或已获得明确授权的设备、应用、账号和网络。请勿将其用于欺骗服务、规避平台规则、伪造生产环境数据或任何未经授权的用途。

主要功能

  • 使用 SwiftUI 构建的 iOS 主应用。
  • 通过地图选点或手动输入设置测试坐标。
  • 支持 WGS-84 与中国大陆地图显示所需的 GCJ-02 坐标转换。
  • 使用 App Group 在主应用与 Packet Tunnel Extension 之间同步配置。
  • 提供 VPN 配置的创建、启动、停止、移除和诊断功能。
  • 在授权测试环境中处理指定的网络定位响应。
  • 本机生成测试 CA,并要求用户手动安装和信任测试证书。
  • 对 Host、端口、路径和响应格式执行严格匹配,避免无边界处理流量。

系统要求

  • iOS 16 或更高版本。
  • 能够打开并构建本工程的 Xcode 版本。
  • Apple Developer 账号及可用于 Network Extension 的签名权限。
  • 一台真实 iOS 测试设备。模拟器无法完整验证 Packet Tunnel、VPN 配置、证书信任和真实定位行为。

签名与安装说明

由于应用内置 Packet Tunnel Extension,主应用和 Extension 都必须使用包含对应权限的签名配置。通常需要:

  • 为主应用和 Packet Tunnel Extension 分别配置唯一的 Bundle Identifier。
  • 为两个 Target 配置一致的 App Group。
  • 为对应 App ID 启用 Network Extensions / Packet Tunnel Provider 能力。
  • 使用包含上述 entitlement 的有效 Provisioning Profile。
  • 确保主应用中记录的 Provider Bundle Identifier 与 Extension 的 Bundle Identifier 完全一致。

仅使用 P12 证书进行普通重签通常无法补充 Apple Developer Portal 未授权的 Network Extension entitlement。因此,这类安装包可能无法安装、无法保存 VPN 配置,或无法启动 Packet Tunnel 和定位测试功能。

构建

  1. 使用 Xcode 打开 WLOC.xcodeproj
  2. 为主应用和 Packet Tunnel Extension 选择你自己的开发团队。
  3. 修改 Bundle Identifier、App Group 和 Provider Bundle Identifier,使它们保持一致。
  4. 在 Signing & Capabilities 中确认 App Groups 和 Packet Tunnel Provider 权限已正确配置。
  5. 选择真实测试设备并构建运行。

如果你的开发者账号或 Provisioning Profile 不包含 Network Extension 权限,普通源码编译可能成功,但真机上的 VPN 配置和 Packet Tunnel 仍会失败。

使用边界与免责声明

  • 本项目仅用于开发、QA、安全研究及其他已获授权的测试场景。
  • 只能测试你拥有或已获得明确授权的设备、应用、账号、服务和网络。
  • 不得关闭系统 TLS 校验、绕过证书固定或拦截未授权的第三方流量。
  • 测试设备不应长期信任测试 CA;测试结束后应移除测试证书和 VPN 配置。
  • 使用者需自行遵守所在地法律法规、Apple 开发者协议、平台规则和相关服务条款。
  • 本项目按“原样”提供,不对适用性、稳定性、安装结果或使用后果作任何保证。

致谢

感谢以下项目提供的思路、研究资料和社区实践:


English

Overview

WLOC is a location-testing tool for developers building software for Apple platforms. Its primary purpose is to simulate different geographic locations in development and QA environments, making it easier to test maps, regional content, location-triggered logic, and other location-related features.

The project contains an iOS host application and a Packet Tunnel Extension. After the user explicitly authorizes and configures the test environment, it provides a test location through a restricted network-location response-rewriting flow. It does not directly alter hardware GPS readings, and its behavior may be affected by system location policies, GPS signal strength, network conditions, and system caches.

Authorized testing only: Use this project only with devices, applications, accounts, and networks that you own or are explicitly authorized to test. Do not use it to deceive services, evade platform rules, falsify production data, or perform any unauthorized activity.

Features

  • A SwiftUI-based iOS host application.
  • Test-coordinate selection through a map or manual input.
  • WGS-84 and GCJ-02 conversion for map presentation in mainland China.
  • App Group configuration sharing between the host application and the Packet Tunnel Extension.
  • VPN configuration creation, start, stop, removal, and diagnostics.
  • Restricted network-location response processing in authorized test environments.
  • On-device generation of a test CA, with manual certificate installation and trust required from the user.
  • Strict matching of hosts, ports, paths, and response formats to prevent unbounded traffic processing.

Requirements

  • iOS 16 or later.
  • A version of Xcode capable of opening and building the project.
  • An Apple Developer account with signing permissions for Network Extensions.
  • A physical iOS test device. The Simulator cannot fully validate Packet Tunnel behavior, VPN configuration, certificate trust, or real-world location behavior.

Signing and Installation

Because the application includes a Packet Tunnel Extension, both the host application and the extension must be signed with profiles containing the required capabilities. In most cases, you must:

  • Assign unique Bundle Identifiers to the host application and Packet Tunnel Extension.
  • Configure the same App Group for both targets.
  • Enable Network Extensions / Packet Tunnel Provider for the corresponding App IDs.
  • Use valid Provisioning Profiles containing the required entitlements.
  • Ensure that the Provider Bundle Identifier stored by the host application exactly matches the extension's Bundle Identifier.

Ordinary re-signing with only a P12 certificate generally cannot add a Network Extension entitlement that has not been authorized through the Apple Developer Portal. Such a build may fail to install, fail to save its VPN configuration, or be unable to start the Packet Tunnel and location-testing functionality.

Building

  1. Open WLOC.xcodeproj in Xcode.
  2. Select your own development team for the host application and Packet Tunnel Extension.
  3. Update the Bundle Identifiers, App Group, and Provider Bundle Identifier so that they are consistent.
  4. Confirm that App Groups and Packet Tunnel Provider are correctly configured under Signing & Capabilities.
  5. Select a physical test device and build the project.

Source compilation may succeed even when your developer account or Provisioning Profile lacks the Network Extension capability. In that case, VPN configuration and Packet Tunnel startup will still fail on a physical device.

Authorized Use and Disclaimer

  • This project is intended only for development, QA, security research, and other explicitly authorized testing scenarios.
  • Test only devices, applications, accounts, services, and networks that you own or are explicitly authorized to test.
  • Do not disable system TLS validation, bypass certificate pinning, or intercept unauthorized third-party traffic.
  • A test device should not permanently trust a test CA. Remove the test certificate and VPN configuration after testing.
  • Users are responsible for complying with applicable laws, the Apple Developer agreements, platform policies, and relevant service terms.
  • The project is provided “as is,” without warranties regarding fitness, stability, installation, or the consequences of use.

Acknowledgements

Thanks to the following projects for their ideas, research materials, and community work:

About

WLOC is a location-testing tool for developers building software for Apple platforms. Its primary purpose is to simulate different geographic locations in development and QA environments, making it easier to test maps, regional content, location-triggered logic, and other location-related features.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages