Correct path for #import of iPhone Frameworks (ALAssetsLibrary.h) - iphone

This may be the easiest points out there but it is stumping for some reason. I am trying to include the AssetsLibrary Framework and having issues with getting the compiler to see the actual include file for ALAssetsLibrary when using relative paths.
I am currently using:
#import </Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAssetsLibrary.h>
And this works but is oh so bad in that it calls out the device and specific OS build. I have added the framework and everything links and runs. I just really do not like using the above absolute path and cannot get any relative paths to work. I have tried many combinations of using quotes ("") and braces (<>). Various relative paths to just System, Library, System/Library...
XCode specifics:
XCode 3.2.5
Component versions
Xcode IDE: 1760.0
Xcode Core: 1763.0
ToolSupport: 1758.0

Found it. Don't know why I did not think of this earlier...
#import <AssetsLibrary/AssetsLibrary.h>
Simple.

In Swift:
Please first of all add the AssetsLibrary framework to your Xcode project: click on the name of your project in the project navigator < Then click on the name of your project under TARGETS < Then click on Build Phases < Then click on Link Binary With Libraries < Then click on the "+ button" and add the AssetsLibrary.framework
Finally add this import below at the top of your swift class:
import AssetsLibrary

Related

Can Swift playgrounds see other source files in the same project?

I created the most simple custom class in a separate Swift file in my project:
class Foo
{
init()
{
println("I made a foo.")
}
}
Then, in a playground within the same project, I tried
var x = Foo()
Xcode didn't seem to like this, and told me that 'Foo' is an unresolved identifier. I'm somewhat confused about how playgrounds fit into the rest of the project structure, since any other Swift file in my project can resolve 'Foo' without issue.
How can I make my playground able to use custom classes I define in other Swift files in my project? I have tried naming the product module for the build target and importing that into the playground, with no success: the playground doesn't recognize the name of the product module.
Thanks in advance for the assistance. I know it is something simple.
There's two ways to use your project's code in a Playground
Playground's Sources Folder
Yes, in Xcode 6.3 Beta 3 (and hopefully, into the future):
Playgrounds are now represented within Xcode as a bundle with a disclosure triangle that reveals Resources and Sources folders when clicked. These folders contain additional content that is easily accessible from your playground’s main Swift code. To see these folders, choose View > Navigators > Show Project Navigator (or just hit Command-1).
Open up a new playground and hit cmd + 1 to see the left pane, then drag files into the source folder to use within the playground.
Note:
The files in the source folder are compiled to a framework which means if you want classes, functions, etc. to be accessible in the playground, they must be explicitly marked as public.
public class VisibleClass {
}
class InvisibleClass {
}
Source: release blog
Compile Project Into Framework
Move project to workspace if it isn't already. (File -> Save as Workspace) will do the trick
Add framework target to your project
Build framework
Make sure files you want to access are added to your framework target
Add Playground to workspace (NOT the project)
Use #testable import YourFrameworkName
Access code in playground
I made a write up here that goes into a bit more detail if you want to check it out.
They cannot. Playgrounds are self-contained. This will hopefully change in the future.
Edit: As of Xcode 6.3, Playgrounds can now contain supporting code. They still cannot see other code in the same project, but code can be added to the support folder of a Playground that can be used from within the playground. See the Swift blog for more info.
Yes.
I started by just adding a class file in the Sources directory.
I made everything public:
class
init
members
After much trying, nothing worked. The XCode crashed and after reopening it all worked like a charm.
In Xcode 10's Project Navigator:
Add the source code file to the playground's Sources folder.
Drag the file from the playground's Sources folder to the desired location in the project (you should see the little "plus in a circle" icon appear.
End the drag and then in the Add File dialog uncheck "copy if needed"
The source file now "lives" in the playground package; the Project refers to it (you can verify that with the File Inspector).
I tried it the other way around: file lives in project folder with reference in playground's Sources folder but it didn't work; I ended up with two copies of the source code file.

cassert file not found but i use Box2d template

i am using cocos2d template with Box2d but when i import Box2d.h in my project it gives me error
cassert fiel not found
i have cocos2d version 2.0
please help me
Make sure all your project's source code files have the file extension .mm and not .m. Or set each .m file's type to Objective-C++.
change your file extension .mm thats it
Changing extension in xcode 4 will not work. Instead go to build settings (tab) and change C++ standard library setting to libc++ (LLVM...) from compiler default.
If you build it now you will get an error saying app is not compatible with iOS 5 or later. So go to summary (tab) and change deployment target to 5.0. It should now build successfully.
Here is how I fixed the issue. Cleaning up and recreating the project didn't seem to be a good idea for me.
There are a couple of answers on the web for this issue but they in each didn't help me solve the problem. One is on SO at
cassert file not found but i use Box2d template and the other is on cocos2d-iphone forum,
http://www.cocos2d-iphone.org/forums/topic/cannot-include-box2d-cassert-file-not-found-despite-every-file-being-mm/
Combining the two suggestions kind of worked for me -
Rename all YOUR (not cocos2d or box2d files, just your project files) from .m to .mm
Make sure that on each of the files, on the right pane, “Type” option is set to “Default – Objective C++ Source”
There was another issue for me specifically, may not be an issue for you, I was using the following signature for CCLabelTTF
CCLabelTTF *title = [CCLabelTTF labelWithString:#"Hello" dimensions:CGSizeMake(720.0f, 880.0f) alignment:UITextAlignmentLeft fontName:#"Arial" fontSize:34];
This is deprecated and caused errors all over the place. I am now using the following slightly modified version and the errors fixed -
CCLabelTTF *title = [CCLabelTTF labelWithString:#"Hello" dimensions:CGSizeMake(720.0f, 880.0f) hAlignment:kCCTextAlignmentRight fontName:#"Arial" fontSize:34];
My most recent writeup of this fix can be found at - http://indiangamer.com/how-i-fixed-the-cocos2d-box2d-include-file-not-found-error/
For those like me : I just tried to reopen a very old xcode project and got this error with cassert files.
Just setting the target to a new one (iOS 13 in my case) made it automatically select the correct version of the c++ stdlib and everything worked just fine.

SDWebImage/UIImageView+WebCache.h file not found while archiving [duplicate]

I am fairly new to ios development - trying to use sdwebimage in my iphone project. I believe I completed all basic setups as required. But when I build, I get this error: No such file file or directory near this line:
#import "UIImageView+WebCache.h"
Yes I have added Target Dependencies
I have added libSDWebImage.a in Link Binary With Libraries
I have -all_load -ObjC in Other Linker Flags
I also tried the -force_load ${BUILT_PRODUCTS_DIR}/libSDWebImage.a (64bit mac)
My Use Header Search Paths is : $(BUILT_PRODUCTS_DIR)
I cleaned the project and rebuilt - but no use.
Build keeps failing. Again, XCode4 code completion "resolves" when I type #import "UI & hit "ctrl+space" which means the lib is visible to xcode. Any pointers will be super helpful. Thanks.
To add the needed header files to the build path do the following.
Select your project file
Select your target
Select Build settings
In the search box enter 'header search paths'
For the Release add "$(SOURCE_ROOT)/SDWebImage" (thats with quotes).
This will work when importing like this #import <SDWebImage/UIImageView+WebCache.h>
I also use SDWebImage.
In my experience I didn't do anything with the linker flags etc.
You only have to add the classes in your project and simply import the "UIImageView+WebCache.h" in your class' header like this:
#import "UIImageView+WebCache.h"
and if you want to use it on an UIImageView object, just use the method
setImageWithURL:placeholderImage:
you can refer to their github for more info
I just ran into this problem and have solved it.
The issue is that when you "drag" the SDWebImage xcode project to your project, Xcode only create a reference to point to those files needed. When you are in debug mode it's fine, it knows where to find those file. However, when you want to archive it (packing everything to be self-contained), it couldn't find it from your search path.
Although you have added $(BUILT_PRODUCTS_DIR) to your search path, but if the actual files that you downloaded are not physically located in your $(BUILT_PRODUCTS_DIR), then Xcode won't find them. This was the problem for me since my SDWebImage files were still sitting in my download folder.
What you want to do is:
1.Move the SDWebImage folders to a place where you won't accidentally delete it. Notice once you've done that, the SDWebImage project file will become red since it's physical location is moved. And it's wired that I could not delete that reference in Xcode, what I ended up doing is add that file again (choosing from the location where I just move it too). You will end up with a red SDWebImage.xcodeproj in your project navigator which you can not delete. It's very annoying but it won't affect anything.
2. If the location you move the SDWebImage stuff to is not in your $(BUILT_PRODUCTS_DIR), then you either move that inside $(BUILT_PRODUCTS_DIR) or as I do, add the path to Target -> Build Settings -> Search Paths -> User Header Search Paths.
Archive and it should work now.
I faced this same problem and was about to go crazy. Like Ravi, I followed the static installation instructions as closely as possible.
I saw the auto suggest for UIImageView+WebCache.h when I was typing #import, but it keeps throwing file not found.
In the end, it was this. In header search paths,
“$(BUILT_PRODUCTS_DIR)” - Wrong.
$(BUILT_PRODUCTS_DIR) - Right.
Embarrassed but now it's working right =)
I've been dealing with this problem for the past hour and noticed something that hasn't been mentioned: Make sure that when you up update header search paths that the "Recursive" option is selected! Otherwise the compiler will not check subfolders.
Worked for me...
I was dealing with the same problem, my two frameworks were not getting found. I tried all the suggested ways in order to resolve the error but it couldnt help. Atlast I deleted the frameworks from my project structure and reloaded them from the original project file and it worked!! Please try this if it helps, It worked for me...
I had a similar issue after pod update. If you are using CocoaPods version higher than 1.0.0 and more than one target in your project, you have to add all the targets into the Podfile.

Cannot compile my app with few classes from the Google Mac Toolbox

UPDATE:
Here is more detailed compiler output:
So I am working on a simple app. I want to be able to do some encoding/decoding of strings, so I have added these three files from the Google Mac ToolBox to my project:
GTMDefines.h
GTMNSString+HTML.h
GTMNSString+HTML.m
Since my project uses ARC, I have added the files to the build phases and set the -fno-objc-arc flag so they don't compile with ARC. See the screenshot:
Now I go to my main view controller and add this line:
#import "GTMNSString+HTML.m"
And I try to compile my project. I get errors like these:
How can I solve this? I am new to iOS development so please explain well.
To get rid of the first two warnings (no rule to process file...) remove GTMDefines.h and GTMNSString+HTML.h from your "Compile sources". Only .m-files need to be there.
You never want to import .m files, even if it's technically possible! To get rid of your errors, change your import from
#import "GTMNSString+HTML.m"
to
#import "GTMNSString+HTML.h"

XCode cannot find foundation.h or UIKit.h after MediaPlayer.framework is added

As soon as I add the MediaPlayer.framework into a new program, XCode absolutely shits its pants. Under supporting Files, PROJECTNAME-Prefix.phc starts red-flagging both #import and #import
Why is it doing this? I have tried to create a new project and re-adding the Framework, but even if that is all I have done, it gives 4 errors on the first failed build.
if you are using xcode4 don't slide the framework in the project: it edit the framework search path and do the error you describe.
Try deleting the framework search path in project "build setting" and for adding the framework use "target" "build phase" "link binary with library".
hope it help and sorry for my poor english.