Skip to content
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

Swift framework dependencies are currently not supported #115

Open
bobrosoft opened this issue Dec 3, 2015 · 20 comments
Open

Swift framework dependencies are currently not supported #115

bobrosoft opened this issue Dec 3, 2015 · 20 comments
Labels
Milestone

Comments

@bobrosoft
Copy link

Hi there!

I recently installed cocoapods-packager and trying to pack my Swift Framework. If I correctly understand from #56 it's supported, right?

I'm getting this:

bash-3.2$ pod package CBSDKCore.podspec --force
Analyzing dependencies
Fetching podspec for `CBSDKCore` from `CBSDKCore.podspec`
Downloading dependencies
Installing CBSDKCore (0.0.1)
Installing SwiftAddressBook (0.5.0)
[!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile or target to opt into using it. The Swift Pods being used are: CBSDKCore and SwiftAddressBook

for that podspec

Pod::Spec.new do |s|
    s.name = 'CBSDKCore'
    s.version = '0.0.1'
    s.license = 'MIT'
    s.summary = 'Summary'
    s.homepage = 'http://example.com'
    s.authors = { 'Author' => 'info@example.org' }
    s.source = { :git => 'https://github.com/....git', :branch => 'develop' }

    s.platforms = { :ios => '8.0' }
    s.ios.deployment_target = '8.0'

    s.source_files = 'CBSDKCore/**/*.{swift,h,m}'

    s.frameworks = 'AddressBook'
    s.ios.dependency 'SwiftAddressBook', '~> 0.5'
    s.requires_arc = true
end

I don't understand about what Podfile is it talking about? It generates own Podfile to install all dependencies? My Podfile in my repo of course contain use_frameworks! inside it or I couldn't install Swift dependencies I need for develop.

@neonichu
Copy link
Member

neonichu commented Dec 3, 2015

I think #99 never considered Swift dependencies, so your setup is currently not supported.

@neonichu neonichu changed the title Error when trying to pack Swift Framework: add "use_frameworks!" to your Podfile Swift framework dependencies are currently not supported Dec 3, 2015
@neonichu neonichu added the bug label Dec 3, 2015
@neonichu neonichu added this to the Release 2.0 milestone Dec 3, 2015
@bobrosoft
Copy link
Author

Mmm, ok. So, to summarize:

  • packing of Swift frameworks are not supported
  • packing of frameworks with Swift dependencies are not supported

Correct? Or first is possible if no external Swift dependencies are used?

@neonichu
Copy link
Member

neonichu commented Dec 3, 2015

I think the first should be possible, as long as all dependencies are ObjC.

@ExoticObjects
Copy link

"packing of frameworks with Swift dependencies are not supported"

Any thoughts on if/when this will be supported? Not having this functionality is adding a good deal of extra work packaging up my library.

@neonichu
Copy link
Member

Personally, I cannot devote time for substantial feature work on cp-packager at the moment. I would happily provide assistance if you or someone else wants to work on a PR, though.

@ExoticObjects
Copy link

Can you elaborate a bit on what would be required to implement this feature? Are there reasons why it's especially difficult? For example, I know that name mangling is different and probably more difficult to deal with in Swift. I imagine that would come into play...

Some brief thoughts on what would need doing might help us decide if we should attempt this or not.

@neonichu
Copy link
Member

neonichu commented Mar 1, 2016

Dependencies would need to be build as dynamic frameworks, instead of static libs and the lipo commands would likely need some adjusting.

What I am currently unsure about is how modules would behave, since there's an assumed 1-to-1 mapping between frameworks and modules, but each Swift-based Pod would be its own module. I would suggest to start by trying to vendor a very simple Swift framework into another one manually using lipo and see how this would be to be done.

@satyamub
Copy link

@neonichu I have made a Library ported to cocoapod and which has few third party frameworks included.. I am able to get those framework referenced when user install my pod. what I am achieving is to create a library from that cocoapod. I am getting this above error message when I try to package the cocoapod. I made the example/ source lib in Swift. Is that the cause of the problem, I can make Objective c code and attach to it with objective samples, will it resolve the issue or did you find any resolution to it without converting to Objective C code.

@mohemian-92817281
Copy link

Any recent developments regarding this issue?

@XZoscar
Copy link

XZoscar commented Jun 8, 2016

I have the same problem.

@fuxx
Copy link

fuxx commented Jul 27, 2016

Same for me. Any status about this?

@neonichu
Copy link
Member

See this comment, unless someone from the community contributes a PR, this will remain unimplemented, unfortunately.

@mdsb100
Copy link

mdsb100 commented May 31, 2017

any news?

@kadapps
Copy link

kadapps commented Jul 5, 2017

Same Problem.

@danielfcodes
Copy link

Any update on this? I have the same problem

@segiddins
Copy link
Member

As Boris previously posted:

See this comment, unless someone from the community contributes a PR, this will remain unimplemented, unfortunately.

@zhihuitang
Copy link

any volunteer?......no

@zhihuitang
Copy link

zhihuitang commented Oct 16, 2017

since the packager doesn't support Swift framework, maybe you can try this solution:
Hide implementation of swift framework when distributing

@bryanboyko
Copy link

I don't have the time or the Ruby skills to look into this right now, but I'd like to add that I just came across the same error

@sirghi
Copy link

sirghi commented Oct 11, 2018

I also lack the skill to implement something here, but while debugging, I noticed that the xcconfigs generated in the Pods project contained some bogus OTHER_CFLAGS and OTHER_SWIFT_FLAGS, namely around module map file locations that weren't correct:

OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/MyFramework/MyFramework.modulemap"
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" -Xcc -fmodule-map-file="${PODS_CONFIGURATION_BUILD_DIR}/MyFramework/MyFramework.modulemap" -import-underlying-module"

Removing them made the packaging pass for a simple one-file swift framework.
However, after referencing UIKit classes, they started not being recognized:

/Users/xxx/Desktop/my-sdk-ios/MySDK/My.swift:92:57: error: use of undeclared type 'UIApplication'
    public func registerForRemoteNotifications(for app: UIApplication) {
                                                        ^~~~~~~~~~~~~

Hope this helps in getting the ball rolling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests