How do you incorporate/access pod files (MMWormhole) in an extension?

236 views Asked by At

I'm trying to incorporate MMWormhole into my app (https://github.com/mutualmobile/MMWormhole).

I've added it to the pod file and installed it which has added to my workspace. My app itself is mostly in Objective-C and I can simply start to use wormhole by just adding #import anywhere I want to use it within the app itself without a problem.

But I also need to use it within a service extension (which is the whole point of the wormhole, to be used in an extension). I'm using a notification service extension which is in Swift and there is already a bridging header for accessing some shared obj-c code from the main app.

If I try to add #import <MMWormhole/MMWormhole.h> to the bridging header (or any variant of that such as "MMWorkhole.h") I get a file not found an error.

I downloaded the example wormhole app, but when I compile that it has a similar problem - in there it is being used within a today extension, but it fails to compile with the same error message (in TodayViewController.m". So I can't even build the example app.

I tried adding MMWormhole.framework to the Linked Frameworks and Libraries section of the extension target (BTW its not there in the wormhole example app) but get an error:

ld: framework not found MMWormhole
clang: error: linker command failed with exit code 1 

How is a pod file supposed to be installed/used in an extension?

1

There are 1 answers

0
Piepants On BEST ANSWER

I got it to work by adding the pod to both the main app and the extension, how to do that itself is not necessarily intuitive, so here's my pod file for anybody else in the same situation:

workspace 'MyWorkspace'
target 'My App' do
    use_frameworks!
    pod 'MMWormhole', '~> 2.0.0'
    ...


target 'My Extension' do
    use_frameworks!
    pod 'MMWormhole', '~> 2.0.0'
    project 'Path to the .xcodeproj'
end