My podspec file just like below
Pod::Spec.new do |s|
s.name = "LTFramework1"
s.version = "0.0.1"
s.summary = "CocoaPods 测试."
s.homepage = "https://github.com/limaofuyuanzhang/LTFramework1"
s.license = "MIT"
s.author = { "limaofuyuanzhang" => "397524331#qq.com" }
s.social_media_url ="http://limaofuyuanzhang.gitcafe.io"
s.ios.deployment_target = '8.0'
s.source = { :git => "https://github.com/limaofuyuanzhang/LTFramework1.git", :tag => "0.0.1" }
s.vendored_framework = "**/LTFramework1.framework"
s.requires_arc = true
end
I can user it upload my framework account to CocoaPods 0.39.0,but when I update my CocoaPods to 1.0.0.beta.2, the podsepc doesn't work.The error below
/var/folders/d3/vxynt1496_34x3mt_576n4mm0000gn/T/CocoaPods/Lint/App/main.m:3:9: fatal error: module 'LTFramework1' not found
#import LTFramework1;
~~~~~~~^~~~~~~~~~~~
1 error generated.
** BUILD FAILED **
The following build commands failed:
CompileC /Users/lintao/Library/Developer/Xcode/DerivedData/App-extnutajzsresacludgticynatpq/Build/Intermediates/App.build/Release-iphonesimulator/App.build/Objects-normal/i386/main.o App/main.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/lintao/Library/Developer/Xcode/DerivedData/App-extnutajzsresacludgticynatpq/Build/Intermediates/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/main.o App/main.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
-> LTFramework1 (0.0.1)
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- NOTE | xcodebuild: /var/folders/d3/vxynt1496_34x3mt_576n4mm0000gn/T/CocoaPods/Lint/App/main.m:3:9: fatal error: module 'LTFramework1' not found
Analyzed 1 pods
And I think is my podspec lack something,but Ican't find it on the official website.
The problem has solve.I made a mistake.I just want to learn push my framework, so I just rename an old framework to LTFramework1 instead of made a new one.And this framework can't use #import LTFramework1 in project,but can user #import <LTFramework1/xxx.h>.I think when user pod lib lint, somewhere has use #import <LTFramework1/xxx.h> in CocoaPods 0.39.0 but use #import LTFramework1 in CocoaPods 1.0.0.beta.2.
I'm still in the study of the difference between #import module and #import <>.I'm try to rename the header to LTFramework1.h,but it doesn't work.
Anyway, thank you very much for your view.My English is poor, please forgive me.
Related
I pod Protobuf-C++ in my ios app, but build failed, build error log looks like this
- NOTE | [iOS] xcodebuild: Protobuf-C++/src/google/protobuf/io/zero_copy_stream.cc:35:10: fatal error: 'google/protobuf/io/zero_copy_stream.h' file not found
- NOTE | [iOS] xcodebuild: Protobuf-C++/src/google/protobuf/wrappers.pb.cc:4:10: fatal error: 'google/protobuf/wrappers.pb.h' file not found
anyone knonw how to fix this ? my protobuf version is 3.11.3
problem like this
'google/protobuf/any.h' file not found
'google/protobuf/arena_test_util.h' file not found
'google/protobuf/util/delimited_message_util.h' file not found
maybe other file not found.
the way to fix it:
way to fix
1. select 'Pods'
2. select 'Protobuf-C++'
3. select 'Build Settings'
4. search 'search path'
5. select 'Header Search Paths'
6. add '$(SRCROOT)/Protobuf-C++/src'
It works for me,thanks a lot! #Rome
i also checked podspec file of Protofbuf, it has missed this config but others does "xcconfig":
{
"HEADER_SEARCH_PATHS": "$(PODS_ROOT)/SQLCipher",
......
}
which looks like same to your solution
#Rome's solution is quite helpful, but after a pod install, I have to do the same thing again manually. So I try to improve it and with this solution, no extra work is needed.
Put the following code in your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
# print "target=", target, "\n"
if target.name == "Protobuf-C++"
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = '$(SRCROOT)/Protobuf-C++/src'
end
end
end
end
In addition, if you have some C++ code that uses protobuf (i.e. includes it), you may also need to do the following in your xxx.podspec:
s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '$(SRCROOT)/Protobuf-C++/src',
}
I am trying to find out how to set up unit testing for my private cocoapod library.
Here is the expecting result:
I added a unit testing target 'MyPodTests' to the 'Pods' Project, then I changed target to my 'MyPodTests' scheme. Then I created test classes for my unit tests. I can now select my 'MyPodLib' scheme and press CMD+U and the testing target executes the tests. This is the behavior I am looking for.
This approach, however, has some drawbacks. If I do 'pod update' or 'pod install' on my example app, the test target is gone. if I call pod update on my Example application, the tests are gone too. I'm certain there is a correct way to do this. Also, I would like to prevent the test classes from being loaded into any consumers using the library, therefore I added an exclusion to my podspec:
s.exclude_files = 'Pod/Classes/**/Test/*'
When I select MyPodLib and press CMD+U nothing is happening, and if I select MyPodTests and press CMD+U it throws "No such module 'MyPodLib'" error.
You'll probably want to have the tests running independently of your example app. If that's the case add a test subspec in your pod spec and set its source files.
For example, say you have an Xcode project with a framework target MyFramework and a test target MyFrameworkTests. Your pod spec will look like this:
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "Summary of what MyFramework does"
s.homepage = "https://www.website.com"
s.license = { :type => "MIT", :file => "LICENCE.txt" }
s.author = "Ramesh Boosa"
s.platform = :ios, "11.0"
s.swift_versions = ["5.0", "5.1"]
s.source = { :git => "https://github.com/MyName/MyFramework.git", :tag => "v#{s.version}" }
s.source_files = "MyFramework/*.swift"
s.test_spec do|test|
test.source_files = "MyFrameworkTests/*.swift"
end
end
To lint your pod spec and to run your unit tests execute pod spec lint MyFramework.podspec.
If your example app is included with your pod you can add an app host to your podspec. The CocoaPods documentation has more details.
I am going mad on how could I make this podspec work.
I'm developing a swift framework, CommonCrypto is needed. After many problems to make it work for every for every teams (Cordova, React), this is how CommonCrypto is implemented :
I got an aggregate target CommonCryptoModuleMap with a run script in its build phase :
if [ -d "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap" ]; then
echo "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap directory already exists, so skipping the rest of the script."
exit 0
fi
mkdir -p "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap"
cat <<EOF > "${BUILT_PRODUCTS_DIR}/CommonCryptoModuleMap/module.modulemap"
module CommonCrypto [system] {
header "${SDKROOT}/usr/include/CommonCrypto/CommonCrypto.h"
export *
}
EOF
But now, the goal is to implement it as a dependence of another Framework in Swift. So I have to specified the target dependency in the podspec.
I got no problem to build or archive it from Xcode.
Here is my Podspec :
Pod::Spec.new do |s|
s.name = "AFrameworkHasNoName"
s.version = "0.1.5"
s.summary = "Foo bar"
s.homepage = "https://github.com/MyRepository_ios"
s.license = "License"
s.author = { "Veesla" => "valentin.cousien#gmail.com" }
s.source = { :git => "git#github.com:MyRepository_ios.git", :tag => "develop" }
s.swift_version = "4.0"
s.platform = :ios, "8.0"
s.requires_arc = true
s.exclude_files = "AFrameworkHasNoNameTests/*"
s.source_files = "AFrameworkHasNoName/**/*.{h,m,swift}"
s.module_name = "AFrameworkHasNoName"
end
Here is the error :
- WARN | source: The version should be included in the Git tag.
- WARN | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
- WARN | url: The URL (https://github.com/MyRepository_ios) is not reachable.
- WARN | [iOS] license: Unable to find a license file
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
- ERROR | [iOS] xcodebuild: MyFileImportingCommonCrypto.swift:10:8: error: no such module 'CommonCrypto'
Thanks for your responses
Nevermind, It seems like I'm not the only failing to include CommonCrypto in a SDK included in another SDK.
I just bypass the problem by including CryptoSwift (using only pure Swift). It works perfectly for me. It's a bit heavy but you don't have to deal with modulemap files and C library... Pretty easy to work with, nice implementation
Here the link of CryptoSwift : https://github.com/krzyzanowskim/CryptoSwift
Hope it will help one of you !
PS : can anyone explain me why did I get down voted ? :(
This question is in regards to podspec with vendor framework and use_frameworks! in the pod file
I've created a Podspec for my framework (which contains swift and obj-c code).
The aforementioned pod spec is for a vendor framework (i.e closed-source) which is already compiled as an an iOS embedded framework, which itself contains swift and objective-c code ("mixed project").
The framework has an umbrella header and defines a module and works as expected when embedded directly to a project (manually without pods ,Drag-and-drop into a project) and using the syntax in the hosting app:
#import <MyFramework/Myframework.h>
The framework header has the standard lines:
//! Project version number for MyFramework.
FOUNDATION_EXPORT double MyFrameworkVersionNumber;
//! Project version string for MyFramework.
FOUNDATION_EXPORT const unsigned char MyFrameworkVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <MyFramework/PublicHeader.h>
#import <MyFramework/Header_one.h>
#import <MyFramework/Header_two.h>
... etc.
The corresponding pod-spec that I am trying (and many combinations there of...)
Pod::Spec.new do |s|
s.name = "MyFramework"
s.version = "1.0.0"
s.summary = "MyFramework SDK."
s.description = "Some sort of long description of the pod"
s.homepage = "http://MyFramework.com/"
s.license = { :type => "Commercial", :text => "MyFramework Copyright 2015 ...." }
s.author = { "Avner Barr" => "avner#abc.com" }
s.platform = :ios, "8.0"
s.source = { :http => "http://somewhere_over_the_rainbow/MyFramework.zip" }
s.public_header_files = "MyFramework.framework/Headers/*.h"
s.module_map = "MyFramework.framework/Modules/module.modulemap"
s.preserve_paths = "InsertFramework.framework/*"
s.vendored_frameworks = "MyFramework.framework"
s.requires_arc = true
end
In the pod file of the host app:
source '.../.../MyPrivateTestingPodSpecRepo.git'
use_frameworks!
target 'TestPSpec1' do
pod 'MyFramework'
end
The pod downloads and creates the workspace as expected but in swift code when trying to do:
import MyFramework
I get the error:
Include of non-modular header inside framework module 'MyFramework'
With a "red" error in the objective-c header (the <> syntax).
i.e.
MyFramework.h
#import <MyFramework/Header_one.h> Include of non-modular header inside framework module 'MyFramework'
Try going to the root of your project directory where the podfile is located in terminal, then type in 'pod install' and hit enter.
If it still doesn't work try typing in 'pod uodate'
I'm new to CocoaPods and wanted to explore it by deploying an open source github project ( Banner notification for curious )
So I followed step by step the Cocoapods Guide as well as the Trunk guide for deployment. OK.
So my pod is called AWBanner (github : https://github.com/Aymenworks/AWBanner ) and I can add it in any project that use pods like that : pod 'AWBanner'. No problem.
My pod library contains only one file I want to provide, which is : AWBanner.swift
Both pod lib lint and pod spec lint success. ✅
This is my spec file
#
# Be sure to run `pod lib lint AWBanner.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = "AWBanner"
s.version = "0.1.1"
s.summary = 'An easy, customizable and soft Swift banner notification for iOS applications.'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
An easy, customizable and soft banner notification for iOS applications.
AWBanner library provides an easy to use class to show a banner view on the screen ( wherever you want, you can specify the Y origin ).
The banner moves from the Y origin ( default 0, but you can change it 👍) and stays there until the duration you choose elapse ( Personally I choose in general 2.5s ).
To dismiss the banner before the time elapse, the user can tap it.
DESC
s.homepage = "https://github.com/Aymenworks/AWBanner"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.license = 'MIT'
s.author = { "Rebouh Aymen" => ".." }
s.source = { :git => "https://github.com/Aymenworks/AWBanner.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
s.source_files = 'Pod/Classes/AWBanner.swift'
s.resource_bundles = {
'AWBanner' => ['Pod/Assets/*.png']
}
s.frameworks = 'UIKit'
end
So the problem is that when importing the lib in my swift project , like that :
import AWBanner
No errors are found, but I can't use any functions I made. It's like it's an empty module. I can't access any of my functions, even after setting them public.
Someone can give me pointers if I have missed something ?