Can't include FMOD on iOS - iphone

I don't think I'm including the FMOD library correctly. I'm getting the following XCode error:
expected specifier-qualifier-list before FMOD
I'm using XCode 4 and the latest version of the FMOD library. I went into the "Link Binaries With Libraries" section in XCode and added libfmodex_iphonesimulator.a.
Any ideas on what I could be doing wrong?
Thanks!

Here is a step-by-step process for getting FMOD running in an iOS application:
File -> New Project
iOS -> Application -> Window based application
Choose name and location (I used 'test' and the FMOD examples directory as the location)
Assuming you named the app 'test', rename 'testAppDelegate.m' to have the extension '.mm' to allow C++ code.
Edit 'testAppDelegate.mm' to have #import "fmod.hpp" at the top.
Project -> Edit project settings (ensure Configuration at the top is set to All configurations)
Go to "Other linker flags" and type in -lfmodex_$PLATFORM_NAME
Go to "Header search paths" and type in ../../api/inc
Go to "Library search paths" and type in ../../api/lib (now close settings).
Right click on the "Frameworks" group on the left, choose Add -> Existing Frameworks, then choose 'CoreAudio.framework'
Repeat step 10 but choose 'AudioToolbox.framework'
Add FMOD code to 'testAppDelegate.mm' as needed, see playSound example for reference code.

After you link the appropriate library make sure you drag the 'inc' folder with all of the .h files into your project somewhere, that was my issue. Also, make sure you include AudioToolbox and CoreAudio if you did not already, and make sure to include fmod.hpp and fmod_errors.h in your view controllers header.

Related

Where is Info.plist in Xcode 13? (missing, not inside project navigator)

Has anyone figured out how to add/edit values in the Info.plist of Xcode 13 yet? I see they moved the Info.plist from the navigator pane... but although I can find it, I'm not sure how to edit it.
It's a "feature."
You don't need it anymore. From the Release Notes:
Projects created from several templates no longer require configuration files such as entitlements and Info.plist files. Configure common fields in the target’s Info tab, and build settings in the project editor. These files are added to the project when additional fields are used. (68254857)
So, instead of inside Info.plist, edit properties like NSCameraUsageDescription here:
Project -> Targets -> Info -> Custom iOS Target Properties
The first time you add/edit, Xcode will automatically generate a new Info.plist file that’s kind of synced1 with Custom iOS Target Properties. Xcode will later merge them for you.
[1]: They’re not fully synced. Some properties like NSCameraUsageDescription will only appear in Custom iOS Target Properties, while Application requires iPhone environment will appear in both. I have no idea how Xcode determines this.
Want Info.plist back, completely?
You might want all of your app's properties in one place. Or maybe you don't trust Xcode with the merging. I spoke with an Apple engineer at WWDC21 about this... here's how to get the classic Info.plist back.
Create a new "Property List" file (File -> New -> File)
Name it Info.plist
Copy and paste the existing values from Project -> Targets -> Info -> Custom iOS Target Properties to Info.plist.
Copy
Paste
Note: Currently you can only select and copy 1 row at a time. If you want to save some time, here are the default contents in XML format. To use this, right-click Info.plist -> Open As -> Source Code, then paste.
Copy the path to Info.plist in the attributes inspector.
Paste the path here:
Project -> Targets -> Build Settings -> Info.plist File
Set Generate Info.plist File to No
Last step. Remove Info.plist from Copy Bundle Resources (select, then press the - button).
Project -> Targets -> Build Phases -> Copy Bundle Resources
Yep, that was a lot. But whether you want classic Info.plist or not is up to you — both are fine and won't change your app.
Xcode 13.3.1, macOS Monterey(12.0.1)
Here is the most simple solution which work for both swiftUI and Storyboard projects, if you are not able to find info.plist and want to add target properties like Privacy - Camera Usage Description and things like we can add in older Xcode version. Here is the solution...
***> Select target of you project on top of the files click on Info on
> top of the right side, now you can see "Custom iOS properties" like
> info.plist, do whatever you want.***
Target > Info
see the image below for reference
Here is a link to a raywenderlich tutorial: https://www.raywenderlich.com/19611194-multiplatform-app-tutorial-swiftui-and-xcode-12
The sample projects uses Xcode 12.0-compatible (objectVersion = 54) project format, created with the Multi Platform app template. I borrowed the plists from this project. Until the sample project is revised, it's nice to have a reference project (structure) for comparison.
This also applies to Xcode 14. To be brief, a few pieces of information about this change:
There is a good write up of the issue here:
https://useyourloaf.com/blog/xcode-13-missing-info.plist/
There is a good YouTube video (found in this page above):
https://youtu.be/mml9ZI81VKA
This issue applies to SwiftUI projects not Storyboard. Once you make
a change to the "standard" info settings, Xcode actually
automatically creates an info.plist file in your project navigator. You can then add more custom settings in the info.plist file.

Core-Plot error

I want to use a graph in my iPhone app. I have downloaded the source code Core- Plot for it, but now when I am trying to run it I am getting an error.
clang: error: -Z-reserved-lib-stdc++: 'linker' input unused when '-c' is present
Can anyone suggest me what this error mean or how to resolve it.
`iPhone, iPod Touch, and/or iPad Application
Dependent Project Install
Because frameworks cannot be used in Cocoa Touch applications in the same way as on the Mac, the means of including Core Plot within an iPhone application are slightly different.
First, drag the CorePlot-CocoaTouch.xcodeproj file into your iPhone application's Xcode project. Show the project navigator in the left-hand list and click on your project.
Select your application target from under the "Targets" source list that appears. Click on the "Build Phases" tab and expand the "Target Dependencies" group. Click on the plus button, select the CorePlot-CocoaTouch library, and click Add. This should ensure that the Core Plot library will be built with your application.
Core Plot is built as a static library for iPhone, so you'll need to drag the libCorePlot-CocoaTouch.a static library from under the CorePlot-CocoaTouch.xcodeproj group to the "Link Binaries With Libraries" group within the application target's "Build Phases" group you were just in.
You'll also need to point to the right header location. Under your Build settings, set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the Core Plot source tree. Make sure to make this header search path recursive. You need to add -ObjC to Other Linker Flags as well (as of Xcode 4.2, -all_load does not seem to be needed, but it may be required for older Xcode versions).
Core Plot is based on Core Animation, so if you haven't already, add the QuartzCore framework to your application project.
Finally, you should be able to import all of the Core Plot classes and data types by inserting the following line in the appropriate source files within your project:
import "CorePlot-CocoaTouch.h"`
Source: core plot wiki on google
I got a solution for it here is the link.
CorePlot failed to build in XCode 4.4
Basically the issue was related to Xcode.

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.

Linking a static library to an iOS project in Xcode 4

I have a project (AQGridView) that compiles to a static library, but I can't seem to add it to my project.
Dragging in the project to my project creates a workspace, and if I try to link the libAQGridView.a file from the DerivedData directory it doesn't recognize it as a library. I'm not sure what I'm doing wrong.
This is the AQGridView project. Does anyone know specifically how to use it in an Xcode 4 project?
I do this as follows:
Drag in the static library project. If you have the static library project open in Xcode, close it now.
Select the main project in the project navigator (the project I'm adding the static library to) and in the editor, under the header TARGETS in the left-hand column, select my main project's target and navigate to the Build Phases tab.
Click the "+" for Target Dependencies and add the library icon target dependency from the added static library project.
Click the "+" for Link Binary with Libraries and add the library icon that is under the folder "Workspace".
It may also be necessary to enter a Header Search Path for the headers of the static library project if that is how the headers are linked in the static library project itself.
If you don't see the static library project as nested under the main project in the main project's project navigator, the most likely reason for that is that the static library's own Xcode project is still open. Quit Xcode and open up the main project that has the nested static library project in it without opening up the original static library project itself, and you should see it appearing as a nested project in your main project.
Xcode menu > View > Utilities > File Inspector
Select the static library file, and then set 'File Type' as 'Mach-O object code' in 'Identity and Type'.
Workspaces are supposed to make this easier, but I don't know that they do. The way I do it is create a workspace, add my main project, add my library project. Then go into the main project's build phases and add the library in the "Link binary with libraries" section and add the library. That should be all that is necessary, at least that's my reading, but it isn't. What I do is go into Xcode preferences, then to the Source Trees pane. Add a source tree that points to your static library's headers, then go back to the build settings for your project, then to the Header Search Paths key, and enter ${foo} there, where "foo" is whatever you called the source tree.
That's what works for me, though I don't know if that's the best or easiest way to do it.
Find your .a file in finder, and drag it into your project.
Select the 'copy items into destination group's folder (if needed)', and add your headers to your project.
Now, Xcode 4 should automatically link against that framework for you.
Here is what the library should look like in your project:
Follow Apple's documentation.
In brief:
Link your target against the library.
Add -ObjC to 'Other Linker Flags' (OTHER_LDFLAGS) under the target's build settings.
Also, I needed to add the library to the scheme of my main project since the library was not visible in the target's dependencies.
The Halle's answer works for me with one addition:
Check in Build Settings of the static library project the Private( or Public) Headers Folder Path value and copy it.
Add copied value to the client project Build Settings Header Search Path or User Header Search Path depending of the include directive you are using

Missing AVFoundation from existing frameworks list: How to play an mp3

I just downloaded XCode 3.2.5 with 4.2 ... I'm trying to play an mp3 file, but apparently the UI changed because I wasn't able to follow any of the tutorial instructions on how to add a framework. Finally I clicked on a little gear button then went to Add -> Existing Frameworks... However AVFoundation is not listed so I'm unable to use the following code:
#import <AVFoundation/AVFoundation.h>
AVAudioPlayer *player;
The post is asking for the "missing" AVFoundation framework. It is true that you cannot easily find it though "Add an existing framework" in some SDK versions, e.g. Xcode 3.2.
Here is the easy way to solve it, thanks to some other people who pointed it out in another forum.
Click on "Target"
Click on your app
Get Info
In the bottom, click on "+"
Now you should be able to see it. I did this and solved the issue.
Right click the frameworks group right Add -> Existing frameworks, a list of frameworks will appear just select AVFoundation framework & click add
In the "project navigator", open the "frameworks" folder and select one the existing frameworks (e.g. UIKit.framework)
Right click and select "Show in Finder" from the menu
From the newly opened folder in the finder, drag the framework folder you are interested in (e.g. OpenGLES.framework) into the "frameworks" folder in XCode
Be sure not to "copy items into destination's group folder"
Choosing "Create groups for any added folders" seems to make it
(duplicate from previous question-- just dumped it into this question as well for any one still struggling with it)