I have project MySingleViewApp and framework MyFramework. Both are fresh created xcode projects and just added podfile to MySingleViewApp and podspec file to MyFramework.
this is MySingleVIewApp pod file;
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'MyFramework', :path => '../MyFramework'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
And this is MyFramework podspec file
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "bla"
s.description = <<-DESC
some description
DESC
s.homepage = "https://github.com/github_account/my-framework"
# brief license entry:
s.license = "MIT"
# optional - use expanded license entry instead:
# s.license = { :type => "MIT", :file => "LICENSE" }
s.authors = { "Your Name" => "yourname#email.com" }
s.platforms = { :ios => "11.0" }
s.source = { :git => "https://github.com/github_account/my-framework.git", :tag => "#{s.version}" }
s.requires_arc = true
s.swift_version = "5.1.2"
s.vendored_frameworks = 'MyFramework.framework'
s.static_framework = true
s.dependency "UserSDK"
end
When run MySingleVIewApp project i get error
dyld: Library not loaded:
#rpath/GoogleUtilities.framework/GoogleUtilities Referenced from: Frameworks/UserSDK.framework/UserSDK Reason: image not found
If i add UserSDK(which is spec dependency of MyFramework) and remove MyFramework from podfile it works
target 'MySingleVIewApp' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks! :linkage => :static
pod 'UserSDK'
target 'MySingleVIewAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MySingleVIewAppUITests' do
# Pods for testing
end
end
Related
When adding an xcframework to your PodSpec, should you do:
spec.source = { :git => 'your repo here', :tag => "#{spec.version}" }
vendored_frameworks = "StarWarsKit.xcframework"
Then in Podfile just do:
pod 'StarWarsKit', '1.0'
use_frameworks!
OR do:
s.default_subspecs = 'Source'
s.subspec 'Framework' do |sp|
sp.ios.vendored_frameworks = 'StarWarsKit.xcframework'
end
s.subspec 'Source' do |sp|
sp.source_files = 'StarWarsKit/**/*.{swift,storyboard,xib}'
sp.resources = 'StarWarsKit/**/*.{png,xcassets,gif,strings}'
end
Then in Podfile just do:
pod 'StarWarsKit/Framework', '1.0'
use_frameworks!
To the project that installs the pod, are they the same?
I have a project XyzAbc with proj structure
--LICENSE
--XyzAbc
----XyzAbc.h
----Info.plist
----file1.swift
----file2.swift
--Products
----XyzAbc.framework
After building this project I pick this XyzAbc.framework and push it in github account that has folder structure
--XyzAbc.framework
--.gitignore
--LICENSE
--XyzAbc.podspec
--README.md
I created XyzAbc.podspec file in my local machine its structure is
Pod::Spec.new do |s|
s.name = ""
s.version = "0.1.1"
s.summary = ""
s.description = ""
s.homepage = ""
s.swift_versions = "4.2"
s.license = {
:type => "MIT",
:file => "LICENSE"
}
s.author = "xyyyy"
s.platform = :ios, "10.0"
s.source = {
:git => "https://github.com/xyz/pqr.git", # github link where I uploaded my compiled library
:tag => "0.1.1"
}
s.source_files = "XyzAbc.framework/Headers/*.h"
s.public_header_files = "XyzAbc.framework/Headers/*.h"
s.vendored_frameworks = "XyzAbc.framework"
s.framework = 'Foundation'
end
I am refering this podspec file in my app like
target 'TestApp' do
use_frameworks!
pod 'XyzAbc', :path => "../../../../Desktop/XyzAbc.podspec"
end
But I am not able to see any header inside pod library. In my project TestApp it looks something like this
--Pods
----Podfile
----Development Pods
------XyzAbc
--------Pods
--------SupportFiles
--------<Frameworks is missing>
I tried using :http then when I provide zip .framework folder in http link, it is not working but when I provide unziped .framework folder then I am able to use this library.
I am following this https://medium.com/onfido-tech/distributing-compiled-swift-frameworks-via-cocoapods-8cb67a584d57
UPDATE - elaborated
Im confused as to why this error is occuring when I try to create my own podfile
I am following this tutorial here
https://ronakshah.org/How-To-Make-A-Cocoapod-With-Dependencies/
However, when I try to run pod install for the last step it gives me this error
Invalid VideoRow.podspec file: undefined method `join' for "TLPhotoPicker":String
Pod::Spec.new do |s|
s.name = 'VideoRow'
s.version = '0.1.0'
s.summary = 'Eureka row that allows us to take or select a video.'
s.description = <<-DESC
This is an add-on to the many rows that are in the Eureka Community. This row will allow users to select a video from there library to export to a backend service of there choosing.
DESC
s.homepage = 'https://github.com/EurekaCommunity/VideoRow'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Smiller193' => 'shawn.miller#temple.edu' }
s.source = { :git => 'https://github.com/EurekaCommunity/VideoRow.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/EurekaCommunity'
s.ios.deployment_target = '9.1'
s.source_files = 'VideoRow/Classes/**/*'
s.platform = :ios, "10.0"
s.dependency = 'TLPhotoPicker'
s.dependency = 'Eureka'
s.swift_version = '4.2'
end
This is my podspec
use_frameworks!
target 'VideoRow_Example' do
pod 'VideoRow', :path => '../'
pod 'Eureka'
pod 'TLPhotoPicker'
target 'VideoRow_Tests' do
inherit! :search_paths
end
end
Both of these seem right but I get an error every time I try to run pod install.
There is no = in the dependency sequence.
Do s.dependency 'TLPhotoPicker'. Docs here.
I have a private pod called XXCommonUtils which has one dependency installed via Cocoapods, EDSunriseSet.
The podspec for my private pod looks like this
Pod::Spec.new do |s|
s.name = "XXCommonUtils"
s.module_name = 'XXCommonUtils'
s.version = "2.0.2"
s.summary = "XX CommonUtils Component"
s.homepage = 'https://www.xx.com'
s.license = { :type => "Private", :text => "Copyright 2016-2018 by XX. All right reserved." }
s.author = { "XX XX" => "xx.xx#xx.com" }
s.source = { :git => "https://github.xx.com/TSS-XX-CoreApp/iOS-Stage-Frameworks", :tag => "XXCommonUtils-2.0.2-Beta" }
s.swift_version = '4.1.2'
s.platform = :ios, '8.0'
s.requires_arc = true
s.ios.vendored_frameworks = 'XXCommonUtils/XXCommonUtils.framework'
s.frameworks = 'UIKit', 'CoreData'
s.dependency 'EDSunriseSet', '1.0'
end
You can see the EDSunriseSet dependency defined here.
I am importing this private Pod in to an application with the following Podfile
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.xx.com/TSS-XX-CoreApp/iOS-Stage-CocoaPods.git'
target 'netperf01' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
# use_frameworks!
pod 'XXCommonUtils', '2.0.2'
# Pods for netperf01
target 'netperf01Tests' do
inherit! :search_paths
# Pods for testing
end
end
I see that both the common utils private pod and it's dependency EDSunriseSet are installed in the pod install output.
When I run the application, I get an instant crash with this error
dyld: Library not loaded: #rpath/EDSunriseSet.framework/EDSunriseSet
Referenced from: /Users/me/Library/Developer/CoreSimulator/Devices/CF8F6C93-2BCF-44F5-B5D1-8B567777271A/data/Containers/Bundle/Application/9E462A24-0417-494F-9081-77D9A33C3B7D/netperf01.app/Frameworks/XXCommonUtils.framework/XXCommonUtils
Reason: image not found
If I uncomment # use_frameworks! in my application Podfile then the app works as normal, however unfortunately this is not a suitable fix for the client attempting the use the XXCommonUtils library. Is there another way to solve this problem?
Report
What did you do?
I have created podspec file for my custom Framework as:
Pod::Spec.new do |s|
s.platform = :ios
s.ios.deployment_target = '10.0'
s.name = "CustomFramework"
s.summary = "CustomFramework have all the wrapper API."
s.requires_arc = true
s.version = "1.0.0"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "My Name" => "my.name#xyz.com" }
s.homepage = "URL_LINK"
s.source = { :git => "github_url_link", :tag => "#{s.version}"}
s.dependency 'RealmSwift', '3.5.0'
s.dependency 'Firebase/Core', '5.1.0'
s.dependency 'Firebase/Firestore', '5.1.0'
s.dependency 'PubNub','4.7.5'
s.source_files = "CustomFramework/**/*.{swift}"
end
I am adding this Custom framework pod in the sample project as:
target 'customFrameworkSample' do
use_frameworks!
pod 'customFramework' , :path => 'Local_Path_for_customFramework.podspec'
target 'customFrameworkSampleTests' do
use_frameworks!
pod 'customFramework' , :path => 'Local_Path_for_customFramework.podspec'
end
end
What did you expect to happen?
Pod should install properly and When sample project is Build, it should Run and not throw any error.
What happened instead?
In the Sample project, error is thrown while importing firbase, RealmSwift files, etc.. in CustomFramework files.
CocoaPods Environment
cocoapod : 1.5.3
When you specify dependancies in your Podspec you are saying that YOUR CUSTOM FRAMEWORK is dependant on them. So the dependancies will only be available to reference within your framework. If you want the sample application to be able to reference Firebase then you will need to specify this within the sample application's podfile.
Documentation references:
Podspec 'dependancies'
Podfile 'dependancies'
make sure you have added firebase library in Linked framework and libraries