I need to add OpenTok 2.3 to a project that uses cocoapods, however only 2.1.7 is present in the pods repository or on github, so I have downloaded the framework locally. My folder structure looks something like this:
project-
|
Podfile
project.xcodeproj
frameworks/
|
OpenTokSDK-WebRTC.podspec
OpenTok-iOS-2.3.0/
|
OpenTok.framework
And the contents of the OpenTokSDK-WebRTC.podspec file is:
Pod::Spec.new do |s|
s.name = 'OpenTokSDK-WebRTC'
s.version = '2.3'
s.authors = 'TokBox'
s.summary = 'The OpenTok iOS SDK lets you use OpenTok video sessions in apps you build for iPad, iPhone, and iPod touch devices.'
s.homepage = 'https://github.com/opentok/opentok-ios-sdk-webrtc/'
s.license = {
:type => 'Apache'
}
s.source = {
:path => './OpenTok-iOS-2.3.0'
}
s.platforms = {
:ios => '5.0'
}
s.source_files = 'Opentok.framework/Versions/A/Headers/*.h'
s.resources = 'Opentok.framework/Versions/A/Resources/opentok.bundle'
s.frameworks = [
"Opentok",
"UIKit",
"CoreMedia",
"CoreVideo",
"CoreAudio",
"CoreTelephony",
"CFNetwork",
"AVFoundation",
"SystemConfiguration",
"Security",
"QuartzCore",
"AudioToolbox",
"OpenGLES",
"MobileCoreServices"
]
s.libraries = [
"stdc++",
"z"
]
s.xcconfig = {
:FRAMEWORK_SEARCH_PATHS => "\"frameworks/OpenTokSDK-WebRTC/\""
}
s.preserve_paths = 'Opentok.framework'
s.requires_arc = false
end
The relevant line in the Podfile is
pod 'OpenTokSDK-WebRTC', :path => "frameworks"
When I run 'pod install' everything appears to run fine, however there is no OpenTokSDK folder in the Pods directory and I get a file not found error in xcode when trying to include . Does anyone know what I am missing?
Thanks for your help.
As I found on their Blog Here is the link new-in-ios-10-the-best-webrtc-apps-yet. you need to Add pod 'OpenTok' in your pod file. So updated version of talk box is Added in your Project. and Now Open your xcworkspace file inplace of xcodeproj file .
Here is my Podfile ,
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
pod 'AFNetworking', '~> 3.0'
pod 'OpenTok'
# Pods for ProjectName
target 'ProjectNameTest' do
inherit! :search_paths
# Pods for testing
end
target 'ProjectNameUITests' do
inherit! :search_paths
# Pods for testing
end
end
Note :- If you are using Swift then please uncomment # use_frameworks!
After updating your pod file enter "pod install" command in your terminal. and Tokbox will successfully install in your project.
Related
I'm having trouble using a framework I wrote in other targets (the same project) using modular imports. I'm using Cocoapods. I'm getting Could not build module: errors while trying to import the module using modular imports (#import CMPComapiFoundation;). I attach a link to the repo for more information.
I did try both local (:path =>) and remote (:git =>) ways of pulling the SDK in Podfile, none of which seems to work. It's worth noting that if added via Cocoapods in a separate project, the code compiles and the SDK can be imported.
SDK's .podspec file:
Pod::Spec.new do |s|
s.name = 'CMPComapiFoundation'
s.version = '1.2.2'
s.license = 'MIT'
s.summary = 'Foundation library for connecting to and consuming COMAPI services'
s.description = <<-DESC
# iOS SDK for Comapi
Client to connect your iOS application with [Comapi](http://comapi.com/) services and add it as a channel to our cloud messaging platform. Written in Objective-C.
For more information about the integration please visit [the website](http://docs.comapi.com/reference#one-sdk-ios).
DESC
s.homepage = 'https://github.com/comapi/comapi-sdk-ios-objc'
s.author = { 'Comapi' => 'support#comapi.com' }
s.source = { :git => 'https://github.com/comapi/comapi-sdk-ios-objc.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/comapimessaging'
s.ios.deployment_target = '10.0'
s.requires_arc = true
s.source_files = 'Sources/**/*.{h,m}'
s.resources = []
s.dependency 'SocketRocket'
end
And here's the Podfile I'm using for the entire project:
platform :ios, '10.0'
use_frameworks!
def shared
pod 'CMPComapiFoundation', :path => '/Users/dominik.kowalski/Documents/comapi-sdk-ios-objc'
pod 'JWT'
end
target 'CMPComapiFoundation' do
pod 'SocketRocket'
end
target 'CMPComapiFoundationTests' do
shared
end
target 'ComapiFoundationSample' do
shared
end
target 'ComapiFoundationSample-Swift' do
shared
pod 'SnapKit'
end
I expect the test and sample targets to import the modules and compile the code.
Okay I managed to fix it myself. Some header files were missing Target membership, but Xcode gave me misleading hints.
I'm trying to create a custom Cocoapod to handle all of my networking calls for my iOS application. The issue that I am having is that some of my files that should be part of my new Cocoapod/framework are not found when I try to reference them in code.
I followed this tutorial https://www.raywenderlich.com/5823-how-to-create-a-cocoapod-in-swift and I successfully created the Cocoapod .xcworkspace project (named: ios-oauth2-rest-template) and added it to bitbucket and created a private PodSpec repo on bitbucket as well (named: KPodSpec) (two separate repos).
I was able to make it through the tutorial but I got stuck on the part 'Using Your New CocoaPod.' I was able to run the following commands to add the Cocoapod to my PodSpec repo:
pod repo add KPodSpecs [Your RWPodSpecs Git URL]
pod repo push KPodSpecs ios-oauth2-rest-template.podspec
When I try to use my new pod in an existing project (named: KApp) some of the files that are in my Cocoapod are able to be referenced while others will not autocomplete even after I import ios_oauth2_rest_template.
I'm not sure if I'm just missing the framework for ios-oauth2-rest-template inside my KApp project. Any help would be much appreciated.
KApp Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'https://bitbucket.org/kpodspecs.git'
target 'KApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for KApp
target 'KAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'KAppUITests' do
inherit! :search_paths
# Pods for testing
end
pod 'LBTAComponents'
pod 'SwiftyJSON', '~> 4.0'
pod 'TRON', '~>4.0'
pod 'ios-oauth2-rest-template', '~> 0.0.1'
end
ios-oauth2-rest-template podspec:
Pod::Spec.new do |s|
# 1
s.platform = :ios
s.ios.deployment_target = '12.0'
s.name = "ios-oauth2-rest-template"
s.summary = "My summary here"
s.requires_arc = true
# 2
s.version = "0.0.1"
# 3
s.license = { :type => "Proprietary", :file => "LICENSE" }
# 4 - Replace with your name and e-mail address
s.author = { "My Name" => "myemail#email.com" }
# 5 - Replace this URL with your own GitHub page's URL (from the address bar)
s.homepage = "https://bitbucket.org/myStuff"
# 6 - Replace this URL with your own Git URL from "Quick Setup"
s.source = { :git => "https://bitbucket.org/myStuff.git",
:tag => "#{s.version}" }
# 7
s.framework = "UIKit"
s.dependency 'Heimdallr', '~> 3.6.1'
# 8
s.source_files = "ios-oauth2-rest-template/**/*.{swift}"
# 9
#s.resources = "RWPickFlavor/**/*.{png,jpeg,jpg,storyboard,xib,xcassets}"
# 10
# s.swift_version = "4.0"
end
ios-oauth2-rest-template Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '12.0'
target 'ios-oauth2-rest-template' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
# Pods for ios-oauth2-rest-template
pod 'Heimdallr', '~> 3.6.1'
target 'ios-oauth2-rest-templateTests' do
inherit! :search_paths
# Pods for testing
end
end
Thanks in advance. I have scoured the internet to no avail as to why this could be happening and I am stumped since I don't have that much experience with CocoaPods in the first place.
UPDATE
Here are some screenshots
The Pods section of the KApp, to show some of my classes. When I try to use ApplicationUtils it works just fine and autocompletes, but when I try to use BaseClass it cannot seem to find it.
Build phases under settings to show that all 30 files are under compile sources. The 30 files match the 30 files from the ios-oauth2-rest-template Xcode project. The 31st file is ios-oauth2-rest-template-dummy.m.
Image showing the folder structure of ios-oauth2-rest-template Cocoapod project.
Thanks to #balazs630, I was able to solve the problem. I had to make sure my access control was set to public or open in order to access them. Looking back at my code, ApplicationUtils was a public class and BaseClass had no designation, so it was by default internal, which according to the docs:
Internal access enables entities to be used within any source file
from their defining module, but not in any source file outside of that
module.
For anyone with a similar problem, check to make sure your access control is set appropriately. Here are some sources to familiarize yourself with access control in Swift:
https://medium.com/#abhimuralidharan/swift-3-0-1-access-control-9e71d641a56c
https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html
i am trying to install my custom pod created and when i run the pod install i see below error. Any one can please help I did try similar links on stack overflow but no luck.
Error : Unable to find a specification for 'Foo'.
Terminal Logs :
ExampleApp djrecker$ pod install
Analyzing dependencies
Pre-downloading: `Foo` from `https://github.com/deepesh259nitk/mixedFramework.git`, tag `1.0.7`
[!] Unable to find a specification for 'Foo'.
Pod file
# Uncomment the next line to define a global platform for your project
platform :ios, '11.0'
target 'ExampleApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for ExampleApp
pod 'Foo', :git => 'https://github.com/deepesh259nitk/mixedFramework.git', :tag => '1.0.7'
end
More pod commands output : pod try , pod install and pod list
AUK03154:ExampleApp djrecker$ pod try Foo
Updating spec repositories
[!] An unexpected version directory `Foo.xcodeproj` was encountered for the `/Users/djrecker/.cocoapods/repos/deepesh259nitk/Foo` Pod in the `Foo` repository.
AUK03154:ExampleApp itrmg$ pod install
Analyzing dependencies
Pre-downloading: `Foo` from `https://github.com/deepesh259nitk/mixedFramework.git`, tag `1.0.7`
[!] Unable to find a specification for 'Foo'.
AUK03154:ExampleApp djrecker$ pod list | grep Foo
AUK03154:ExampleApp djrecker$
pod spec file
Pod::Spec.new do |s|
s.name = "Foo"
s.version = "1.0.7"
s.summary = "This is a iOS framework containing both objective c and swift code"
s.description = "This is a iOS framework containing both objective c and swift code and shows how modules with with POD"
s.homepage = "https://github.com/deepesh259nitk/mixedFramework"
s.license = "MIT"
s.author = { "Deepesh" => "deepesh259nitk#gmail.com" }
s.platform = :ios, "11.0"
s.source = { :git => "https://github.com/deepesh259nitk/mixedFramework.git", :tag => "1.0.7" }
#s.source_files = "Foo/**/*.{h,m,swift}"
#s.source_files = "Foo/**/*.{modulemap}"
#s.source_files = "Foo/**/*.private.modulemap"
# s.exclude_files = "Classes/Exclude"
# s.public_header_files = "Foo/*.h"
s.vendored_frameworks = 'Foo/Foo.framework'
end
Put the podspec in the top level directory at github.com/deepesh259nitk/mixedFramework
I've set up a workspace with two Swift projects in it: one a framework I'm developing, the other a demo app for the framework.
Podfile looks like this:
platform :ios, '9.0'
workspace 'foo.xcworkspace'
target 'framework' do
project 'framework.xcodeproj'
end
target :'demo' do
project 'demo/demo.xcodeproj'
pod 'framework', :path => 'framework.podspec'
end
the .podspec file looks like this:
Pod::Spec.new do |s|
s.name = 'framework'
s.authors = { "foo author" }
s.version = '0.1.0'
s.summary = 'foo summary.'
s.homepage = 'foo homepage'
s.platform = :ios, '9.0'
s.license = {
:type => "Proprietary",
:file => "LICENSE"
}
s.source = {
:git => 'https://url.to/foo.git',
:tag => s.version.to_s
}
s.source_files = 'framework/framework/**/*.{swift,h,m}'
s.requires_arc = true
s.weak_framework = "XCTest"
s.pod_target_xcconfig = {
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"',
}
end
After running pod install, Xcode/AppCode can still not see the classes from the framework project. So if I add a manual import to a class in the demo app and try to compile, it fails with:
Error:(13, 21) use of undeclared type 'FooClass'
What do I have to do to properly have the demo app project see the classes from the framework project generated pod?
Try using inherit! :search_paths on the demo target
This means they don't get their own copies of the pods but can see they exist via the header files.
platform :ios, '9.0'
workspace 'foo.xcworkspace'
target :framework do
project 'framework.xcodeproj'
end
target :demo do
inherit! :search_paths
project 'demo/demo.xcodeproj'
pod 'framework', :path => 'framework.podspec'
end
untested but perhaps worth a shot
If you install a Cocoapod don't use the file with .xcodeproj to open your project anymore, but the newly created .workspace in the same folder.
I finally resolved this issue:
Make sure the min. required iOS is defined in Podfile, e.g.:
platform :ios, '10.0'
Add any third-party pods also to the podspec file, e.g.:
spec.dependency 'Alamofire', '~> 4.5'
spec.dependency 'Serpent', '~> 1.0'
If doing pod install without the use_frameworks! it will mess up some things (see this answer: ld: framework not found Pods). So in between I got these invalid Pod xconfigs that I had to delete and then do a clean and pod install.
Make sure to build the framework project at least once and then the demo source should find the import to the framework pod name!
Make sure that all classes are correctly added to their target, especially classes in the test target should not have been added to the app target accidentally.
After all is said and done, having worked with a multitude of IDEs and development technologies, Xcode and Cocoapods can only be summed up as one giant clusterf*** of an accident!
I know there are already a few questions on this theme here on SO, but very few have accepted answers, and I don't think I have found the exact same problem as mine.
I'm building a Swift pod, and in my code I rely on the Google Maps iOS SDK, which is bundled as a .framework file. The project builds OK in Xcode, however I have troubles publishing the lib to Cocoapods.
I managed to have a Podspec file that almost validates using the pod lib lint command. However, now that I've added the Google-Maps-iOS-SDK pod as a dependency in the Podspec file, it fails with the following message:
$ pod lib lint
[!] The 'Pods' target has transitive dependencies that include static
binaries:
(/private/var/folders/n2/qyjfpk6n7zz_mngtwswlmsy00000gn/T/CocoaPods/Lint/Pods/Google-Maps-iOS-SDK/GoogleMaps.framework)
$
Is this expected? Why can't I add the Google Maps iOS SDK as a pod reference in my own Swift-based pod?
Here's the Podspec:
Pod::Spec.new do |s|
s.name = '(name)'
s.version = '1.0.0'
s.summary = '(summary)'
s.platforms = { :ios => '8.0', :osx => '10.10' }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.source_files = 'Sources/*.{h,swift}', '*.framework'
s.source = { :git => "https://github.com/(Github repo).git", :tag => "1.0.0" }
s.requires_arc = true
s.frameworks = "Foundation", "CoreLocation"
s.author = { 'Romain L' => '(email)' }
s.dependency 'Google-Maps-iOS-SDK'
end
If I don't include the Google Maps iOS SDK as a dependency, then pod lib lint fails in the Bridging Header, and complains it cannot find <GoogleMaps/GoogleMaps.h> (file not found).
I'm stuck, and I don't know if it's a bug from Cocoapods 0.36 (still in Beta) or if I'm doing something wrong.
Thanks for your help!
I finally found another thread on SO dealing with similar problems: Linker errors in a Swift project with Google Maps for iOS added via CocoaPods.
It appears that the errors were due to a combination of bad Podspec file (on the Google Maps iOS SDK side), and bugs in Cocoapods 0.36 Beta.
It's actually possible to workaround the issues by using #fz.'s revised Podspec file for Google Maps: https://stackoverflow.com/a/28471830/145997. Another article that also was of great interest to understand how the vendored_frameworks setting works in Podspec is: http://codereaper.com/blog/2014/creating-a-pod-with-crashreporter/.
So, to correctly import the Google Maps iOS SDK in a Pod project, first use the following Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
# altered version of Google's Podspec
pod 'Google-Maps-iOS-SDK', :podspec => "https://raw.githubusercontent.com/Reflejo/GoogleMapsPodspec/master/Google-Maps-iOS-SDK.podspec.json"
use_frameworks! # don't forget this!
I'm now able to reference Google Maps classes from my Swift code simply by doing import GoogleMaps. And, to distribute the Pod, my final Podspec now resembles the following:
Pod::Spec.new do |s|
s.name = 'MyPod'
s.version = '1.0.0'
s.homepage = "https://github.com/..."
s.summary = '(pod summary)'
#s.screenshot = ""
s.author = { 'Romain L' => '(email)' }
s.license = { :type => 'BSD', :file => 'LICENSE' }
s.social_media_url = "https://twitter.com/_RomainL"
s.platforms = { :ios => '8.0' }
s.ios.deployment_target = '8.0'
s.source_files = 'MyCode/*.{h,swift}'
s.module_name = 'MyPod'
s.source = { :git => "https://github.com/....git", :tag => "1.0.0" }
s.requires_arc = true
s.libraries = "c++", "icucore", "z" # required for GoogleMaps.framework
s.frameworks = "AVFoundation", "CoreData", "CoreLocation", "CoreText", "Foundation", "GLKit", "ImageIO", "OpenGLES", "QuartzCore", "SystemConfiguration", "GoogleMaps" # required for GoogleMaps.framework
s.vendored_frameworks = "Dependencies/GoogleMaps.framework" # Put the Google-provided framework in that subfolder of your Pod project
#s.dependency 'Google-Maps-iOS-SDK' # Careful! this will cause errors if enabled!
end
I am now able to start a new iOS app in Xcode and use the following Podfile to link against my own pod, itself referencing the Google Maps iOS SDK:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'MyPod'
use_frameworks! # do not forget this!
Not that easy, but feasible after all! Hoping Google will soon patch its Podspec file for Swift developments, though.