Add Parse.com 1.11.0 to watchOS 2 - ios

In the Parse SDK update to 1.11.0 it says it supports watchOS and tvOS. I was wondering how I can add the frameworks to my watchOS app using Cocoapods. The pod file contains pod 'Parse' and I have run pod update then pod install but when I add a bridging header to the watchOS 2 Extension it says file not found.
Do you know what I should be doing?
Thank you

It seems like the QuickStart instructions have not been updated for watchOS 2. I couldn't find any information in the announcement either.
If you only need to use Parse on your WatchKit Extension target, then a simple Podfile similar to this will work:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'MyApp' do
end
target 'MyApp WatchKit App' do
end
target 'MyApp WatchKit Extension' do
platform :watchos, '2.0'
pod 'Parse', '~> 1.11'
end
However, if you need to use Parse in both your iOS target and the WatchKit Extension target (e.g. to register for Push Notifications on iOS and communicate with Parse on WatchKit), things are a bit more complicated.
Due to the "Generated duplicate UUIDs" bug in CocoaPods, you will need to work around the issue, by running this in your terminal first:
export COCOAPODS_DISABLE_DETERMINISTIC_UUIDS=YES
Next, you can create a Podfile such as this:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'MyApp' do
platform :ios, '8.0'
pod 'Parse', '~> 1.11'
end
target 'MyApp WatchKit App' do
end
target 'MyApp WatchKit Extension' do
platform :watchos, '2.0'
pod 'Parse', '~> 1.11'
end
Finally, pod install, and you should be good to go!

Related

Import Firebase in dynamic Swift framework (with/without Cocoapods) and import framework into app target

Firebase for iOS is an Objective-C framework which recommends integration using Cocoapods. Here's how I'm trying to set it up:
I am running Xcode 8b6 on OS X 10.11.6. The app is being built with the iOS 10 SDK, targeting iOS 9.
MyApp is the regular (Swift) iOS app I want to use.
MyFramework is an embedded dynamic framework with the app, q. I would like all the Firebase code to be abstracted away into the framework, and therefore add Firebase to the MyFramework target in my Podfile:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
end
target 'MyApp' do
pod 'Firebase'
pod 'Firebase/Database'
pod 'Firebase/Auth'
end
On running pod install, I am able to import Firebase in all .swift files in MyFramework. However, on using import MyFramework anywhere in my app, I get the error Missing required module Firebase.
Thinking this could be a Cocoapods issue, I started a fresh project and integrated Firebase manually, but ended up with the same issue.
Is this a known issue? If so, are there any fixes for it?
In the podspec of MyFramework, add dependency of the Firebase pods. Also set the static framework flag as true. This is how your podspec should look:
*OTHER METADATA RELATED TO MYFRAMEWORK*
s.static_framework = true
s.dependency 'Firebase'
s.dependency 'Firebase/Database'
s.dependency 'Firebase/Auth'`
May be you can include this in your podfile
//As you are targeting iOS 9.0
platform :ios, '9.0'
use_frameworks!
def firebase_pods
pod 'Firebase'
pod 'Firebase/Database'
pod 'Firebase/Auth'
end
target 'MyApp’ do
firebase_pods
Let me know if this doesn't work for you, i can try to help in other way i could

Xcode can't find Alamofire, error: No such module 'Alamofire'

I'm trying to include Alamofire in my Swift project following the github(https://github.com/Alamofire/Alamofire#cocoapods) instruction.
I've created a new project, navigated to the project directory and run this command sudo gem install cocoapods. Then I faced following error:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/pod
After searching I managed to install cocoapods by running this command sudo gem install -n /usr/local/bin cocoapods
Now I generate a pod file by pod init and edited it this way:
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
target 'ProjectName' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Law
pod 'Alamofire'
target 'ProjectNameTests' do
inherit! :search_paths
# Pods for testing
end
target 'ProjectNameUITests' do
inherit! :search_paths
# Pods for testing
end
end
Finally I run pod install to install Alamofire. After that I open the project and import Alamofire statement gives me following error No such module 'Alamofire'
Update-1: Results of pod install is:
Analyzing dependencies
Downloading dependencies
Using Alamofire (3.4.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Open the .xcworkspace not the .xcodeproj
go to Product -> Scheme -> Manage Schemes...
and check Alamofire true
this work for me
Sometimes with no reason xcode can't load a module Alamofire. It can happen after a work session, after opening a project. The fix for this is to select a schema -> Alamofire, and run. If the message is "Successful", the schema can be changed back to project and it will work with no problems.
I suggest you to change your pod file like this below:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
pod 'Alamofire', '~> 3.0' <<<---- Alamofire library is cross beetween projects
target 'NotifyM' do
end
target 'NotifyMTests' do
end
target 'NotifyMUITests' do
end
Another thing is use_frameworks! you should use this if the project is Objective-C based and try to use Swift pod library.
UPDATE: for the new cocoapods version 1.x the shared library should be like this:
# There are no targets called "Shows" in any Xcode projects
abstract_target 'Shows' do
pod 'ShowsKit'
pod 'Fabric'
# Has its own copy of ShowsKit + ShowWebAuth
target 'ShowsiOS' do
pod 'ShowWebAuth'
end
# Has its own copy of ShowsKit + ShowTVAuth
target 'ShowsTV' do
pod 'ShowTVAuth'
end
end
as indicated into cocoapods website :http://guides.cocoapods.org/using/the-podfile.html
you have to clean project and build, before you can import that library.
Install this way Pod file
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'NotifyM' do
pod 'Alamofire', '~> 3.0'
end
target 'NotifyMTests' do
end
target 'NotifyMUITests' do
end
I suggest that and it's work for me :
platform :ios, '8.0'
use_frameworks!
target 'App' do
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'
end
After that, run : pod install in your project repository
2021 M1 USERS
according to: https://developer.apple.com/forums/thread/123614?answerId=683594022#683594022
close XCode
open Finder app and show there "Applications"
right click on icon Xcode and click on "Get info" (or something similar)
there is checkbox "Open with Rosseta" (or something similar). Select it
run Xcode again and try to build
it worked for me hope it works for you.
After a lot of efforts and all solutions provided above. I have fixed on Xcode 13.0:
Use for Simulator:
Go to:
- Build settings -> EXCLUDED_ARCHS = arm64
- Build settings -> VALID_ARCHS = arm64e armv7 armv7s arm64 x86_64
Use for Realm Device:
Go to:
- Build settings -> EXCLUDED_ARCHS =
- Build settings -> VALID_ARCHS = arm64e armv7 armv7s arm64
You should tap the Target to select Alamofire and build it once before coding.
When using Cocoapods to include dependencies always open your .xcworkspace
In Podfile use use_frameworks!
Remove any linked libraries from build phases.
In Build Setting look for Framework Search Path and add $(inherited) in both debug and release.
Do the same for Header Search Path too.
Now try a clean build.

CocoaPods - iOS, add new OSX target, not linking properly?

I've got an iOS app, that now needs an osx build. As it's 80%-ish shared code I've added an OSX build to the project.
With my cocoapods I'm getting a few build errors (after pod install, also tried pod update)
Also found I had explicitly add a pod to the osx target to get it do the link and build phase magic in the workspace file.
The first and key error:
Target 'Pods-scoreosx' of project 'Pods' was rejected as an implicit dependency for 'Pods_scoreosx.framework' because it doesn't contain platform 'macosx' in its SUPPORTED_PLATFORMS 'iphonesimulator, iphoneos'
Any one know what I'm doing wrong?
edit:
Current Podspec file:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
use_frameworks!
pod 'EmitterKit'
pod 'SwiftDate'
pod 'CocoaAsyncSocket'
pod 'ReactiveKit', '~> 1.0'
pod 'ReactiveUIKit', '~> 1.0'
pod 'ReactiveFoundation', '~> 1.0'
pod 'AsyncSwift'
target 'score' do
end
target 'scoreTests' do
end
target 'scoreUITests' do
end
target 'scoreosx' do
pod 'EmitterKit'
end
target 'scoreosxTests' do
end
target 'scoreosxUITests' do
end
The error message says you need to explicitly configure the platform for the target. Setting declaring the platform in the target would help.
target 'scoreosx' do
platform :osx
pod 'EmitterKit'
end

watchOS 2 working with CocoaPods

Has anyone gotten CocoaPods working with watchOS 2? I tried using ‘use_framework!’ with ‘platform :watchos, ‘2.0’ but it says "[!] Invalid Podfile file: Unsupported platform watchos2. Platform must be :ios or :osx.. Updating CocoaPods might fix the issue.”
I am on the latest version of CocoaPods.
CocoaPods released new version which is 0.38.0 and now supports watchOS 2.
http://blog.cocoapods.org/CocoaPods-0.38/
According to the blog above, deployment target can be set to watchOS 2 in Podspec.
Pod::Spec.new do |s|
# …
s.watchos.deployment_target = '2.0'
end
You can set target for watchOS 2 in Podfile with the version.
However, library has to set the deployment target explicitly, so you need to check whether it's supported for each library in Podspec.
The latest version of CocoaPods supports this.
If you just need to get a pod working on watchOS 2 (e.g. Parse), the you can simply use a Podfile such as this:
# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!
target 'MyApp' do
end
target 'MyApp WatchKit App' do
end
target 'MyApp WatchKit Extension' do
platform :watchos, '2.0'
pod 'Parse', '~> 1.11'
end
If however, you need to use the pod in multiple targets of different platforms (e.g. iOS and watchOS 2), things are slightly tricker. See this answer for more information.
CocoaPods currently doesn't support watchos. There is a work in progress issue here for adding support for it.

CocoaPods and Realm in Swift

Using Xcode-6.3.1, iOS-8.3 and MacOS-10.10.3, I am trying to use RealmSwift (0.92.3) and CocoaPods 0.37.1
I use the following procedure :
install cocoapods (in terminal):
$ sudo gem install cocoapods
Create new Xcode project (named MyApp)
Create Podfile
platform :ios, '8.3'
use_frameworks!
target 'MyApp' do
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyAppTests' do
pod 'RealmSwift', '>= 0.92.3'
end
Place the Podfile in the MyApp folder (next to MyApp.xcodeproj)
Download the newest Realm (0.92.3 from here) (i.e. Swift version)
unzip it
go to /ios folder
copy RealmSwift.framework also to your MyApp-project folder
(after Point 4 and 5 you end up like in the picture here)
Inside a terminal, go to your MyApp-folder and type
pod install
After pod-install, I end up with the following text inside the terminal:
After that, I simply open the new MyApp.xcworkspace
It basically looks ok - except: NO FRAMEWORK SEEMS TO BE FOUND !! (see screenshot below)...
What am I still missing ????
Any help greatly appreciated!
I finally found out that the "red" colored missing frameworks are no harm. Using CocoaPods these frameworks are not physically there - therefore Xcode cannot change the color. It, for sure, does not indicate a mistake here...
THREFORE THE ABOVE WORKFLOW (pt 1-8) IS CORRECT !
However, the Podfile above is not the right one if you want to use your "MyApp WatchKit Extension". The correct one is:
xcodeproj 'MyApp.xcodeproj'
workspace 'MyApp.xcworkspace'
platform :ios, '8.3'
source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
link_with 'MyApp', 'MyApp WatchKit Extension'
def shared_pods
pod 'RealmSwift', '>= 0.92.3'
end
target 'MyApp' do
shared_pods
end
target 'MyAppTests' do
shared_pods
end
target 'MyApp WatchKit Extension' do
shared_pods
end
Also, it is important that you still "import RealmSwift" in your Realm-Object definition(s) as can be seen in an example below:
Also, if you intend to use your Realm-Object in two targets (i.e. "MyApp" and "MyApp WatchKit Extension"), make sure you select both the corresponding targets in the target selection pane of your RealmObject.swift file (see image below):

Resources