Alex Bollbach
Alex Bollbach

Reputation: 4600

Cannot import Cocoapod into Dynamic Framework

I am creating a project in Xcode8 which has a widget extension. I am trying to factor out my service API code (some class functions that hit a web API written in Swift) into a dynamic Framework.

I have created the Framework through the template and dragged my ServiceAPI.swift file/code to it. Made sure that the file was included in the framework target.

This code relies on SwiftyJSON to parse the JSON it gets from the web. Now, before moving the code into the framework, SwiftyJSON was compiled and running fine in my application target. After moving it I get a linker error:

ld: framework not found SwiftyJSON clang: error: linker command failed with exit code 1 (use -v to see invocation)

I have tried several things to fix it. I thought possibly setting the framework search paths might work but no paths I added fixed the issue.

So what can I do to fix this?

Upvotes: 0

Views: 298

Answers (1)

Alex Persian
Alex Persian

Reputation: 94

It looks like you are using cocoapods. In that case you can simply add your framework as a target for the Pod, SwiftyJSON. To do this simply edit your Podfile to include the second target.

target 'MyApplication' do
    pod 'SwifyJSON'
end

target 'MyFramework' do
    pod 'SwiftyJSON'
end

Upvotes: 2

Related Questions