test
Run iOS Xcode workspace or project tests to identify and report errors, enabling developers to validate code functionality within their development environment.
Instructions
Run test for the iOS Xcode workspace/project in the folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | The full path of the current folder that the iOS Xcode workspace/project sits |
Implementation Reference
- src/mcpxcodebuild/server.py:107-108 (handler)Handler logic specific to the 'test' tool: appends 'test' action to the xcodebuild command.if name == "test": command.append("test")
- src/mcpxcodebuild/server.py:77-81 (registration)Registers the 'test' tool in the list_tools function, specifying name, description, and shared input schema.Tool( name="test", description="Run test for the iOS Xcode workspace/project in the folder", inputSchema=Folder.model_json_schema(), )
- src/mcpxcodebuild/server.py:63-66 (schema)Pydantic model defining the input parameters (folder path) used by the 'test' tool schema.class Folder(BaseModel): """Parameters""" folder: Annotated[str, Field(description="The full path of the current folder that the iOS Xcode workspace/project sits")]
- src/mcpxcodebuild/server.py:83-120 (handler)Main handler function for tool execution, dispatches based on tool name ('test' or 'build'), sets up xcodebuild command, runs it, and returns output.@server.call_tool() async def call_tool(name, arguments: dict) -> list[TextContent]: try: args = Folder(**arguments) except ValueError as e: raise McpError(ErrorData(code=INVALID_PARAMS, message=str(e))) os.chdir(args.folder) xcode_project_path = find_xcode_project() project_name = os.path.basename(xcode_project_path) project_type = "" if xcode_project_path.endswith(".xcworkspace"): project_type = "-workspace" else: project_type = "-project" scheme = find_scheme(project_type, project_name) destination = find_available_simulator() command = ["xcodebuild", project_type, project_name, "-scheme", scheme, "-destination", destination] if name == "test": command.append("test") result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False).stdout lines = result.decode("utf-8").splitlines() error_lines = [line for line in lines if "error:" or "warning:" in line.lower()] error_message = "\n".join(error_lines) if not error_message: error_message = "Successful" return [ TextContent(type="text", text=f"Command: {' '.join(command)}"), TextContent(type="text", text=f"{error_message}") ]