Where storyboards should be included in a pod project? - ios

I'm trying to generated a Pod with some graphics into a storyboard.
Well, my issue is the next.
When I try to run
pod spec lint --verbose
I get the next error:
The following build commands failed:
ComipileStoryboard MyProject/Example/Base.lproj/Main.storyboard
- ERRRO | [iOS] xcodebuild: Returned an unsuccessful exit code.
Where I should add the storyboards files?

Anything other than source files will go in resources or resource-bundles
Pod::Spec.new do |spec|
spec.name = 'YOUR_LIB_NAME'
spec.version = '1.0'
spec.source_files = 'YOUR_LIB_NAME/*'
spec.resource_bundles = {
'YOUR_LIB_NAME' => ['YOUR_LIB_NAME/YOUR_PATH_TO_STORYBOARD/*.storyboard']
}
end

Related

Xcode Swift CocoaPods pod spec lint Fails on Embed Pods Frameworks

I'm getting the following error when trying to run pod spec lint --verbose:
sent 1312397 bytes received 106 bytes 2625006.00 bytes/sec
total size is 1311832 speedup is 1.00
/var/folders/3d/v0m_90ty4mg1opbynpnjjvzh2010gm/T/CocoaPods-Lint-20181015-62030-oljqd-MySwiftPackage/Pods/Target Support Files/Pods-App/Pods-App-frameworks.sh: line 104: EXPANDED_CODE_SIGN_IDENTITY: unbound variable
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks /Users/myuser/Library/Developer/Xcode/DerivedData/App-loplmnuztwibrzfqgadqoxucytrz/Build/Intermediates.noindex/App.build/Release/App.build/Script-09EB8340PON5K18DNW0C63DQ.sh
(1 failure)
Testing with `xcodebuild`.
-> MySwiftPackage (0.1.0)
- WARN | summary: The summary is not meaningful.
- WARN | description: The description is shorter than the summary.
- WARN | url: The URL (https://github.com/fishcharlie/MySwiftPackage) is not reachable.
- NOTE | xcodebuild: note: Using new build system
- NOTE | xcodebuild: note: Planning build
- NOTE | xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file. (in target 'App')
- WARN | xcodebuild: MySwiftPackage/MySwiftPackage/ViewControllers/Shared/MyFirstViewController.swift:102:37: warning: conditional cast from 'UIViewController' to 'MyViewController' (aka 'UIViewController') always succeeds
- WARN | xcodebuild: MySwiftPackage/MySwiftPackage/ViewControllers/Shared/MySecondViewController.swift:145:37: warning: conditional cast from 'UIViewController' to 'MyViewController' (aka 'UIViewController') always succeeds
- ERROR | [OSX] xcodebuild: Returned an unsuccessful exit code.
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 1 error and 5 warnings.
I know I have a few warnings that I can clean up. But there is only one error that I'm getting, which is - ERROR | [OSX] xcodebuild: Returned an unsuccessful exit code.. And above that it says that Embed Pods Frameworks was the cause of failure.
Not quire sure how to debug this since I can build and run the example projects in Xcode just fine.
Below I have attached my Podspec as well.
Pod::Spec.new do |s|
s.name = 'MySwiftPackage'
s.version = '0.1.0'
s.summary = 'A short description of MySwiftPackage.'
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/fishcharlie/MySwiftPackage'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'fishcharlie' => 'fishcharlie.code#gmail.com' }
s.source = { :git => 'https://github.com/fishcharlie/MySwiftPackage.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/char_fish'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.swift_version = '4.2'
s.source_files = 'MySwiftPackage/Classes/**/*', 'MySwiftPackage/ViewControllers/Shared/**/*'
s.ios.source_files = 'MySwiftPackage/ViewControllers/iOS/**/*'
s.osx.source_files = 'MySwiftPackage/ViewControllers/macOS/**/*'
s.resources = 'MySwiftPackage/Assets/**/*.{ttf,xcassets}'
s.dependency 'Alamofire', '4.7.3'
s.dependency 'Bond', '6.10.2'
s.ios.dependency '1PasswordExtension', '1.8.5'
end
Any ideas on how to fix/debug this?
The error should be about
line 104: EXPANDED_CODE_SIGN_IDENTITY: unbound variable
The solution (as stated in Issue 7708 on github/Cocoapods ) should be to add the following User-Defined Settings to project:
EXPANDED_CODE_SIGN_IDENTITY="-"
EXPANDED_CODE_SIGN_IDENTITY_NAME="-"`
Try adding the flag --no-clean. This flag makes lint leave the build directory
intact for inspection
so you can debug that build failure in a workspace which may be more familiar and give you more information.
Looks like they fixed this for xcode 10 in pr github.com/CocoaPods/CocoaPods/pull/7720, you could try upgrading to 1.6.0, or downgrading xcode to 9.4.

Building a Cocoapod with both Swift and Objective-C: How to Deal with Umbrella Header Issues?

I have an existing Xcode framework, that uses both Swift and Objective-C, that I'm trying to get working as a Cocoapod. My steps so far are:
1) I used pod lib create SMCoreLib to initialize a new folder (https://guides.cocoapods.org/making/using-pod-lib-create.html).
2) I copied the Swift and Objective-C code from my framework into the SMCoreLib/Classes folder in this newly initialized pod folder. I also dragged this code into the relevant group in _Pods.xcodeproj.
3) I made some changes to the .podspec file for my project. It's as follows (note that the Github repo hasn't been updated yet with these changes; I can do that if someone wants):
Pod::Spec.new do |s|
s.name = 'SMCoreLib'
s.version = '0.0.2'
s.summary = 'Spastic Muffin Core Library for iOS'
# 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
Objective-C and Swift classes to support Spastic Muffin code.
DESC
s.homepage = "https://github.com/crspybits/SMCoreLib.git"
s.license = { :type => "GPL3", :file => "LICENSE.txt" }
s.author = { "Christopher Prince" => "<snip>" }
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/crspybits/SMCoreLib.git", :tag => "#{s.version}" }
s.ios.deployment_target = '8.0'
s.source_files = 'SMCoreLib/Classes/**/*'
s.resources = "SMCoreLib/Assets/**"
# s.resource_bundles = {
# 'SMCoreLib' => ['SMCoreLib/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
s.dependency 'AFNetworking'
s.dependency 'HPTextViewTapGestureRecognizer', '~> 0.1'
s.dependency 'Reachability'
end
My problem is that I get failures both trying to build the Example Xcode project and trying to lint the pod. Building the Example Xcode project, I get the following errors:
From the command line, when I do:
pod lib lint --allow-warnings --verbose --no-clean
I get the following errors:
- NOTE | [iOS] xcodebuild: <module-includes>:2:9: note: in file included from <module-includes>:2:
- ERROR | [iOS] xcodebuild: /Users/chris/Library/Developer/Xcode/DerivedData/App-bhqthebvswpzxeesjidsqpmmwovu/Build/Products/Release-iphonesimulator/SMCoreLib/SMCoreLib.framework/Headers/SMCoreLib-Swift.h:103:9: error: 'SMCoreLib/SMCoreLib.h' file not found
- NOTE | [iOS] xcodebuild: <unknown>:0: error: could not build Objective-C module 'SMCoreLib'
The problem appears to be that in the automatically generated SMCoreLib-Swift.h Generated Interface Header, the SMCoreLib.h umbrella header cannot be found. I would greatly appreciate any suggestions.
I have a hack fix for this problem. I'd like a better one. The fix is to put a SMCoreLib.h file at: SMCoreLib/Classes/SMCoreLib.h. The file contains the single line:
#import "SMCoreLib-umbrella.h"
The problem seems to be that the Generated Interface Header doesn't respect a name change for the umbrella header given in a module map. Cocoapods creates this module map and the name change. This hack fix is present in the Git repo for this project https://github.com/crspybits/SMCoreLib.git.

Error using Apple frameworks in my CocoaPod podspec?

I have a cross platform library that I'm trying to push to CocoaPod, but the it is failing on the podspec validation. The error I get is:
ERROR | xcodebuild: Returned an unsuccessful exit code. You can use --verbose for more information.
ERROR | xcodebuild: MyPod/Sources/CLKComplicationServer.swift:10:8: error: no such module 'ClockKit'
I tried adding the frameworks to my podspec, but it is still not accepting. Here is what my podspec looks like:
Pod::Spec.new do |s|
...
s.ios.deployment_target = "8.4"
s.watchos.deployment_target = "2.0"
s.tvos.deployment_target = "9.0"
s.requires_arc = true
s.ios.framework = 'AVFoundation'
s.watchos.framework = 'ClockKit'
s.source_files = "Sources/**/*.{h,swift}"
end
What am I doing wrong? I'm having the same issue with AVFoundation. I tried adding both to my header file, but ClockKit is not recognized.

CocoaPods podspec lint failure - file not found

I'm trying to distribute my pod, but I'm having issues with it's validation.
When I'm trying to lint against my .podspec I'm getting:
- ERROR | [iOS] [xcodebuild] path/to/my/source/file.m:14:9: fatal error: 'KeyValueObjectMapping/DCKeyValueObjectMapping.h' file not found
I tried to preserve the path to their framework with different variations like
s.preserve_paths = 'KeyValueObjectMapping.framework/*'
or
s.preserve_paths = '${PODS_ROOT}/Vendor/KeyValueObjectMapping/KeyValueObjectMapping.framework'
& other variations but that way I'm getting one more error:
- ERROR | [iOS] The `preserve_paths` pattern did not match any file.
I also tried different other things which I saw on other issues like:
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/Vendor/KeyValueObjectMapping/KeyValueObjectMapping.framework"','FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/Vendor/KeyValueObjectMapping/*"' }
s.framework = 'KeyValueObjectMapping'
The project builds fine with Xcode5 & with xcodebuild with it's default setup, I'm getting this issue only when validating it for Cocoapods.
I was running into this issue trying to create a custom Podspec and add the RevMob and Heyzap SDKs as dependencies.
I kept getting the following error:
- ERROR | [iOS] [xcodebuild] MyProject/MyProjectSubDir/AnotherDir/CustomAd.h:10:9: fatal error: 'RevMobAds/RevMobAds.h' file not found
- ERROR | [iOS] [xcodebuild] MyProject/MyProjectSubDir/AnotherDir/FacebookController.m:18:9: fatal error: 'RevMobAds/RevMobAds.h' file not found
Then when I specified the FRAMEWORK_SEARCH_PATHS for RevMob, I would get the same error but for Heyzap's SDK.
The solution for me was to create a subspec and specify search paths for each of the SDKs giving me issues. Here:
s.subspec "Heyzap" do |ss|
ss.dependency "Heyzap", "~> 6.4.4"
ss.xcconfig = { "FRAMEWORK_SEARCH_PATHS" => "$(PODS_ROOT)/Heyzap"}
end
s.subspec "RevMob" do |ss|
ss.dependency "RevMob", "~> 7.4.8"
ss.xcconfig = { "FRAMEWORK_SEARCH_PATHS" => "$(PODS_ROOT)/RevMob"}
end
My pod spec lint now runs & builds without error.

Cocoapods importing a framework to source code

In my cocoapod for iOS, I have a essentially items:
Open-source classes (.m & .h files)
MyFramework.framework (.framework directory, header files, and .bundle for resources)
One of the open-source classes calls import <MyFramework.MyFramework.h> so it can use the components of MyFramework in its implementation. But because of this, I'm having trouble getting the podspec to pass the spec lint test (pod spec lint MyCocoapod.podspec). When I run the spec lint validation, it says:
ERROR | [iOS] [xcodebuild] .../MyFile.h:54:9: fatal error: 'MyFramework/MyFramework.h' file not found
While investigating, I noticed that the podspec does pass the spec lint validation if I remove that open-source class in the podspec's source_files section, s.source_files = 'MyFiles.{h,m}'. Any idea why my class can't import my custom framework during the spec lint validation?
The relevant code in the podspec looks like this:
s.preserve_paths = 'myframework/MyFramework.framework'
s.frameworks = 'Foundation', 'MyFramework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '$(SRCROOT)/myframework/' }
s.public_header_files = 'MyFramework.framework/Headers/*.h', 'SourceCode/*.h'
s.source_files = 'SourceCode/*.{h,m}' # Crashes here - Source_file imports MyFramework.h. If I take this out, it passes spec lint validation
EDIT This process is now entirely handled by the vendored_frameworks option. This handles preserving the paths, the framework search paths, and linking to the project.
To include a framework you can use:
s.vendored_frameworks = 'path/to/SomeFramework.framework'
To include bundle files do:
s.resources ='path/to/SomeBundle.bundle'

Resources