在现有 iPhone 项目和 Watch Kit 扩展之间共享 类
Sharing classes between existing iPhone project and Watch Kit extension
我想分享一个 class "MyClass",我将其作为目标添加到 iPhone 项目,然后我向该项目添加了 Watch Kit 扩展目标。
每当我在 Watch Kit 扩展源代码中导入 "MyClass" 时,我得到:
Undefined symbols for architecture arm64: "_OBJC_CLASS_$_MyClass",
referenced from:
objc-class-ref in WKMyInterfaceController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with
exit code 1 (use -v to see invocation)
知道如何解决这个问题吗?这似乎是一个链接器问题所以我想我必须将 class MyClass 的源代码添加到 WatchKit Extension 应用程序的链接 libraries/headers 但我不确定是否有更好的方法来做到这一点.
您需要 select 为您的 MyClass 定位。
如果您正在使用 objective c 然后转到您的 MyClass 的 .m 文件和 select 目标也作为您的手表套件。
希望对您有所帮助。
我想分享一个 class "MyClass",我将其作为目标添加到 iPhone 项目,然后我向该项目添加了 Watch Kit 扩展目标。
每当我在 Watch Kit 扩展源代码中导入 "MyClass" 时,我得到:
Undefined symbols for architecture arm64: "_OBJC_CLASS_$_MyClass", referenced from: objc-class-ref in WKMyInterfaceController.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
知道如何解决这个问题吗?这似乎是一个链接器问题所以我想我必须将 class MyClass 的源代码添加到 WatchKit Extension 应用程序的链接 libraries/headers 但我不确定是否有更好的方法来做到这一点.
您需要 select 为您的 MyClass 定位。
如果您正在使用 objective c 然后转到您的 MyClass 的 .m 文件和 select 目标也作为您的手表套件。
希望对您有所帮助。