XCode - Dependencies for static build in xcframework - ios

Dependencies in static build
I am creating a .xcframework which contains static builds of my SDK for consumption via CocoaPods and SPM.
The framework structure is:
MYSDKAssets.bundle
MySDK.xcframework
- info.plist
- ios-arm-64
- MySDK.swiftmodule
- MySDK.a
- ios-x86_64-simulator
- MySDK.swiftmodule
- MySDK.a
MySDK has two external dependencies: GenericPubSub and GenericAnalytics. The problem I am running into is when I try to install the SDK in an external app via CocoaPods, I am getting an error in the .swiftinterface file
No such module GenericPubSub on the import GenericPubSub line.
I've listed the dependencies in the podspec:
spec.dependency 'GenericPubSub', '~> 1.0.0'
How can I fix this so that my static build can use external dependencies?

Related

Working process of pod install command in iOS

I have one doubt about cocoapod. Nowadays we are using dependency manager cocoapod for adding libraries to our project.
For example I added pod 'Alamofire' command in podfile and i run pod install command in my terminal.Then automatically added Alamofire library to our xcode project.This is working fine.
But my doubt is we are mentioned only pod 'Alamofire' in podfile, then how to download this exact library from this single line command? What is the process done in background when i run pod install command?
When you mention just the name of the repository in podfile. It automatically checks the latest version of the library present on GitHub and downloads it.
Here is the detailed log of what happens when you install a pod.
Analyzing dependencies
Updating spec repositories
Updating spec repo `master`
$ /usr/bin/git pull
Already up-to-date.
Finding Podfile changes
- AFNetworking
- HockeySDK
Resolving dependencies of `Podfile`
Resolving dependencies for target `Pods' (iOS 6.0)
- AFNetworking (= 1.2.1)
- SDWebImage (= 3.2)
- SDWebImage/Core
Comparing resolved specification to the sandbox manifest
- AFNetworking
- HockeySDK
Downloading dependencies
-> Using AFNetworking (1.2.1)
-> Using HockeySDK (3.0.0)
- Running pre install hooks
- HockeySDK
Generating Pods project
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing libraries
- Installing target `Pods-AFNetworking` iOS 6.0
- Adding Build files
- Adding resource bundles to Pods project
- Generating public xcconfig file at `Pods/Pods-AFNetworking.xcconfig`
- Generating private xcconfig file at `Pods/Pods-AFNetworking-Private.xcconfig`
- Generating prefix header at `Pods/Pods-AFNetworking-prefix.pch`
- Generating dummy source file at `Pods/Pods-AFNetworking-dummy.m`
- Installing target `Pods-HockeySDK` iOS 6.0
- Adding Build files
- Adding resource bundles to Pods project
- Generating public xcconfig file at `Pods/Pods-HockeySDK.xcconfig`
- Generating private xcconfig file at `Pods/Pods-HockeySDK-Private.xcconfig`
- Generating prefix header at `Pods/Pods-HockeySDK-prefix.pch`
- Generating dummy source file at `Pods/Pods-HockeySDK-dummy.m`
- Installing target `Pods` iOS 6.0
- Generating xcconfig file at `Pods/Pods.xcconfig`
- Generating target environment header at `Pods/Pods-environment.h`
- Generating copy resources script at `Pods/Pods-resources.sh`
- Generating acknowledgements at `Pods/Pods-acknowledgements.plist`
- Generating acknowledgements at `Pods/Pods-acknowledgements.markdown`
- Generating dummy source file at `Pods/Pods-dummy.m`
- Running post install hooks
- Writing Xcode project file to `Pods/Pods.xcodeproj`
- Writing Lockfile in `Podfile.lock`
- Writing Manifest in `Pods/Manifest.lock`
Integrating client project
Please refer to this Link for a detailed version of how CocoaPods work.

iOS, install library via pod install, still get "No such module"

Pardon me for beginner's question,
I tried to install a library named NetworkKit, and follow their instruction by doing
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'NetworkKit'
and then
pod install
but still in the swift file, I got the error "No such module" at the line import NetworkKit.
Any idea how to fix this? Thanks
Update: This is the output of pod install --verbose
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target
`Pods-networkingexamle`: (``)
Using `ARCHS` setting to build architectures of target
`Pods-networkingexamleTests`: (``)
Using `ARCHS` setting to build architectures of target
`Pods-networkingexamleUITests`: (``)
Finding Podfile changes
- NetworkKit
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
- NetworkKit
Downloading dependencies
-> Using NetworkKit (1.3.2)
- Running pre install hooks
Generating Pods project
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing targets
- Installing target `NetworkKit` iOS 8.0
- Generating Info.plist file at `Pods/Target Support
Files/NetworkKit/Info.plist`
- Generating module map file at `Pods/Target Support
Files/NetworkKit/NetworkKit.modulemap`
- Generating umbrella header at `Pods/Target Support
Files/NetworkKit/NetworkKit-umbrella.h`
- Installing target `Pods-networkingexamle` iOS 8.0
- Generating Info.plist file at `Pods/Target Support
Files/Pods-networkingexamle/Info.plist`
- Generating module map file at `Pods/Target Support
Files/Pods-networkingexamle/Pods-networkingexamle.modulemap`
- Generating umbrella header at `Pods/Target Support
Files/Pods-networkingexamle/Pods-networkingexamle-umbrella.h`
- Installing target `Pods-networkingexamleTests` iOS 8.0
- Generating Info.plist file at `Pods/Target Support
Files/Pods-networkingexamleTests/Info.plist`
- Generating module map file at `Pods/Target Support
Files/Pods-networkingexamleTests/Pods-networkingexamleTests.modulemap`
- Generating umbrella header at `Pods/Target Support
Files/Pods-networkingexamleTests/Pods-networkingexamleTests-umbrella.h`
- Installing target `Pods-networkingexamleUITests` iOS 8.0
- Generating Info.plist file at `Pods/Target Support
Files/Pods-networkingexamleUITests/Info.plist`
- Generating module map file at `Pods/Target Support
Files/Pods-networkingexamleUITests/Pods-networkingexamleUITests.modulemap`
- Generating umbrella header at `Pods/Target Support
Files/Pods-networkingexamleUITests/Pods-networkingexamleUITests-umbrella.h`
- Running post install hooks
- Writing Xcode project file to `Pods/Pods.xcodeproj`
- Generating deterministic UUIDs
- Writing Lockfile in `Podfile.lock`
- Writing Manifest in `Pods/Manifest.lock`
Integrating client project
Integrating target `Pods-networkingexamle` (`networkingexamle.xcodeproj` project)
Integrating target `Pods-networkingexamleTests` (`networkingexamle.xcodeproj` project)
Integrating target `Pods-networkingexamleUITests` (`networkingexamle.xcodeproj` project)
- Running post install hooks
- cocoapods-stats from
`/Library/Ruby/Gems/2.0.0/gems/cocoapods-stats-1.0.0/lib/cocoapods_plugin.rb`
Sending stats
- NetworkKit, 1.3.2
Pod installation complete! There is 1 dependency from the Podfile and 1 total
pod installed.
[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
Update 2:
The answer is in Thanh Pham's and Shayan Jali's comment: I have to open xcworkspace after install the pod, instead of the xcproject
Let me put the answer here for future readers:
The output of pod install --verbose indicates that the pod has been installed successfully. However, you have to open the .xcworkspace file generated by CocoaPods instead of the .xcproject file.
It is also worth mentioned that the pod can be compiled on Xcode 7 but not Xcode 8 since it has not been updated to Swift 2.3 nor 3.0 at the time of this post.
“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.
The NetworkKit isn't configured with the latest swift syntax. So, use this link Xcode 8 Beta 3 Use Legacy Swift issue to resolve it.
It is import NewsstandKit, the import NewtworkKit is not working.

Transitive dependencies on Cocoa Pod

I have an iOS Project with some third party dependencies and some of them are written in Swift. Due to that i have the flag use_frameworks! in my Podfile .
The problem occurs when I try to install AppRTC framework. AppRTC has a reference to a static library and pod install fails with the following error:
[!] The 'Pods-X' target has transitive dependencies that include static binaries: (/.../libjingle_peerconnection/libWebRTC.a)
This tutorial explains an approach to overcome this problem by placing a modified version of the podspec file for the pod where the static library resides.
https://blog.sabintsev.com/importing-c-static-libraries-into-a-swift-project-using-cocoapods-a53993c3a2ca#.fo7l8rqxi
I created a custom pospec for AppRTC and set s.vendored_libraries but I couldn't make it work.The pod dependencies of my project look like this.
If i install libjingle_peerconnection (where the static library is) and SocketRocket explicitly with cocoa pods, i do not get any error.I a only add AppRTC to my pod file i get the mentioned error.
Question 1) To which project shall i include the custom podspec?
Question 2) Do i need to install the pods separately?
|MyProject|
/ \
.... AppRTC
/ \
|SocketRocket| |libjingle_peerconnection|

Running Cocoapods "pod install" Causes Libraries to Disappear

We are having a problem with an existing project. Running pod install causes our existing Pods to break.
Our existing project looks like this:
After I run pod install, several of the libraries that appear in the Products directory and under the Targets are gone, and the app won't compile:
Here is the output from pod install --verbose
myapp-Macbook-Air:myapp username$ pod install --verbose
Preparing
Updating local specs repositories
Updating spec repo `master`
$ /usr/bin/git pull --ff-only
Already up-to-date.
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods`:
(`$(ARCHS_STANDARD)`)
Finding Podfile changes
- Dropbox-iOS-SDK
- FiksuSDK
- GoogleAnalytics
- Localytics
- MobileAppTracker
- SDWebImage
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
- Dropbox-iOS-SDK
- FiksuSDK
- GoogleAnalytics
- Localytics
- MobileAppTracker
- SDWebImage
Downloading dependencies
-> Using Dropbox-iOS-SDK (1.3.13)
-> Using FiksuSDK (4.4.1)
-> Using GoogleAnalytics (3.13.0)
-> Using Localytics (3.5.0)
-> Using MobileAppTracker (3.7)
-> Using SDWebImage (3.7.2)
- Running pre install hooks
Generating Pods project
- Creating Pods project
- Adding source files to Pods project
- Adding frameworks to Pods project
- Adding libraries to Pods project
- Adding resources to Pods project
- Linking headers
- Installing targets
- Installing target `SDWebImage` iOS 7.0
- Installing target `Pods` iOS 7.0
- Running post install hooks
- Writing Xcode project file to `Pods/Pods.xcodeproj`
- Generating deterministic UUIDs
- Writing Lockfile in `Podfile.lock`
- Writing Manifest in `Pods/Manifest.lock`
Integrating client project
Integrating target `Pods` (`myapp.xcodeproj` project)
Adding Build Phase 'Embed Pods Frameworks' to project.
- Running post install hooks
- cocoapods-stats from
`/usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-stats-0.6.2/lib/cocoapods_plugin.rb`
Sending stats
- Dropbox-iOS-SDK, 1.3.13
- FiksuSDK, 4.4.1
- GoogleAnalytics, 3.13.0
- Localytics, 3.5.0
- MobileAppTracker, 3.7
- SDWebImage, 3.7.2
Pod installation complete! There are 6 dependencies from the Podfile and 6
total pods installed.
[!] The `myapp [Debug]` target overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting defined in `Pods/Target Support Files/Pods/Pods.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
(We've always had that GCC_PREPROCESSOR warning)
Any ideas about what be happening here, would be appreciated.
Some other notes: We are having this problem on Xcode 6 and Xcode 7, but both machines are running OS X 10.11, which might be the problem. Cocoapods v0.39.0. Also tried downgrading to Cocoapods v0.25.0 but the same problem occurs.

What is the best way to add iOS Google API components (Analytics) to a static iOS library?

I am building a static iOS library and would like to use Google Analytics for tracking events inside the library. I tried installing via CocoaPods in the library itself but when I run the parent app I get a "resource not found" error. When I add the Google dependency in the podspec of the library via s.dependency and then run "pod instal" I get:
[!] The 'Pods-MyApp' target has transitive dependencies that include static binaries:
and then when I run the app, I get this error:
Undefined symbols for architecture x86_64:"_OBJC_CLASS_$_GAI"

Resources