New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use SVProgressHUD in an App Extension? #432
Comments
Okay... I've got it... first of all it has to be a preprocessor macro (that one was quite clear). More importantly it doesn't have to be defined in the App Extension target, but in the |
@MuscleRumble But if I manually modify Pods-SVProgressHUD target, it will get erase on next pos install. How you solve this problem. |
By using the
|
Thanks, it works. |
@MuscleRumble Have you managed to get this working using the latest version of Cocoapods? I'm getting the following when regenerating my workspace: Fixed it by renaming installer.project.targets to installer.pods_project.targets, but even though 'pod update' goes through fine, Xcode is now complaining that extensions can't access sharedApplication, meaning the preprocessor macro didn't register. |
I haven't tested the new version of CocoaPods yet, but I was also worried about Target Deduplication. It shouldn't affect App Extensions at all, but I haven't tested it yet. I'll try the latest version of CocoaPods out on my projects and get back to you. |
I actually might've solved it. I was using Pods-MyExtension-SVProgressHUD before as the target name, but I switched back to just using "SVProgressHUD" as the name, which seems to work with the latest Cocoapods. |
Alright, nice! :D Out of curiosity, do you have two Pod targets for SVProgressHUD or only one now? The thing is: I would like to have two targets, one for the main project, one for the extension. Because I wouldn't want to set |
I've defined a "shared" list of pods that includes SVProgressHUD, which I then include in both the main app target and the extension target (in the Podfile), like so: def shared
pod 'SVProgressHUD'
end
target 'MyApp' do
pod 'SomePod'
shared
end
target 'MyAppExtension' do
pod 'SomeOtherPod'
shared
end Previously in the post_install, I was looking for the SVProgressHUD pod that was exclusively built for my extension, then (and only then) setting the preprocessor macro. Now, with the changes to Cocoapods, it doesn't list target-specific pods anymore (no idea why), so I had to "globally" set SV_APP_EXTENSIONS in post_install. |
For some strange reason, I'm now getting duplicate symbols for each pod though, right after updating Cocoapods. |
Okay, so it turns out I just had to remove derived data, and remove any MyApp-PodName includes from Build Settings. Seems to compile now with the latest Cocoapods. |
Posted an issue on CocoaPods: CocoaPods/CocoaPods#3951 In short: I don't know how to set the preprocessor macro |
Just to keep everybody in the loop who's interested. I'm using now this pre_install do |installer|
pod_targets = installer.pod_targets.flat_map do |pod_target|
pod_target.name == "SVProgressHUD" ? pod_target.scoped : pod_target
end
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.pod_targets = pod_targets.select do |pod_target|
pod_target.target_definitions.include?(aggregate_target.target_definition)
end
end
end After that you can use the I think this is the best solution for now. It would be great if that "duplication enforcement" would be part of the Podfile DSL in future, but this is a CocoaPods issue. ;) |
Hi, we are aware of a problem regarding the Podfile (e.g. #449). It seems that the |
[Some APIs Are Unavailable to App Extensions](https://developer.apple.com/library/ios/documentation/Genera l/Conceptual/ExtensibilityPG/ExtensionOverview.html#//apple_ref/doc/uid/ TP40014214-CH2-SW6) According To Apple Doc: > Because of its focused role in the system, an app extension is ineligible to participate in certain activities. An app extension cannot: > Access a sharedApplication object, and so cannot use any of the methods on that object Test in my own app.We need the `NS_EXTENSION_UNAVAILABLE_IOS` make it available in App extension
In case anyone come across this issue, now you can simply do post_install do |installer|
installer.project.targets.each do |target|
if target.name == "SVProgressHUD-Pods-MyExtensionTargetName"
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'SV_APP_EXTENSIONS'
end
end
end
end Cocoapods will generate 2 seperated targets in Pods project, one with "SV_APP_EXTENSIONS" setup and one without it. |
Hello everybody! First thank you for tobihagemann help! By the way, if I use above configuration, spinner is running in app side, but not running in share extension side. Of course, in share extension side, any issue not happened, but spinner not running even though I configured additionally call setViewForExtension: from share extensions view controller with self.view. If I use only post_instll, spinner is only running in extension side, not running in app side. Below is my podfile:
I want to know how to showing spinner both of app and share extension side. |
Hello guys, since XCode 10, I'm getting duplicated issue in this solution. Do we have another solution for this? |
Not working for me guys :( |
any new solution here? |
I've read the short passage about how to use SVProgressHUD in an App Extension, but I'm still getting errors and I have no idea how to properly use the
SV_APP_EXTENSIONS
macro.I'm using CocoaPods and I'm not sure where I have to define that macro. Maybe it's easier to just look at this minimal project:
Any idea?
The text was updated successfully, but these errors were encountered: