To ensure that any project depending on it can use it, a class in an iOS framework must inherit from a class in its pod dependency. To achieve this, the header of the class needs to be made public. However, after doing so, Xcode generates an error stating that it cannot find the header file for the pod dependency when attempting to import headers.
I worked on an Xcode project called 'HelloTargetWithPod' that included a framework called 'Hello'. In my Podfile, I added the AFNetworking library as a dependency for the "Hello" target, using the following code:
platform :ios, '14.0'
target 'Hello' do
use_frameworks!
pod 'AFNetworking', '~> 4.0.1'
end
target 'HelloTargetWithPod' do
use_frameworks!
end
After running pod install
and closing "HelloTargetWithPod.xcodeproj", I opened "HelloTargetWithPod.xcworkspace".
Within the "Hello" framework, I created a public class called "MyImageDownloader" and imported the AFNetworking header file using the following code in "MyImageDownloader.h":
#import "AFNetworking/AFNetworking.h"
@interface MyImageDownloader : NSObject
// ...
@end
However, when I tried to compile the project, Xcode generated the error "'AFNetworking/AFNetworking.h' file not found".
In the meantime, there are two additional issues:
If MyImageDownloader.h is not set as public, the error does not occur.
Importing <AFNetworking/AFNetworking.h> in MyImageDownloader.m does not generate an error. Why does it generate an error in MyImageDownloader.h?
If MyImageDownloader.h is set as public and add the following code:
@class AFImageDownloader; NS_ASSUME_NONNULL_BEGIN @interface MyImageDownloader : AFImageDownloader @end NS_ASSUME_NONNULL_END
Xcode displays the error message "Attempting to use the forward class 'AFImageDownloader' as superclass of 'MyImageDownloader'".
I have uploaded the relevant project code to this Git repository.
This issue is similar to the Including a pod inside a framework target: file not found. I have tried the solutions provided, but they did not work.
I'm not sure how to resolve this issue, and I'd appreciate any help or advice.