Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 292 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using 'vendored_frameworks' and 'source_files' for cocoapod using 'use_frameworks!'

#1
I'm building a cocoapod that basically contains a framework (private sources) and a view (open source) that rely on this framework, all made in Objective-C.

In the podspec I have the following lines :

```
spec.vendored_frameworks = 'MyPod/Framework/MyFramework.framework'
spec.source_files = ['MyPod/UI/Views/MyView.{h,m}']
```

When using the `use_frameworks!` syntax, I can't `#import MyFramework`

I just don't understand what's happening.

Moreover, when I remove the `spec.source_files` line, I can `#import MyFramework` and it works perfectly, but of course I cannot use `MyView`.

What am I doing wrong ?
Reply

#2
If you use `use_frameworks!` your pod itself will become a framework. Therefore you should `#import MyPod` instead of `#import MyFramework` and then use `MyView`.

Review also `public_header_files` in case you need it.
Reply

#3
Since the project's pods are now a framework, you could try [importing it as a module][1] using **`@import`**` MyFramework`.

However, if that doesn't work, then try backing up your project and then running `pod deintegrate && pod install`. Also, [this question][2] is very similar, and some of its comments and answers may be helpful.


[1]:

[To see links please register here]

[2]:

[To see links please register here]

Reply

#4
For anyone coming across this problem today: this is a known problem in CocoaPods, with a few issues raised on Github [here][1] and [here][2] discussing the problem.

The suggested workaround is to split your podspec into two: one podspec with only your `vendored_frameworks` and another podspec with only the `source_files` that use the framework.

User crsantos on Github has [helpfully posted][3] an example of this workaround, with two separate podspecs that I have reproduced below.

Vendored framework podspec:

<!-- language: lang-ruby -->

# Regarding

[To see links please register here]

Pod::Spec.new do |s|
s.name = 'SampleDynamicLibPod'
s.version = '0.0.1'
s.summary = 'SampleDynamicLibPod. Cool Story bro!'

s.description = <<-DESC
Blah Blah Blah Blah Blah description
DESC

s.homepage = 'https://github.com/crsantos/SameRepoForAllPodSpecsAndSource'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Carlos Santos' => '[email protected]' }
s.source = { :git => 'https://github.com/crsantos/SameRepoForAllPodSpecsAndSource.git', :tag => "#{s.name}-#{s.version.to_s}" }
# this is the way of tagging diferent podspecs on the same repo
# Dont't forget to tag your repo with `SampleDynamicLibPod-0.0.1` for this specific spec

s.module_name = 'SampleDynamicLibPod'

s.ios.deployment_target = '9.0'
s.platform = :ios, '9.0'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3' }

s.vendored_frameworks = 'SampleDynamicLibPod/Frameworks/SampleDynamicLib.framework'
end


Source files podspec. Note the dependency on the vendored framework podspec.

<!-- language: lang-ruby -->

# Regarding

[To see links please register here]


Pod::Spec.new do |s|
s.name = 'WrapperAroundSampleDynamicLibPod'
s.version = '0.0.2' # just a different number to avoid confusion with the other podspec
s.summary = 'WrapperAroundSampleDynamicLibPod. Cool Story bro!'

s.description = <<-DESC
Wrapper Around Sample Dynamic Lib Pod Blah Blah Blah Blah Blah Blah Blah Blah
DESC

s.homepage = 'https://github.com/crsantos/SameRepoForAllPodSpecsAndSource'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Carlos Santos' => '[email protected]' }
s.source = { :git => 'https://github.com/crsantos/SameRepoForAllPodSpecsAndSource.git', :tag => "#{s.name}-#{s.version.to_s}" }

# Dont't forget to tag your repo with `WrapperAroundSampleDynamicLibPod-0.0.2` for this specific spec

s.module_name = 'WrapperAroundSampleDynamicLibPod'

s.ios.deployment_target = '9.0'
s.platform = :ios, '9.0'
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3' }

s.source_files = 'WrapperAroundSampleDynamicLibPod/Classes/**/*'

s.dependency 'CocoaLumberjack/Swift'
s.dependency 'SampleDynamicLibPod', '0.0.1' # you can achieve this with "#{s.name}-#{s.version.to_s}" from the
end


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

Reply

#5
While shocking's answer is technically right there is a way to combine `source_files` and `vendored_frameworks`. The solution is to also use `preserve_paths` pointing to the location of the vendored frameworks.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through