I'm having trouble adding a static library from another Xcode project (CloudApp API) to my Xcode project. My project has two targets -- a prefpane bundle, and a console application. I want to add the static library to the console application. Here's what I've done so far:
Created a new workspace
Added the CloudApp project to my workspace
Added the libcloud.a file to my "Link Project Binaries" list for the target binary
Added -ObjC to the "Other Linker Flags" setting for the target binary
Added $(BUILD_PRODUCTS_DIR) to the "User Header Search Paths" setting for the target binary
Copied all the relevant headers from the CloudApp project into my project (without adding them to the target) so that I don't get errors from any #import statements
Edited the scheme for the target binary to require compiling CloudApp first
Added relevant frameworks to the target (Cocoa, Foundation, CoreFoundation)
Doing all this worked fine when I just had a single Cocoa target (not a console application). But now I'm getting errors in the CloudApp header files I included. Basically things like this:
In CLWebItem.h:
Unknown type name 'NSImage'
Any ideas?
Create a prefix-header.pch and #import <Cocoa/Cocoa.h> inside. Make sure to compile the prefix header in your settings.
Related
Trying to create a document provider app extension for my app, returns me this error when I try to run the project after creating the app extension (just creating it not adding anything else) :
error: bridging header '/myPath/test-Bridging-Header.h' does not exist
Apparently the app extension is not searching at the right path, the bridging header is in the folder with all the classes and the app extension is looking for it at the root of the project.
Any fix?
Probably a problem with the file path you've provided.
By default Xcode will look for your bridging header file from the directory where you can find your xcodeProj file.
In XCode, go to your Project's Building Settings and search for Code Generation. Under Swift Compiler - Code Generation, verify the path you've supplied for your bridging header file.
I have a static library project included to my main project.
I followed this tutorial. It worked when I had Xcode 5. It stopped working after I updated to Xcode 6. What might be a reason? I use CocoaPods 0.35.0.
When using Cocoapods, you should not set "Other Linker Flags" manually. This is automatically set as part of the pod install process.
Part of the Tutorial that you linked to tells you to set the Other Linker Flags manually.
Go to your project and clear Other Linker Flags value on the project level and the target level (if it is in bold) by highlighting the value and hitting delete.
Once deleted, you should see the inherited value coming from the Pods.xcconfig file. Something like:
-ObjC -framework CoreGraphics
You can verify this by clicking on "Levels" to the left of the search bar.
This should have you cocoapods libraries sorted. Once this is working add the path to your static library headers by setting "Header Search Paths" to "${inherited} /path/to/static/libary/headers"
I want to work with some frameworks like glew and cg so i manually added
the needed frameworks to my project by right clicking the project -> Add files to ...
and choosing the correct framework. The problem is, when i try to include the header files,
Xcode cant find any of them. I hope this picture will help to understand:
And:
The error given is for the glew framework, but it also happens on Cg.
As you can see on the left, The needed frameworks were added.
Any idea on how i can include these headers?
After trying to add the header files manually i got an architecture error:
I dont know if this is how it should look like.
Thanks!
Before starting, remove the framework and all files you have added while trying to make it work.
Then, you have to add the frameworks in the Build Phases of your target. Then go into Link Binary With Libraries and select your framework from there.
This should do it. Your headers should be available as auto-completion after each #import directive.
If it does not work (it sometimes happens), there are additional steps I can provide to you.
Additional steps:
Go to your project settings, in the build settings:
Complete the Framework Search Paths with the path of your framework
Do the same with User Header Search Path
Then, it should work. If it does not, you will need to add the full path of your header in the #import directive. Example:
#import "/path/to/my/header.h"
Apple's documentation available here states:
In the project navigator, select
your project
Select your target
Select the 'Build Phases' tab
Open 'Link Binaries With Libraries'
expander
Click the '+' button
Select your framework
(optional) Drag and drop the added
framework to the 'Frameworks' group
In my case I have added Framework Search Paths for Target, but it should be added to Project
Also Always Search Users Path should be yes
For those whose autocomplete fails after adding framework.
I used to add frameworks, by going to Build Phases and taking the Link Binary with Libraries option. Now in XCode 6.1, though project was building fine, autocomplete in XCode was not working.
So what needs to be done is:
Remove the already added framework from Project Navigator and also from Link Binary with Libraries.
Add framework to project by simply File -> Add Files to option in XCode.
And auto complete will start working.
In my case, the external framework had been downloaded with Windows and added to the project. Then it was transferred to OSX, where the Xcode project was built and the external framework didn't load properly. I guess it is because Windows changes the framework folder to be a regular folder, which OSX then has trouble with.
Solution for me was to simply download the framework with OSX and drag it into the framework folder in the XCode project.
In my case I had to update a framework version, so I just replaced the .framework in the filesystem and then I got the error you've mentioned in the question.
Removing the framework and adding it back again, playing with the search paths and all the other suggestions didn't help.
Eventually, cleaning the build folder did the trick:
Select "Product" from the xcode menu, hold the option key and click on: "Clean Build Folder".
After that I built and ran the project successfully.
I published lite version of my iPhone-app and is in the store. Now, I want to add the code for the 'full' version and am stuck at a point.
After adding the second target in the project, the lite version compiles fine, but the full version does not. This is because the macro defined in _Prefic.pch file is not visible to the full version of the code.
Can a project have multiple .pch files? If no, how do I specify XCode to share the .pch file with both targets?
Right-click on your target and choose "Get Info". In the "Build" section search for "Prefix Header" setting and look at its value. Set the value as needed (to a new file or to already existing one).
I have a static library project that I inherited from another developer. I added a class to the project and built it. When I include the static lib in another project, the build fails with a symbol not found error for the class that I added.
I looked at the build logs for the static lib project and I noticed that the .m file isn't compiled. The file is clearly visible in Xcode, right next to all of the other class files. Can anyone think of a reason that the file wouldn't be built? How does Xcode discover the files that it builds?
Make sure the new file is included in the target you're trying to build.
Click on the filename in the left pane of XCode and open the inspector (command-I), then look at the "targets" tab to verify that the target you're building is checked.
If necessary, you can also expand the target (in the left pane) to see the build steps, and drag the file directly into the build step (for example "Compile Sources") where it needs to be.