Mobile SDK Install - Detailed help for Cocoapods install

See the directory and Terminal responses… Terminal is blocking view of .xcodeproj file. It is in the directory with Podfile.

Hi @ido,

Thanks for the additional help. Kenneth moved me a bit closer, but I am still getting an error that is holding the install up.

I appreciate your advice to move to Objective C, but I’m not facile with it and want to stick with Swift. I presume you have run those examples in Swift, so must have set up a Mac with the Mobile SDK and Xcode Swift :smile:

I can’t go further with the Swiftilicio.us site until I get the pod install to run.

Thanks,
Ben

Podfile is stlll not in the root project directory, put it there (use Finder) and cd to this folder in terminal and then run pod install, believe me, if the file is there it will install.

In addition, the Podfile contents should be JUST:

pod "Spark-SDK"

and not all this:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target "Spark_SDK_First_Try" do
    pod "JGProgressHUD"
end
1 Like

Hi @ido
The project directory is there on the desktop, in the screenshot. Finder is open and you can see that the view is on the top level of the folder and that Podfile is right there. Am I confused about the term “root of the directory”? Is it not:

In a computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the trunk of a tree, as the starting point where all branches originate from.

So, could you look at the screen shot and tell me if that Podfile is at the root of the directory according to what you mean, cause I think it is according to that definition. That’s all I have to go on for an explanation of root directory.

You can see in the screen shot that I have navigated Terminal to the directory that contains the file Podfile. Although I am there, I get the file not found error. Could you look at the screenshot of the Finder window and the Terminal and tellme what is wrong.

As for the file contents, you sent me to Swiftilicio.us page for Swift, and that is what that page said should be in the Podfile. So, I was just trying to follow the instructions you provided. If I don’t follow the instructions on Swiftilicio.us (there are several pages of Swift instructions), then what should I do to get the Mobile SDK running in Swift?

@ido, I am trying to get the Swift SDK running as you suggested. I’m doing everthing I can on my own and spending hours reading the docs, the links in the docs and experimenting, but I am making no progress. The announcement said to come to this forum for help, so that’s why I’m here. If this is the wrong place to get help, just let me know.

file Podfile should reside in same directory as your <project name>.xcodeproj file.
you can use the command ls -l on shell to verify you see both of those files in the folder you are currently in, once that’s the case run pod install or pod update. the swiftalico.us page contain the instructions on how to setup XCode environment settings to allow Obj-C SDK integration with Swift project, any SDK. It is not specific instructions for the Particle SDK.

I found that there is help for Pod if entered as Pod --help.

From there I learned that you can create a Podfile in the currently pointed to directory by typing Pod init. I did that and it created a second Podfile in my project root directory, right alongside the one I created. The file created with init is listed as a text file. The one I created is listed as a TextEdit Document. Neither has an extension but somehow they are different, which might explain why pod install could not find a pod file.

I put the line: pod “Spark-SDK” in the file created by pod init. I ran pod install and got this error message:

Bendrixs-MacBook-Pro:Spark_SDK_First_Try bendrix$ pod install

[!] Invalid Podfile file: undefined local variable or method `“Spark’ for #Pod::Podfile:0x007f8fc3af4600. Updating CocoaPods might fix the issue.

from /Users/bendrix/Desktop/Spark_SDK_First_Try/Podfile:1

-------------------------------------------

pod “Spark-SDK”

-------------------------------------------

Since I just installed Cocoapods yesterday, the suggested update of cocoapods is not likely to be the source of the problem.

SOLVED See revised post at the top of the page.

1 Like

Glad everything was solved.
Thanks Ben for summarising it up to help other users, I appreciate it.

Hi, Thanks for step by step example. I have a question regarding adding cocoapod-keys. I tried to run this example with cococapod-keys, https://github.com/spark/spark-setup-ios-example. But after installing the pod plugin and run the pod install/update it still asked for cocoapods-keys plugin install. My pod file looks like this:

source ‘https://github.com/CocoaPods/Specs.git

platform :ios, ‘8.0’

target ‘SparkSetupExample-Swift’ do

xcodeproj 'SparkSetupExample-Swift'
pod "SparkSetup", :path => "../spark-setup-ios"
pod "Spark-SDK", :path => "../spark-sdk-ios"
plugin 'cocoapods-keys', {
    :project => "SparkSetupExample-Swift",
    :keys => [
    "OAuthClientId",
    "OAuthSecret"
    ]}

end

I appreciate your help. I am getting stuck. Thanks.

Try removing the two :path => "../spark-setup-ios" directives from the Podfile and run pod install again

Hi, thanks. But I am still getting the same cocoapods-keys plugin error. My Pod file looks this now:

source ‘https://github.com/CocoaPods/Specs.git

platform :ios, ‘8.0’

target ‘SparkSetupExample-Swift’ do

xcodeproj 'SparkSetupExample-Swift'

pod "Spark-SDK", :path => "../spark-sdk-ios"
plugin 'cocoapods-keys', {
    :project => "SparkSetupExample-Swift",
    :keys => [
    "OAuthClientId",
    "OAuthSecret"
    ]}

end

I think you are getting the error because of the out of date Ruby you have installed on your system, see my reply in the other thread

I got ruby 2.6.1, cocoapods 0.39.0 and cocoapods-keys 1.6. Please see my gem list.

Ruby 2.6.x doesn’t make much sense to me. Latest stable version is 2.3.0. See here:

https://www.ruby-lang.org/en/downloads/

Hi, I am running ruby 2.3.0. It was my mistake. still no avail. Please see my screen shot for plugin error and my gem list.

super weird, shouldn’t happen.
I’d try a complete uninstall-reinstall of ruby+cocoapods

Hi Ido;

I have tried reinstalling everything on different Mac and now I am able to pass the Cocoapods-keys, etc for iOS TInker. I have put cocoapods-keys as follow:
“MixpanelToken”, particle
“OAuthClientId”, particle
“OAuthSecret” particle

Now when I run Particle app on Xcode I am getting the following error on SparkDiscoverDeviceViewController.m file:

property ‘isAuthenticated’ not found on object of type "SparkCloud"

Please see my screen shot also. Do I need to set cocoapods-keys to my real account to run this app?

This is a recent change - I added isAuthenticated property just the other day and haven’t yet published a new pod version… It replaces isLoggedIn - Be sure you use latest pod 0.4.0 release and not tip of master.

Unrelated - yea Cocoapod-keys is run every install and inject secret keys to the app.
Mixpanel is used for our analytics tool - you can ignore that unless you want to use it too and then you can find the required token under your account at Mixpanel. Oauth seret/client is for setting unique key for SDK usage per app. You can use particle/particle for now

Hi, thanks for the pointer. where do I get Cocoapods 0.4.0. I can only find up to 0.39.0 on github and gem. Thanks.

re “First, download the SDK from the link on the Mobile SDK page”

Should we download “master” or release “0.5.1”?

I downloaded both, and they’re different.
I assume master has latest and greatest changes, but is not officially released. (?)
spark-sdk-ios-master
spark-sdk-ios-0.5.1