How to ignore some static library for iOS simulator - iphone

I am trying to build my project for sdk iphoneos and iphonesimulator. There are few .a static libraries that can only be utilized for iphoneos. Where can I go an ignore these files if its being build for iphonesimulator within XCode?
Thanks.

Instead of hard linking the libraries, use the "Other Linker Flags" setting in the project configuration settings. You'll be able to link different versions of libraries based on the current build configuration.
By default you already have Debug and Release build configuration, press the "plus" button on the Debug will add a configuration for a specific architecture. Choose "Any iOS Simulator" and link the libraries you would like to use to run the app on simulator. Then press the "plus" button on the Debug again, this time choose "Any iOS" and link the libraries you would like to use to run the app on the device.
Lastly, do the same thing for the Release configuration.

You can set two targets, one for simulator and one for device, and in the simulator target settings (Build Phases -> Link Binary With Libraries) remove the unwanted *.a files

I just had this issue and I solved by creating a new target just for the simulator.
At the new target you can go to the target settings -> build phases -> link binary with libraries and removed the static library just for that target.
Also make sure you do not include the files from the static library by using the TARGET_IPHONE_SIMULATOR macro for checking, just as #MDT did.

Related

Iphone Linker Error – “class.o for architecture i386" confused?

I am getting error Linker Error – class.o for architecture i386 on xcode project while i try to build the project. on my project i have used some third party framworks as well. any solution for this ??
To break down this issue here are some tips.
1>Make sure to included the QuartzCore framework or other required frameworks in your project. It should be in the Build Phases->Link Binary With Libraries.
3>Check while switching to the new version, you put the new library in a folder next to the old one, in case you had to switch back at some point. Normally when you removed the old version, it did not remove the path to the old version of the .a file from Library Search Paths in the build settings in "Project Name -> Under Targets" and delete the old path and add new one if required.
2>To add new class please select Project Name -> Under Targets select your target project name -> Build Phases -> Expand Compile Sources -> Click + at bottom of Compile sources and add the correct source file.
4>If the above tips are not working for you then be careful while adding files , don’t copy files directly, just create class by clicking on "new files" in Xcode and copy code one by one and add required frameworks. it won't show linker error .
I believe the class is not in your compile sources list.
Select your project on the navigation sidebar -> goto "build phases" -> expand "compile sources" -> add the corrensponding .m file for your class
Please check the class for which you are getting error message is linked to the target you are building.
Also make sure the third party library you are linking into project is properly linked and also linked at runtime of the project.
That is sure that application is able to find the class which you have mentioned at runtime.

xcode 4.3.2 archive build not creating dsym

I have an old project developed with Xcode 4, i remember doing xarchive on Xcode which generated dsym properly. but on the latest version that is x 4.3.2 the xarchive created doesn't have the dsym file. i verified the setting these setting
dwarf with dsym for both debug and release
what else is causing issue, is there any other setting which i should take care ? please advice a way to fix this issue.
note: i selecting archive-debug and not archive release in the scheme. thanks.
Verify that the Generate Debug Symbols are set to YES in Build Settings. Make sure you clean your target before compiling. After doing so, make sure you're looking for the .dSYM in the right location.
Right Click Archive from Organizer and Show In Finder
Right click .xarchive File and Show Package Contents
Navigate to dSYMs directory.
Identifying the problem
Check your build settings for both release and debug configuration:
Generate Debug Symbols → Yes
Debug Information... → DWARF with DSYM
Deployment Postprocessing → YES
Strip Linked Product... → No
Strip Debug... → No
Try check the Report Navigator.
In my case, the dSYM file has not been generated, and there hasn't been a corresponding line that goes like "Generate Appname.dSYM ...in {path}"
But there's been Fabric installed, and it logged the fact of the dSYM file's absence:
Just filer the Report Navigator by "dSYM".
Fixing
In my case I've just had to do what I'm asked of:
DEBUG_INFORMATION_FORMAT should be set to dwarf-with-dsym for ALL
configurations.
Also, it may turn out that dSYM file is being generated in an unexpected place. Check environment variables, especially DWARF_DSYM_FOLDER_PATH and DWARF_DSYM_FILE_NAME.
To embed the dSYM within the app bundle, just set DWARF_DSYM_FOLDER_PATH to $(CONFIGURATION_BUILD_DIR)/$(EXECUTABLE_FOLDER_PATH) and DWARF_DSYM_FILE_NAME to $(EXECUTABLE_NAME).dSYM
Checking
Now the build should create dSYM for your target

There is no "share" button in Xcode 4.3 organizer

I have a valid Apple iOS dev account and all provision profiles set. I can debug the application on my iPhone. But when I do Product -> Archive and went to the organizer, there is only a "Validate..." and "Distribute..." button.
Clicking the "Distribute..." button only provides me with "Save built products" and "Save Xcode archive" which both doesn't contains any "IPA" file.
There is however an "MyApp.app" file built. I'm not sure what to do about it though.
Suggestions?
In short: Make sure you have configured all linked libraries with "Skip Install" to "YES" in the build settings screen. There are a few detailed instruction on how to do that here on SO.
Failing that, clicking on "Validate..." should clue you in to any potential fixes.
So, I just set-up my machine and somehow on one of a library project "Skip Install" was reverted to "NO".
The first sign that this is wrong is that the "Archive Type" shows up as "Generic Xcode Archive" which is the wrong one.
You can verify this by selecting the archive in organizer and clicking "Validate...", Xcode should tells you about the multi-bundle problem.
The "contains multiple product" is a known Xcode issue and can be worked around by making sure that all built products in all of your projects have the build setting "Skip Install" set to "YES" except for your main application project. This can happens if you add a library project by dragging the xcodeproj file into Xcode.
After fixing it and re-archiving, it should now shows up with an archive type of "iOS App Archive".
And if you click "Distribute..." now, you will now be able to properly export an IPA by selecting the second option.
Your PROJECT - Skip Install - set to NO
Your libraries - Skip Install - set to YES
In your SUBproject you should check "Copy headers" section
click on SUB project
Building Phases
DRAG all files fron Public and Private sections to PROJECT section

Release Configuration does not link header libraries in iPhone application

I am working on an application which is working properly in Debug configuration.
But when I am trying to build it in Release mode, its showing me list of errors specifically not finding header libraries.
Is there any extra settings I have to do for it?
Thank You.
Check the build settings of your application. (In XCode3: Project -> Project Settings -> Build tab).
You may set options for 'All Configurations' or for individual configuration separately. Check the entries you have for 'Header Search Paths' in Release versus Debug.
See the header paths settings in dubug and release mode .Make them same in both configurations

Frameworks are 'red' in Xcode

I downloaded a project developed by Apple employees ( who taught course at Stanford on iPhone application development). Strangely , the frameworks are red.
http://img.skitch.com/20100730-kcjun96mp2pxnpg7w3x6njw57.jpg
I tried to locate coreGraphics.framework and UIKit.framework to add them again but i couldnt find them either.
Taimur
The red text indicates that the actual files are not at the path that the project has for them.
Get info on the framework and look under the General tab. The first section shows the name and path of the framework bundle itself. The most common cause of a problem with system supplied frameworks is that the path type has been changed to something that breaks the path. The default setting is Relative to Current SDK. Change the path until you get one that leads to the actual framework.
If you have the developer tools installed in a custom location, you are more likely to run into this problem. If you copy a project from someone with non-standard settings, you can encounter it as well.
Are you building for a Simulator or for Device?
Try building for Device.
Found a way to fix this automagically:
Right click your main Xcode project file (the blue one at the top ),
Get info,
'General' tab,
At the bottom, set 'Base SDK for All configurations' to your desired one.
Done!
Steps to fix this issue in M1 Macs:
Install "sudo gem install cocoapods-deintegrate cocoapods-clean" to install deintegrate if not installed.
Run "pod deintegrate" in terminal in your project folder to uninstall all pods.
Run "pod cache clean —all"
Run "pod install"
Go to Project Explorer Select "Pods" in blue
Select the each pods in the target section
Search for "Excluded Architecture" in Build Settings Tab under "All" sub category.
Add "Any iOS Simulator SDK" in both debug and release and set the value to "arm64"
Repeat this for each Pod with the error "Framework not found".
Clean Build the project.
#Taimur Hamza - Its happen (red color) following any one of reason,
Your downloaded project may be miss some required files
Before run the application at first time.
so, first you have to find that above reason is happen and try to solve via copy the framework from another running project and paste it your project.
I had faced this problem before. I got over it by copy the missing (in red) framework from my friend's Mac then copy it to the Framework folder.
This is the path of my framework folder:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/System/Library/Frameworks
You may need to change the path depend on your system or your sdk version.
Most likely you decided to remove some of the frameworks you don't need and you deleted them but selected "Move to Trash" instead of "Remove reference".
The problem is that this framework was not included in your project's folder. It sits in a System folder when it can be used by multiple projects. So not only did you cause the current project not to compile, but also all projects on your computer.
If you have any frameworks left, you can right-click on them and check "Show in Finder". Than you can find your deleted frameworks in the trash (if it's not wiped already), and put them back in the system's Frameworks folder.
If you can't find this folder, for me it was here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library
Of course, when you go in Applications folder and select Xcode, you have to right-click on it and click "Show Package Contents".
If you deleted your frameworks even from the trash, than I guess you could re-install Xcode...