MapBox iOS SDK within your own Xcode - ios

I downloaded MapBox example from github using the following
git clone --recursive https://github.com/mapbox/mapbox-ios-example.git
Which downloaded it including all dependencies. Now I'm trying to create a separate project and include MapBox DSK as it was in that example. I tried creating workspace then creating a single view project then add new file and select .xcodepro for the MapBox DSK but didn't work when I tried importing MapBox.h file. I never tried importing 3rd parties API before and a bit not sure how I can do that correctly. Any Idea how I can accomplish that ?
Thanks in Advance

Just try:
#import <Mapbox/Mapbox.h>
instead of just importing Mapbox.h as suggested here:
https://www.mapbox.com/blog/ios-sdk-framework

You simply drag the Mapbox-ios-sdk project file from Finder to the files pane in Xcode.
And then click the project in Xcode files pane, Target-->Build Settings. Search for "User Header Search Paths". Specify where the MapBox sdk is located.
What I do is I put the MapBox-iOS-sdk in my project directory. And I set the path as $(SRCROOT) and make sure to set it as recursive.
While you're at it also make sure -ObjC and -all_load are set in Other linker flags.
That only helps you reference the .h files, to link, also under Build Setting, Link Binary with Libraries you need libMapBox.a.
If there is a MapBox.bundle (as in the latest development branch) in the group and files pane, you want to drag that into Target->Build phases->Copy bundle resources as well. (The add button doesn't work for me.)

I think the best way is to look at mapbox-ios-example provided by MapBox and try to replicate all dependencies into your own project.

A bit late but I did it like it was explained here: http://mapbox.com/mapbox-ios-sdk/#binary.
Not messing around with git, just dragging things into your project, easy!

I think problem here is he couldn't find a specific 'file' that was titled "MapBox.Framework" inside the folder of resources downloaded from Map Box, however what you actually need to do is copy that whole folder, which is titled "MapBox.Framework" into the frameworks section. I think the confusion was that the main folder that needs to be copied doesn't look like the yellow framework icon until you copy that folder into Xcode's frameworks section.

Related

Adding an Xcode subproject: Shouldn't all the source files get copied?

I am manually adding the SQLite.swift subproject to my project. As the directions indicated, I copied the .xcodeproj file to my project. This allows me see all the source files (unlike this SO question).
Everything seemed like it was working fine. However, I discovered that the source files of that subproject were not copied to my project. They are still in original location where I downloaded them. Is this by design? What if I want to share my project source code with other people in the future? They won't have the subproject source that is necessary for my project to work.
If I do need to copy the subproject source to my project, then how do I do that?
Add it to your filesystem-structure first. For example by pressing "Show in Finder" on the "Chimee"-project which will lead you to the folder it's located in. Then copy the SQLite-project structure in there.
Afterwards you can then drag&drop the xcodeproj into your project which will then still link to its original path, but as it's now inside your project-structure isn't a problem anymore.
I guess that this is by design, because when you try it via Add files to "YourProject" you can select the Copy items if needed-option but it will still not get copied (only with .xcodeproj-files, it works with all other filetypes)
After doing more research, I now feel that using a dependency manager (like CocoaPods or Carthage) is a better option than manually adding the framework to the project.
This will allow easier updating in the future.
Github source code sharing and App Store submission issues have already been considered.
Using Carthage is not too difficult if you follow this excellent guide: Carthage Tutorial: Getting Started
Notes
Delete the framework files that you manually copied in before installing the framework with Carthage.
I will leave #TMob's answer as accepted for now, but I am no longer pursuing that route.

Trouble with an .h import

As a beginner in ObjectiveC I need some help.
I'm working on a phonegap plugin for IOS (so, written with objective C). I use some open source code but I got an error with an .h import.
My architecture look like:
myFmk.framework/
myFmk.framework/ABCDE/myFmk.h <== in a sub folder
myFmk.framework/myFmk <=== this is a file
myPlugin.h
myPlugin.m
In myPlugin.h I have #import and in "myFmk.framework/myFmk" file I have only one line "ABCDE/".
I thought that this file do a redirection of the absolute import (with brackets) but my complier told me that "myFmk/myFmk.h" is not found.
I tried to find some documentation about this feature but I wasn't able to find its name... do you have this documentation or the feature name?
Thks.
Is the framework added using a cocoapod? If not, did you follow the instructions properly for adding it to your project? It would probably help if you posted the framework you are experiencing problems with.
If this is a framework that is added to your project properly and you are unable to import there are a few things you should check. First, go to your project settings (click on the project at the very top of your file tree in the left column) and then look for "linked libraries". See if the library is listed there. If not click the + and try to add it.
If this framework was added via cocoapods another thing to check is search your file structure for libPods.a. If it is red, I find sometimes it is helpful to delete it, close the project and run pod install again.
Also if you installed the project via cocoapods remember to open the workspace and not the old xcode project file.
I have also experienced this problem when my header search paths and other linker flag paths were wrong. Linker Flags should be $inherited if this is a cocoapod. In my projects most Header search paths are $inherited too.
If none of this is helpful please provide more information such as how this framework was added to your project and what the framework is. Also let us know if you get any error messages.

finding the framework of a cocoa modules

I just followed a tutorial https://medium.com/#PyBaig/build-your-own-cocoa-touch-frameworks-in-swift-d4ea3d1f9ca3 for creating your own cocoa touch framework. There is one step where you need to right click a framework and it shows in finder, but it is not working for me. I can right click any other file and show in finder just fine. Any suggestions on how to find the framework file for dragging into another project?
well according to some apple doc I found:
Note: The standard locations for frameworks are the
/System/Library/Frameworks directory and the /Library/Frameworks
directory on the local system.
If it isn't in those directories, it is probably some custom path that would be specified on the CC line in the build output, and if you were really hard up, you could click the diff editor on the Xcode project and search for something.Framework, where something is the framework you are looking for.
... it is also possible that it is a framework that is build by a sub-project, and for whatever reason, it haven't been built yet.

Framework header file not found (iOS pop framework)

I'd like to install facebook's pop framework. I have a multi-project workspace which is not using cocoa pods. I want just the simplest, dumbest, quickest install.
From the pop readme:
"... you can add the project to your workspace and adopt the provided configuration files or manually copy the files under the pop subdirectory into your project. If installing manually, ensure the C++ standard library is also linked by including -lc++ to your project linker flags."
I added pop.xcodeproj to my workspace.
I added "pop.framework" to to
the project that needs pop (general > linked frameworks and libraries).
I added "-lc++" to my project linked flags (in the project that needs pop).
Added #import <POP/POP.h> to my .m file.
The result: "POP/POP.h" not found.
I guess I'm doing something wrong, but absolutely no idea where to start looking.
I set the Built Setting of my project, then it worked.
User Header Search Paths = $(SRCROOT) // recursive. Pop is placed in the directory
Always Search User Paths = YES
This setting worked for me:
in podfile:
pod 'pop'
in project > target > build settings
always search user paths YES
add search path:
Take a look at this:
How to add facebook open source code pop to project directly
I also discovered that the -lc++ flag actually caused a linker error. I followed the instructions in that link and removed the flag and everything worked!
You could try this...worked for me as I'm also adding pop as static library, instead of using CocoaPods:
Download source code from this tutorial, because we'll be adding the library files with quotes "POP/POP.h" instead of < POP/POP.h > and all files are already changed here, just copy/paste the "pop" folder from the example project to your project: http://tapity.com/tutorial-getting-started-with-pop/ You can alternatively change all files you already have inserting quotes.
In your project create a subdirectory called "pop" (File/New/Group) with another subdirectory inside called "WebCore". It's important that you create these subdirectories so they will appear as yellow "folders" (instead of blue folders) and Xcode will compile the files properly. You can check if POP files are being included in Build Phases / Compile Sources.
Add the respective POP files inside these empty subdirectories respecting the same structure of the source project (i.e. File/Add Files to "project" inside each subdirectory).
Now just #import "POP/POP.h" and start using pop animations. Doing this way there's no need to add pop.xcodeproj to your workspace.
After trying all of these solutions, what worked for me was actually was lowering the Deployment Target from 9.3 to 8.0.
Be careful of the order of your framework search paths. I had another project which I was referencing modules from that had a different version of the framework library and because that project was higher in the framework search path ranking it was picking up the incorrect header files too.
Those who suffers from it. My problem was like this,
I was having trouble with swift and xcode 8 build times. So i changed my scheme Edit Scheme -> Build -> Find Implicit Dependencies (Uncheck). I was not get trouble with simulator i was having trouble with device. So when i change it to check again it worked. And then made uncheck or vice versa.

Lexical or Preprocessor Issue 'FacebookSDK/FacebookSDK.h' file not found

I just add facebookSDK.framework in ios project through this document :Getting Started with the Facebook SDK for iOS
I have successfully build and run my Xcode project by following it. But when I copy my Source code and run it on another PC following error is coming
"Lexical or Preprocessor Issue 'FacebookSDK/FacebookSDK.h' file not found"
I was also add facebookSDK.framework in my Project's resource and try again but not solve it.
So, Please tell me how to do for run this project in other place.
I have a very similar issue, but in my case it is with the Amazon Web Services SDK instead of the Facebook SDK. For me the problem turned out to be related to my framework load path.
Solution: Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Double-click it and add a new search path: . and make it recursive. Clean and build.
This assumes that your framework is stored somewhere inside your project directory. If not, change the new search path as needed.
I had this problem and fixed it by doing this:
Delete the FacebookSDK framework from your project.
Delete any references to the Facebook SDK from your "Framework
Search Paths" and "Header Search Paths" in Build Settings (be aware
this setting exists both under 'Project' and 'Target', so clear it
from both places)
Clean your project, save and quit.
Relaunch your project.
Re-add the Facebook SDK framework by dragging into your project.
Compile. At this point, it was fixed for me.
In my case I did things similar to you (one thing is different), it worked for me. The steps are below:
Go the FacebookSDK directory, select FacebookSDK.framework, right click and press get info then copy the file path.(something like : /Users/macbook/Documents/FacebookSDK)
Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Double-click it and paste the file path that you just copied.
Be aware this setting exists both under 'Project' and 'Target', so paste it in both places.
Clean project and build. This time it should work.
My solution to the Lexical or Preprocessor Issue - file not found error, was as follows:
Go to Xcode => Project Target => Build Settings => Search Paths
Then insert the following path in both Framework Search Paths and Library Search paths, using your own project name in this path:
"${SRCROOT}//project name/facebookSDK/framework"
I solved this error message by dragging the DeprecatedHeaders folder from the Facebook SDK (it lives in FacebookSDK/Versions/Current) into the Frameworks folder, next to the FacebookSDK.framework.
Adding all manner of search paths (including . as suggested above) did not help, nor does the answer from Mr_bem help - the .m file already existed in the "compile sources"
This may not directly help with the OP's question, but may hopefully help others like me.
In my case the problem was with MillenialMedia SDK:
Lexical or Preprocessor Issue 'MillennialMedia/MMSDK.h' file not
found
It was solved by removing SDK frameworks from project, moving frameworks to Project's top-level folder (Where stored .xcodeproj File). And then adding Frameworks to Project in Build Phases.
Sometimes you need to re-download SDK archive form official website (if it was corrupted or something like that). In my case it was happened after pushing my project to remote repository from office computer and pulling it from home computer.
Removing frameworks
Moving framevorks from inner folder to top-level Project folder (Same folder, where your .xcodeproj file is stored
Adding frameworks back to the project
Click on the blue icon from your files browser in xcode (the top one with your project name)
Click on targets, then build phases.
Expand compile sources.
Add your Facebook.m files there.
That should do it.
If not, just clean your project (command + shift + k), and then re-add the framework (Y).
If you have any more questions, just ask ;D
I have same problem. Maybe you used tortoiseSVN (windows) to checkout source code.
This is my problem:
Mac => submit source => Window => checkout source => Copy source from window to Mac => compile => error.
Solution: using svn for Mac to checkout source.
When I had this problem I found that the project came back clean but when I tried to run it I got the error. If I commented out the facebook.h files then it just switched to the next files in my prefix file and still created the error.
I was ready to start changing the build settings and search paths but decided to close all my Xcode projects and restart it first which worked for me.
Writing this it seems almost too obvious a thing to try but as soon as the error appeared I was onto stackoverflow and trying the answers suggested above. My situation might be rare and unique but definitely try restarting and closing everything first as it only takes 10 seconds and worked for me.
In my case it was Xcode and its lovely feature of F***ing up stuff :)
Solution: Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item. Make sure you don't have slashes before the quotes, which are usually added when you add a framework via the "Add files to..." on Xcode.
If you see slashes before the quote, remove them.
example:
\"
Should be
"
Ok guys, I think i got the answer. Follow the steps given below.
Copy your framework into your project.
Make sure it is under some directory. e.g.$(PROJECT_DIR)/project_name/Resources/Frameworks
Click on the target.
Goto Build Phases->Link binary with Libraries
Add the custom framework by clicking "Add Other"
Verify in the project navigator that the framework exists only once.
Now goto Build Settings->Search Paths->Framework Search Path and make sure that it has the following two things.
(a) $(inherited)
(b) $(PROJECT_DIR)/project_name/Resources/Frameworks.
Not to remind the framework exists inside the "Frameworks" folder
Make sure that there is nothing in the library search path.
Now click on the project (above target)->Build settings and repeat steps 7 and 8.
Now clean the project and build the project.
Hope it works.
Please remember not to keep any folder names with spaces. If you have kept them, make sure that you provide the correct escape characters.
I had same problem and find out the reason of this error in my case is because there are more then one "facebookSDK.framework" can be found in the "Framework Search Paths".
You can check all "Framework Search Paths" in your project and make sure Xcode only can find one "facebookSDK.framework" in those paths.
The values in Framework Search Paths and Header Search Paths were initially the same that mentioned here by others.
I checked to link the library manually by dragging it to the Xcode.
FB SDK's library were already present as well.
The problem was with the folder name of downloaded SDK
I renamed it to FacebookSDK and got my app up and running
If you are using this command line for the facebook plugin on IOS
cordova -d plugin add /path/to/cloned/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
And you see the FacebookSDK.framework in your Frameworks but you are unable to expand it.
Go back and use cordova plugin remove phonegap-facebook-plugin then
git clone https://github.com/Wizcorp/phonegap-facebook-plugin.git and then re-add the facebook plugin.
vote539 is correct, but...
Blockquote Go to "Build Settings" in Xcode, and under "Search Paths" there is a "Framework Search Paths" item.
Then double-click the current paths for "Framework Search Paths".
A window will appear. For the item $(PROJECT_DIR)/yourAppName, change from recursive to recursive.
The cause of the issue is that you put your frameworks in a subdirectory, rather them being in the root directory.

Resources