简体   繁体   中英

How to import AppDelegate.h from another Framework in Xcode

I have a framework called "MyFramework.xcodeproj" that is added to my main project. Within this framework, I'm working on a file that needs a reference to my AppDelegate.h file. It isn't able to locate it, and when I try to add the file from "Build Phases" in "Compile Sources" it isn't able to find it there either. How can I get the reference to this file?

Your framework should ideally be separate from any application delegate logic. However, if you do need access to it, you can simply cast the shared application delegate to AppDelegate .

(AppDelegate *)[[UIApplication sharedApplication] delegate];

Just copy AppDelegate 's @interface and put it somewhere visible in your framework. AppDelegate.m does not need to be there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM