{"id":29082189,"url":"https://github.com/xmartlabs/metalperformanceshadersproxy","last_synced_at":"2026-02-25T23:06:19.341Z","repository":{"id":62447752,"uuid":"97752144","full_name":"xmartlabs/MetalPerformanceShadersProxy","owner":"xmartlabs","description":"A proxy for MetalPerformanceShaders which takes to a stub on a simulator and to the real implementation on iOS devices.","archived":false,"fork":false,"pushed_at":"2018-09-18T14:05:52.000Z","size":166,"stargazers_count":47,"open_issues_count":0,"forks_count":4,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-27T20:03:43.143Z","etag":null,"topics":["device","ios","metal","metalkit","metalperformanceshaders","proxy","simulator","stub"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xmartlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-19T19:09:19.000Z","updated_at":"2025-02-11T22:32:13.000Z","dependencies_parsed_at":"2022-11-01T23:17:49.865Z","dependency_job_id":null,"html_url":"https://github.com/xmartlabs/MetalPerformanceShadersProxy","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/xmartlabs/MetalPerformanceShadersProxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2FMetalPerformanceShadersProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2FMetalPerformanceShadersProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2FMetalPerformanceShadersProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2FMetalPerformanceShadersProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmartlabs","download_url":"https://codeload.github.com/xmartlabs/MetalPerformanceShadersProxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmartlabs%2FMetalPerformanceShadersProxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262324922,"owners_count":23293750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["device","ios","metal","metalkit","metalperformanceshaders","proxy","simulator","stub"],"created_at":"2025-06-27T20:03:37.962Z","updated_at":"2026-02-25T23:06:19.315Z","avatar_url":"https://github.com/xmartlabs.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MetalPerformanceShadersProxy\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://travis-ci.org/xmartlabs/MetalPerformanceShadersProxy\"\u003e\u003cimg src=\"https://travis-ci.org/xmartlabs/MetalPerformanceShadersProxy.svg?branch=master\" alt=\"Build status\" /\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/platform-iOS-blue.svg?style=flat\" alt=\"Platform iOS\" /\u003e\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg src=\"https://img.shields.io/badge/swift4-compatible-4BC51D.svg?style=flat\" alt=\"Swift 4 compatible\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\" alt=\"Carthage compatible\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org/pods/XLActionController\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/MetalPerformanceShadersProxy.svg\" alt=\"CocoaPods compatible\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://raw.githubusercontent.com/xmartlabs/MetalPerformanceShadersProxy/master/LICENSE\"\u003e\u003cimg src=\"http://img.shields.io/badge/license-MIT-blue.svg?style=flat\" alt=\"License: MIT\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nBy [Xmartlabs SRL](https://xmartlabs.com)\n\nA proxy for **MetalPerformanceShaders** (and dependents) which takes to a **stub on a simulator** and to the **real implementation on a device**. It works both for Swift and Objective-C.\n\nIt's usually a problem not to be able to **compile** for a simulator target when using Metal shaders. By using this proxy, you are being able to compile and to *run* on simulators. Note that trying to run the Metal shaders on a simulator will fail. Nevertheless, it allows a project that implements Metal shaders to:\n\n* Upload a pod to CocoaPods.\n* Make a framework to work with Carthage.\n* Run an app on a simulator to use features that don't depend on Metal shaders.\n* Compile unit tests.\n* Test automatically (maybe with a CI server) with simulators the parts of an app that don't depend on Metal shaders.\n\n## Usage\n\nIf you use Metal, you probably use `CVMetalTexture.h` and `CVMetalTextureCache.h` from `CoreVideo` or `CAMetalDrawable.h` from `QuartzCore`. But they are not available when targetting the simulator. To make them available, just do:\n\n```swift\nimport MetalPerformanceShadersProxy\n```\n\nThis pod will add **no stub** to devices (**no footprint!**), as the proxy uses preprocessor macros to decide which implementation to use.\n\nNote that if a stub method is called, a exception will be thrown.\n\n### currentDrawable from MTKView\n\n`currentDrawable` property of `MTKView` is of type `CAMetalDrawable` in the device but of type `MTLDrawable` in the simulator. So you need to cast it in your code to use it properly. E.g., if you have\n\n```swift\nlet texture = view.currentDrawable.texture\n```\n\nchange it to\n\n```swift\nlet texture = (view.currentDrawable as? CAMetalDrawable)?.texture\n```\n\nThis is the best workaround we came up with. If you happen to have a better idea, please open an issue.\n\n### Advanced: Control when to use the stub\n\nIf for some reason you want to control when to use the stub, you can import the stub like:\n\n```swift\n#if condition\n    import MetalPerformanceShadersStub\n#endif\n```\n\n## How it was created\n\nSee [CREATION](CREATION.md) for an explanation.\n\n## Requirements\n\n* iOS 9.0+\n* Xcode 9.0+\n\nTo use with previous Xcode versions, see previous releases.\n\n## Getting involved\n\n* If you **want to contribute** please feel free to **submit pull requests**.\n* If you **have a feature request** please **open an issue**.\n* If you **found a bug** or **need help** please **check older issues before submitting an issue.**.\n\nIn particular, if you find a missing Metal-dependent framework, open an issue or better submit a pull request :smile:\n\nBefore contribute check the [CONTRIBUTING](https://github.com/xmartlabs/MetalPerformanceShadersProxy/blob/master/CONTRIBUTING.md) file for more info.\n\nIf you use **MetalPerformanceShadersProxy** in your app, we would love to hear about it! Drop us a line on [Twitter](https://twitter.com/xmartlabs).\n\n## Examples\n\nFollow these 3 steps to run Example project: clone MetalPerformanceShadersProxy repository, open MetalPerformanceShadersProxy workspace and run the *Example* project.\n\nAs a real example, you can check out the [Bender](https://github.com/xmartlabs/Bender) library.\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](https://cocoapods.org/) is a dependency manager for Cocoa projects.\n\nTo install MetalPerformanceShadersProxy, simply add the following line to your Podfile:\n\n```ruby\npod 'MetalPerformanceShadersProxy', '~\u003e 0.3'\n```\n\nIf you just want the stub:\n\n```ruby\npod 'MetalPerformanceShadersProxy/Stub', '~\u003e 0.3'\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a simple, decentralized dependency manager for Cocoa.\n\nTo install MetalPerformanceShadersProxy, simply add the following line to your Cartfile:\n\n```ogdl\ngithub \"xmartlabs/MetalPerformanceShadersProxy\" ~\u003e 0.2\n```\n\n## Author\n\n* [Xmartlabs SRL](https://github.com/xmartlabs) ([@xmartlabs](https://twitter.com/xmartlabs))\n\n## Changelog\n\nIt can be found in the [CHANGELOG](CHANGELOG.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmartlabs%2Fmetalperformanceshadersproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmartlabs%2Fmetalperformanceshadersproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmartlabs%2Fmetalperformanceshadersproxy/lists"}