My iOS app contains both objective-C and Swift code. Now i have added use_frameworks! at the top of pod file to use some swift library. Unfortunately it started giving compilation errors.
My pod version : 0.39.0
It started complaining about imports in bridge.h file
Pod file contains objective-C libraries. Now i want to add swift libraries.
How can i fix this issue. Let me know if needs more details
use_frameworks!
platform :ios, '9.0'
xcodeproj 'Test.xcodeproj'
def devDependecies
pod 'SocketRocket'
pod 'CocoaLumberjack'
pod 'MRProgress'
pod 'GRMustache', '~> 7.3.0'
pod 'Realm', '=0.96.2'
pod 'ADALiOS'
pod 'Office365/Outlook'
pod 'Office365/Discovery'
pod 'AFNetworking'
#https://github.com/youtube/youtube-ios-player-helper/issues/160
pod 'youtube-ios-player-helper', :git=>'https://github.com/youtube/youtube-ios-player-helper', :commit=>'head'
pod 'iOSCalendarEventParser', '=0.0.4'
pod 'OneDriveSDK'
end
target 'Test' do
devDependecies
end
Sample error in bridge.h file :
But this file exists under pod directory.
'youtube-ios-player-helper' can compile as a framework.
So remove it from the bridge header and just add an import line in your Swift classes
import youtube-ios-player-helper
Do the same for all pods that can compile as a framework
At this moment Xcode does not allow that. use_frameworks works only with swift pods or libraries. If you add an objective C library you need to use the bridging header, therefore you need to remove the use_frameworks instruction in order to make it work. The only work around I found is to only import through pods the objective C libraries and the swift libraries you can add them manually. You can copy the classes names and content and use them as if you would have created them.
Related
I was running my program softly and at some point (maybe closed the Xcode to reopen or updated pod file) it suddenly it can't compile anymore.
I already tried opening .xcodeproj and .xcworkspace. The first one shows this message when compiling:
The second case shows tons of issues:
This is my pod file:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'HonoluluArt' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# Pods for HonoluluArt
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 3.0'
pod 'GoogleMaps'
pod 'GooglePlaces'
end
Can I get any help? Thanks a lot!
try to clear pods and reinstall:
in the project folder execute: pod deintegrate
then clean pods: pod clean
Reinstall pods: pod install
this should work
also if you don't need in particular the v3 of Alamofire remove ~> 3 to install the latest version and modify your Podfile:
target 'HonoluluArt' do
use_frameworks!
pod 'Alamofire'
pod 'GoogleMaps'
pod 'GooglePlaces'
end
Alamofire ~> 3.0 is written in Swift 3. Podfile shows that this is an older codebase. You could try building you project with older version of Xcode (xCode 10.0 is last version supporting Swift 3) or you should upgrade Alamofire to actual version ~> 5.0 (you will also need to upgrade project codebase to newer Swift version).
You indicated you opened the project file and compiled. Cocoa Pod instructions clearly state after installing, you should only work in the .xcworkspace file thereafter. Can you open that and try a compile?
I just removed any reference to Alamofire. Pod file, imports, paths and stuff and it worked. I'm trying to manage the code once it is removed, but worked.
Thanks anyway!
Trying my hand at building a cocoapod and I need to include the SwiftKeyChainWrapper cocoapod as a dependency. I have the pod linked inside the .podSpec file but (1) I can't find a way to include it in the development pod whilst I build it to use methods and (2) when I run pod lib lint --verbose --no-clean --use-libraries I get the following error:
ERROR | [iOS] unknown: Encountered an unknown error (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: SwiftKeychainWrapper
Inside the pod project I have the following:
platform :ios, '11.0'
use_frameworks!
target 'MyPod_Example' do
pod 'MyPod', :path => '../'
target 'MyPod_Tests' do
inherit! :search_paths
end
end
And the dependency is listed:
s.dependency 'SwiftKeychainWrapper'
Thanks
--use-libraries is the flag to use static libraries instead of dynamic frameworks, you should remove it from your lint command to make it work as a framework.
Is there a way to install this library without cocoapods ? because when i install it with pod i get this error :
[!] 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:
CryptoSwift and JSONWebToken
And when i add 'use_framewords!' i got error on the other libraries written with objective-c that use pod also
Here is my podfile :
source “https://github.com/CocoaPods/Specs.git”
platform :ios, '8.1'
pod 'GoogleMaps'
pod 'RSKImageCropper'
pod 'AFNetworking', '~> 3.0'
pod 'DZNEmptyDataSet'
pod 'Instabug'
Thank's in advance
You can drag and drop the
link
sources into your project. If you add the library in this way, you
will update the library manually as you know.
The second option is using cocoapods and solving the problem. When you use use_frameworks! cocoapods tries to convert the whole pods as framework, so the error should be in your bridging header. Try to import your frameworks in your files.
I want to use this Objective C pod in my Swift project : EAIntroView
I found in this SO answer :
Cocoapods 0.36 and above introduces the use_frameworks! instruction
which implies that the bridging header is not required for importing
Objective-C pods in Swift.
but I can't import EAIntroView and use the code of the Library
Here is my pod file
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
use_frameworks!
target 'PROJ' do
pod 'Koloda', '~> 2.0.3'
pod 'EAIntroView'
end
target 'PROJTests' do
end
target 'PROJUITests' do
end
Cocoapods compiled it as framework, try to use #import EAIntroView
I have just started a new Swift project and I would like to use different libraries. In particular, I would like to use Realm.io, an Obj-C library. But, I would also like to use pure Swift libraries such as Alamofire or Dollar.
I use Cocoapods for managing my dependencies. I use the latest version (0.37.0) and the new use_frameworks! flag. pod install is successful anytime.
Unfortunately, when I try to build my project I get two errors (for my main target):
Umbrella header Realm.h not found from module.modulemap
Could not build Objective-C module Realm from any file using import Realm
Other imports work fine.
I have noticed the following: if I remove pure Swift libs and use_frameworks, everything works fine. I am aware about this current issue from Cocoapods. However, it should not be a problem for Realm asks developers to use that flag.
Here is my Podfile:
platform :ios, '8.0'
use_frameworks!
target 'rothrock' do
pod 'Realm'
pod 'Cent'
pod 'SwiftyJSON'
pod 'Alamofire'
end
target 'rothrockTests', :exclusive => true do
end
I use no bridging header. Should I?
Any idea or workaround?
Alright, here is the full walkthrough:
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
You need a bridging header and import your Objective-C library headers there.
If you are using only Realm you can check out this documentation for Swift http://realm.io/docs/cocoa/ (go to CocoaPods down in the tabs)
Swift
Install CocoaPods 0.36.0 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'Realm' to your app target.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!
Download the latest release of Realm and extract the zip.
Drag the file at Swift/RLMSupport.swift into the File Navigator of your Xcode project, checking the Copy items if needed checkbox.
I just installed the Realm library in a project I have with some of the libraries you mention above like Alamofire and SwiftyJSON and others and it works fine when you build the project and even put the import Realm, no compilation errors at all.
I'm using Cocoapods 0.36.0, the stable version and this is my PodFile :
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
link_with 'ApiWorkflow', 'ApiWorkflowTests'
pod 'SwiftyJSON', '~> 2.2'
pod 'Alamofire', '~> 1.2'
pod 'Typhoon', '~> 3.0'
pod 'SwiftCSV', '~> 0.1'
pod 'Realm'
I hope this help you