CocoaPods / cocoapods-packager

CocoaPods plugin which allows you to generate a static library from a podspec.
Other
1.14k stars 220 forks source link

Swift framework dependencies are currently not supported #115

Open bobrosoft opened 8 years ago

bobrosoft commented 8 years ago

Hi there!

I recently installed cocoapods-packager and trying to pack my Swift Framework. If I correctly understand from https://github.com/CocoaPods/cocoapods-packager/issues/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 commented 8 years ago

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

bobrosoft commented 8 years ago

Mmm, ok. So, to summarize:

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

neonichu commented 8 years ago

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

ExoticObjects commented 8 years ago

"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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

Any recent developments regarding this issue?

XZoscar commented 8 years ago

I have the same problem.

fuxx commented 8 years ago

Same for me. Any status about this?

neonichu commented 8 years ago

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

mdsb100 commented 7 years ago

any news?

kadapps commented 7 years ago

Same Problem.

danielfcodes commented 7 years ago

Any update on this? I have the same problem

segiddins commented 7 years ago

As Boris previously posted:

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

jeffery812 commented 6 years ago

any volunteer?......no

jeffery812 commented 6 years ago

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

bryanboyko commented 6 years ago

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 commented 5 years ago

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