Search code examples
iosswiftuiuikitwatchkitwatchos

How to access class from iOS folder in watchOS App


How to access a data class which is in the iOS folder from the watchOS extension folder. If i want to access the class normally by calling my DataService i get this error:

enter image description here

This file I want to access:

enter image description here


Solution

    • Select DataService.swift file.
    • Then click on the top right navigation button to show inspectors.
    • Under "Show the file inspector," tick the target name for your watchOS extension.
    • This will share that particular file with the watchOS extension.