This all started when I changed my_sound.mp3 to another sound with the same name in 'Supporting Files' folder, but after compiling app was still playing the old one. After that I've done a lot of manipulations.
What I've tried:
Delete app from iPhone and from Simulator
Delete all from Library/Developer/Xcode/DerivedData
Product > Clean in Xcode
Now my app don't see my_sound.mp3 at all...
How I check:
NSString* path = [[NSBundle mainBundle] pathForResource:#"my_sound" ofType:#"mp3"];
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSLog(#"No file");
}
Files created long time ago in 'Supporting Files' are available.
"Is my_sound.mp3 listed with the correct name in the "Copy Bundle Resources" section of the target's Build Phases?" – Phillip Mills Aug 4 at 19:00
Related
I am writing an Objective-c++ application and I am trying to reach the applications Contents folder.
Let's pretend my apps name is MyApp.app. If I run my application from Xcode then I can reach the Contents folder like this:
std::fstream file;
file.open("MyApp.app/Contents/some_text_file.txt");
if(file.is_open()) {
...
}
else {
...
}
But If I run my built application without Xcode, then file.is_open() fails.
[[NSBundle mainBundle] bundlePath] will give you the path of the MyApp.app directory. You can then add Contents to that path.
Alternatively, [[NSBundle mainBundle] resourcePath] will give you the path to the MyApp.app/Contents/Resources directory. You can then remove the subdirectory from that path; see Working with paths from [[NSBundle mainBundle] resourcePath]
Use NSBundle class to get informations on your application bundle.
[[NSBundle mainBundle] bundlePath] give you full path to MyApp.app.
I have the following problem:
I included a static library of FontConfig libfontconfig.a into my iPhone project.
The application is building and i can run it on the device but when I do a call to a method that needs some functions of this library the application crashes with the following error
Fontconfig error: Cannot load default config file
terminate called throwing an exception
I read that this error normally occurs when FontConfig cannot find the fonts.conf file that is normally located in /etc/fonts.
But I cannot move that file to this directory of the iPhone. Has anyone a solution? Just copying the file to the application bundle did not help, as well.
I would appreciate any help.
I finally found a way to solve this problem. I set an Environment Variable FONTCONFIG_FILE and FONTCONFIG_PATH that define the locations of the fonts.conf file and the path that was before /etc/fonts. So I can add the fonts directory to the project and define the path #runtime.
The Environment Variables have to be set in your code before you call a method that needs a functionality of FontConfig. I set it after starting my Application in the AppDelegate.
Here is the code I added:
//Get the directory of your Application
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
//Create a String with the location of your fonts.conf file
NSString *fontconfigFile= [bundlePath stringByAppendingString:
[NSString stringWithFormat:#"/fonts/fonts.conf"]];
//Create a String with the path of the FontConfig configuration path
NSString *fontconfigPath= [bundlePath stringByAppendingString:
[NSString stringWithFormat:#"/fonts"]];
//Set the Environment Variables
setenv("FONTCONFIG_FILE", [fontconfigFile UTF8String], 0);
setenv("FONTCONFIG_PATH", [fontconfigPath UTF8String], 0);
In a second step I had then to modify my fonts.conf file. I added the fonts directory to FC/fonts and the cache directory to FC/cache of my project and adjusted the fonts.conf file on two parts.
I changed the first part:
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/X11R6/lib/X11/fonts</dir>
<dir>~/.fonts</dir>
to:
<!-- Font directory list -->
<dir>FC/fonts</dir>
and the second part:
<!-- Font cache directory list -->
<cachedir>/opt/local/fc1407cd/var/cache/fontconfig</cachedir>
<cachedir>~/.fontconfig</cachedir>
to:
<!-- Font cache directory list -->
<cachedir>FC/cache</cachedir>
Then it did not crash anymore.
I am gettings insane, I can't figure it out.
I have downloaded and tries to build XMLRPC for iOS. I triend with https://github.com/eczarny/xmlrpc and https://bitbucket.org/kdbdallas/xmlrpc-ios/wiki/Home
The first one, the original one, doesn't have an iOS target. the second one should have, but even that one doesn't seem to work.
I build XMLRPC-iOS lib using XCode the following way:
download, unzip, open in xcode
Go to menu Product > Archive
In organized I choose "Share" on the latest build
I save it in my own project folder. Include it in the project.
When I build my own project I get:
ld: warning: ignoring file
/Users/paulp/Documents/ios/iPhone/ios-account/Account/external/XMLRPC/libXMLRPC_iOS.a,
file was built for archive which is not the architecture being linked
(i386) Undefined symbols for architecture i386:
"_OBJC_CLASS_$_XMLRPCRequest", referenced from:
objc-class-ref in MyAPI.o
"_OBJC_CLASS_$_XMLRPCConnectionManager", referenced from:
objc-class-ref in MyAPI.o ld: symbol(s) not found for
architecture i386 clang: error: linker command failed with exit code 1
(use -v to see invocation)
How is that possible? The XMLRPC-iOS settings are set to:
SDKROOT = iphoneos5.0
ARCHS = $(ARCHS_STANDARD_32_BIT) = armv7
IPHONEOS_DEPLOYMENT_TARGET = 5.0
VALID_ARCHS = armv6 armv7k armv7f armv7
OTHER_CODE_SIGN_FLAGS = armv7k armv7f armv6 armv7
GCC_VERSION = com.apple.compilers.llvmgcc42
Can someone explain for me how I can build and use the XMLRPC-iOS library in my own application?
Thanks!
it worked for me; here is exactly what i did.
Create new project (called RpcTest)
Download the forked project from bitbucket, extracted the zip in my RpcTest directory, so my directory looks like this:
Drag the XMLRPC-iOS.xcodeproj into my Xcode project (under Frameworks group, but this doesn't matter)
Now, to the build settings. Add kdbdallas-xmlrpc-ios-f28a13cc16ae under User Header Search Paths (uncheck recursive) in your project's Build Settings; now build your project (cmd+B)
go to Build Phases tab, expand Target Dependencies, add XMLRPC-IOS project, expand Link Binary With Libraries, add libXMLRPC_iOS.a.
Now you should be able to include any xmlrpc header and use the lib.
Hope that helps.
EDIT
Download via Dropbox.
be advised: incomplete implementation, just a demo that xmlrpc works! ;)
I've used the first one you mention https://github.com/eczarny/xmlrpc with success in an iPhone project.
Should be working. (was some time ago)
[EDIT]
Some more details :
I imported XMLRPCResponse and XMLRPCEventBasedParser (+ all related classes to get them working from the project).
Then, here's the code to parse a response (I was doing the request by hand):
NSURL* url = [NSURL URLWithString:#"http://www.xxxxxxxxx.fr/xmlrpc.php"];
NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:#"POST"];
[urlRequest addValue:#"text/xml" forHTTPHeaderField:#"Content-Type"];
NSString* param = [NSString stringWithFormat: #"<param><value><double>%f</double></value></param><param><value><double>%f</double></value></param><param><value><double>%.0f</double></value></param><param><value><int>1</int></value></param>",
request.coordinate.latitude,
request.coordinate.longitude,
request.radius/1000.0];
NSString* xmlrpcReq = [NSString stringWithFormat:#"<?xml version=\"1.0\"?><methodCall><methodName>geoSearch</methodName><params>%#</params></methodCall>", param];
[urlRequest setHTTPBody:[xmlrpcReq dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* content = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
XMLRPCResponse* rpcResponse = [[XMLRPCResponse alloc] initWithData:content];
if ([rpcResponse faultCode]==0) {
NSArray* result = (NSArray*)[rpcResponse object];
Cheers
Lionel.
May i know what target you are setting ? for example three target available, if you using for iOS, please select libXMLRPC then build then select the libXMLRPC.a files from the build and then link it to our project. then it will run.
I am using Xcode 4. I have copied
several images to main folder, I
have built project, next I have
deleted all images. When I list
resources path by NSLog, I can see
that there are still in this
package. I've deleted build folder,
clean etc. What should I do to
delete this files from my package
And second question. Why when I copy
an entire folder, and list files and
directories by:
NSFileManager *fm = [[NSFileManager alloc] init];
NSString *string = [[NSBundle mainBundle]resourcePath];
for(NSString *name in [fm contentsOfDirectoryAtPath:string error:nil])
{
NSLog(#"%#", name);
}
In console a can only see files from this folder.
Have you deleted the project from simulator ? You can do it in the Simulator app or deleting the project folder at ~/Library/Application\ Support/iPhone\ Simulator/
I have a main project and a static library project inside the main project. I want few plists in my static library project. Since there is no resource directory it is not possible to add plists directly, What is did is this.
1.Added a loadable bundle to my static library project
2.Added few plists to loadable bundle
3.This loadable bundle is made as a dependency to my static library project
4.Added this loadable bundle as a dependency to my main project as well
Am i going on the right path ? when i fired the build and used show contents to see the contents of the app i was able to see the .bundle file inside the .app file. Right now i want to know how to access this bundle . .
i used this
NSBundle *staticlink = [NSBundle mainBundle] pathForResource:#"MyBundle" ofType:#"bundle"];
[staticlink load];
NSLog(#"%#",staticlink);
console said this . .
. . . /mainproject.app/MyBundle.bundle <not yet loaded>
What is missing ? what should i do load MyBundle ?
-pathFoResource:ofType: returns a NSString object which will have the path to the bundle.
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:#"MyBundle" ofType:#"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
[bundle load];