Pods-Alamofire: Swift is not supported for static libraries - ios

I have a project running on Swift 1.2 and iOS 8.4.
After the update to Swift 2 and iOS 9, I did "pod update" to update my pods.
Now there is an Pods-Alamofire error: "Swift is not supported for static libraries."
Any ideas how to fix this?

If you are using cocoapods, make sure that you are using the right version of Alamofire
pod 'Alamofire', '~> 2.0' //2.0 is currently the latest version
Also make sure you are using use_frameworks! so your Profile should look like this:
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 2.0'
The use_framworks! part tells CocoaPods that your project is using frameworks instead of static libraries.
In order to use Pods written in Swift, you must explicitly include use_frameworks! to opt into using frameworks. If you forget to include this, and CocoaPods detects you’re trying to use a Swift CocoaPod, you’ll get an error when you try to install the pods.
If you’ve only ever programmed in Swift, this may look a bit strange − that’s because the Podfile is actually written in Ruby. You don’t need to know Ruby to use CocoaPods, but you should be aware that even minor text errors will typically cause CocoaPods to throw an error.
Credit: Ray Wenderlich

Add use_frameworks! below platform on your pod file. This way your pod will be added as framework and not as static library

Related

How to remove use_frameworks! AND keep using swift pods on an objective-c project?

our project is an Objective-c project.
Since we're using react-native-firebase we can't use use_frameworks! in cocoapods any more.
The problem is we have a swift pod dependency (PromiseKit) and to use swift dependencies we must use use_frameworks! as far as I understand.
What I'm trying to do is have the best of both worlds, aka:
remove use_frameworks! so that react-native-firebase works AND
keep the PromiseKit swift dependency.
current Podfile:
platform :ios, '10.0'
target 'TestApp' do
use_frameworks!
# swift pod
pod 'PromiseKit'
# react-native-firebase
pod 'Firebase/Core', '~> 5.3.0'
pod 'Firebase/DynamicLinks', '~> 5.3.0'
pod 'Firebase/Messaging', '~> 5.3.0'
end
I noticed there's this command :modular_headers => true or use_modular_headers which I sense may or may not be relevant to the solution I'm looking for since Cocoapods 1.5 but I can't seem to connect the dots.
Edit:
If I remove use_frameworks! (even if I replace it with use_modular_headers!) I get this error:
Any help please?
Replace use_frameworks! with use_modular_headers! in the Podfile.
From the CocoaPods 1.5 release note referenced:
With CocoaPods 1.5.0, developers are no longer restricted into
specifying use_frameworks! in their Podfile in order to install pods
that use Swift. Interop with Objective-C should just work. However, if
your Swift pod depends on an Objective-C, pod you will need to enable
"modular headers" (see below) for that Objective-C pod.
With CocoaPods 1.9.0, it is now possible to build frameworks both statically and dynamically. Use use_frameworks! :linkage => :static
I have also faced this issue. and find a perfect solution for this.
https://github.com/joncardasis/cocoapods-user-defined-build-types
this is a plugin for cocoapods by which we can specify to use "dynamic framework" (i.e. what "use_framework" does) on a particular pod. this feature is not currently supported in cocoapods, that is why use this plugin to resolve your issue.
I ran into a similar issue last week, so I created a basic project where I'm using Swift, Firebase but not use_frameworks!, instead using bridging headers.
Don't know if people are still having issues with this, let me know if it helps. https://github.com/jenshandersson/React-Native-Swift

How to integrate both Objective-C and Swift pods in same project in iOS app

I am doing Objective-C in iOS app. But the problem is I want to add few Objective-C apis into that I added successfully earlier with cocoa pods, But, now I want to add Swift Api through cocoa pods, but the problem getting while installing is following.
[!] 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: apis
But I can't add this manually due to its large api and it contains sub folders.
But, if I remove "#" key from use_frameworks!, its getting installed, but, the old Objective-C apis getting file not found in my project.
Even I have very basic knowledge at installing frameworks/apis through cocoa pods.
Can any one suggest me how to over come this.
use_frameworks! will work with Objective-C pod only if they are dynamic frameworks not static libraries. Most of the popular third party libraries are using dynamic frameworks like AFNetworking, GoogleMaps etc.
Make sure all your Objective-C pods are dynamic frameworks. If you are not sure just create a sample project with cocoapods and use use_frameworks!. Try adding one by one, all the pods and find out which one is the culprit.
I had that problem once, what I did was use use_frameworks! like you mentioned, and then I changed how the Objective-C imports are written.
The command use_frameworks! turns each pod into a Framework, so in your projects the .h and .m files are no longer visible to the import like they would usually.
As a result, instead of using for example #import <AFNetworking/AFNetworking.h>, you do #import AFNetworking;
From my own experience, and maybe it was just a special case for my project. But turning everything into frameworks slowed down the compile time on Xcode and it made my App Package bigger for some reason.
Podfile file:
platform :ios, '10.0'
use_frameworks!
def pods
pod 'Alamofire', '= 4.4'
pod 'SwiftyJSON' '= 3.1.4'
pod 'MBProgressHUD'
end
target 'YourProject' do
pods
end
YourProject-Bridging-Header.h
#import <MBProgressHUD/MBProgressHUD.h>
Build Settings

Unable to pod install with multiple Library

I am trying to add multiple library using pod setup, but unfortunate not success.
My Pod Setup
platform :ios, "8.0"
use_frameworks!
target 'Demo Cluster' do
pod 'GoogleMaps'
pod 'GooglePlaces'
pod 'Google-Maps-iOS-Utils'
pod 'Alamofire', '~> 3.4'
end
I get This Error
Until GoogleMaps is released as a dynamic framework, you can only support it as a transitive dependency as a library. However, as you are using a swift framework - you can't support that either. Your best option is to request Google release their libraries as a dynamic framework.
You can try to download them manually and insert them but I think it will not work neither.
I suggest you to read this discussion.
From this dicussion:
Until GoogleMaps is released as a dynamic framework, you can only
support it as a transitive dependency as a library. However, as you
are using a swift framework - you can't support that either. Your best
option is to request Google release their libraries as a dynamic
framework I'm afraid.

Why is there an error in swift grammar

The tool involved is Xcode7.2, which is installed using CocoaPod
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 3.0'
However, there is a large number of compilation errors as shown in the picture. Can I ask why are these errors?
The #selector special form was added in Swift 2.2, which is shipped with Xcode 7.3. You're using Xcode 7.2. You need to either upgrade Xcode, or use a slightly older version of AlamoFire.

Could not build Objective-C module 'zipzap'

I would like to use zipzap library in my swift ios project.
I use cocoapods to integrate it. When I run pod install everything works fine, but when I do import zipzap, it says Could not build Objective-C module 'zipzap'.
I've done everything that people recommend here and in similar questions. But no luck.
Is it possible that this library simply not compatible with swift-based projects?
This is my Podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target 'MyProject-iOS' do
pod 'Reachability', '~> 3.2'
pod 'SwiftyJSON', '~> 2.1'
pod 'zipzap', '~> 8.0'
end
target 'MyProject-iOSTests' do
end
I faced the same issue. Looks like the podspec for zipzap is missing. Due to which pod ends up making all header files public. And that is what causes the issue.
I wrote my own podspec file which only makes five headers public, rest are private. This decision was based on the podspec.json found in the zipzap repo.
I included zipzap in my project as follows:
pod 'zipzap', :podspec => 'https://raw.githubusercontent.com/tahasamad/zipzap/master/zipzap.podspec'
I'm the author of ZipZap. Version 8.0.4 now properly supports iOS and OS X frameworks, both with and without CocoaPods. After updating with CocoaPods, you should just be able to import ZipZap in Swift and "it just works".
In order to get correct exception handling, you'll have to use CocoaPods 0.36 or later, otherwise you may get some build warnings.

Resources