Run a project without accessing frameworks for real devices - ios

I have an issue: I have built-in frameworks via "Frameworks, Libraries, and Embedded Content" that work only on real devices, while their source code is not available and I can't create version for simulator. However, I need to run the project on the simulator, and the functionality that is associated with the frameworks is disabled for the simulator with:
#if targetEnvironment(simulator)
#else
import MyFramework
import MyFramework1
#endif
However, when we try to start the project in simulator mode, I get an error -
Building for iOS Simulator, but the linked and embedded framework
'Framework' was built for iOS.
At Build Phases -> Link Binary With Libraries for my target I selected optional status for MyFramework and MyFramework1
Any suggestion how to fix run for simulator without these frameworks are welcome!

I've found useful fix for my case. This fix is based on this. I just excluded the folder for the simulator (Any iOS Simulator SDK) where the frameworks are physically located. I've added path like this "$(SRCROOT)/my_project/my_libs/*"

Related

Profiling app with Cocoa Touch Framework in Instruments does not show any symbols

I have an Xcode Cocoa Touch Framework project (written in
Objective-C) that produces a .framework directory as well as the
corresponding .dSYM file. Its using iOS 10.1 as its Base SDK
with a deployment target of 8.0. All built using Xcode 8.1.
I would like to profile my framework using Instruments so I've added
my framework into a separate Xcode project (written in Swift). It
builds and runs fine. However in Instruments, the symbols from my
framework are not showing.
In the Instruments menu: File -> Symbols, it shows that there are
Missing symbols but they are all from System Frameworks
(/usr/lib/dyld)
When I try to set the dSYM path to the dSYM file of my framework, it says that:
No new libraries to symbolicate. The specified path didn't locate a dSYM for any of the selected libraries.
Am I profiling my framework the wrong way? Or am I missing other settings in my framework's build settings?
Any help is appreciated. Thanks!
The problem went away once I profiled the app in an actual device instead of the simulator.

App builds for Simulator, but not for 'Generic iOS Device'

I am experimenting with pulling data from the internet for my app, and everything works as it should when the app is run in the iOS Simulator or on my own device.
The frameworks I'm using are Alamofire, SwiftyJSON and GzipSwift; I cloned the Github repo of the Gzip framework, build it myself, dragged the .framework into my project navigator and linked it up (added the framework to Link Binary with Libraries under Build Phases).
Now, when I build the code for any specific device, it compiles and runs just fine, but when I select 'Generic iOS Device' as the target, the build process fails and tells me that it couldn't find the methods I used from the Gzip framework.
I am quite certain I missed some setting or didn't import the framework correctly, but I have no clue on how to fix this.
Any ideas?
I guess you build the framework only with the simulator architecture instead of building it for all architectures (arm64).

add xctest framework to an old project

how can I add xctest framework to an old project? When I try to add a new framework I couldn't find xctest in the available list in Link Binaries With Libraries.
I also tried edit->refractor->convertToXCTEst but select targets to use xctest: lists no targets
In Xcode 6.1.1, and also in Xcode 6.0.1, the XCTest.framework is not listed anymore as an available framework. In Xcode 5.1.1, however, the framework is listed.
So something appears to have changed between Xcode 5 and 6 when it comes to testing. For instance, when you create a new project in Xcode 6 you no longer need the XCTest framework. You can simply add a new test case, build and the test runs just fine. I have yet to figure out why this is the case, but for you this might be the first thing to try: Just code a test case and see whether things work.
If they don't, then you could try this ugly workaround: Open the project with an older version of Xcode, add the framework there, then go back to work in your new version of Xcode. This worked for me when I tried it with Xcode 5.1.1.
EDIT: The reason why XCTest.framework is no longer needed in projects created by Xcode 6 is because these projects have the build setting CLANG_ENABLE_MODULES set to YES. Xcode 6 exposes this in the UI under the name "Enable Modules (C and Objective-C)". With this setting enabled, any #import statements for system frameworks such as XCTest cause clang to automatically link against that framework. Details are available in the "Modules" section of the clang documentation. Once this build setting is enabled you can also remove any other system frameworks from the "Link Binary with Libraries" build phase of your targets.
And for completeness' sake: The reason why Xcode 6 no longer lists XCTest.framework as an available framework is because the framework's location inside the Xcode bundle has changed:
# Xcode 6
/Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework
# Xcode 5
/Applications/Xcode-5.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk/Developer/Library/Frameworks/XCTest.framework
Apparently Apple now relies entirely on CLANG_ENABLE_MODULES to get test targets to link against XCTest.framework. If you want Xcode 6 to list XCTest.framework as an available framework, you can manually create a symbolic link inside the Xcode app bundle:
cd /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
sudo ln -s /Applications/Xcode-6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework .
You need to restart Xcode after creating the link.

Making Xcode ignore static library when building for iOS Simulator

I have a Xcode project, that includes a Static Library project, that uses another static library that does not support the iOS simulator architecture (Vuforia SDK: libQCAR.a).
Vuforia SDK documentation states:
Vuforia applications must be deployed to a device to run; they cannot be run in the iOS simulator.
This is my project structure:
MyApp.xcodeproj
Classes
MyStaticLibrary.xcodeproj
Classes that depends on libQCAR.a
Frameworks
libMyStaticLibrary.a
libQCAR.a
My problem is that MyApp.xcodeproj does not build for the iOS Simulator because libQCAR.a is not built for the i386 architecture.
Is there anyway to make MyApp.xcodeproj ignore the libQCAR.a library when building for i386? I would be able to disable all the code that depends on the library with #if !(TARGET_IPHONE_SIMULATOR)
You can use a conditional build settings to specify the library you want to link only on a given platform, instead of adding the library to your project in the usual ways. Specifically, you will need to specify:
-lQCAR
in "Other Linker Flags".
Have a look at the attached image that should make things more clear (in the picture I am linking only for the simulator, you will want to select a device, I guess).
Also, do not forget to add the path to the directory containing the library to "Library Search Path" build setting (this does not need to be conditional; it would not do any harm on the simulator).
This issue seems very similar to: Xcode: Conditional Build Settings based on architecture (Device (ARM) vs Simulator (i386))
I believe sergio's solution is very close, but have you tried specifying the full path to the library under Other Linker Flags (potentially without "-l" - just the path)?
In my case, it should specify clearly which SDK uses which flags.
So in Any iOS Simulator SDK, you should not include the library.
In Any iOS SDK, you should include it. In my case, it's -lCloudReco.

iOS Development: problematic framework search path

I have an iOS app and I want to test it on simulator. When I run the project xcode complains that my framework file is "missing required architecture i386 in file".
I did a bit of search on line and it says that's because xcode used the framework files intended for actual device when building the project for simulator. Solution is to add the simulator framework folder under the framework search path in build settings.
Okay now the problem is, doing that solves the problem of building project on simulator, but later when I want to build the project on an actual device, xcode starts complaining again saying there are redefinitions of some of the openGL typedef in the framework. To fix this I have to remove the search path item that I added.
So is there an easy way to avoid having this kind of problem? I don't want to switch the search path over and over again when I want to build the project on different platform.
If you upgrade a project from 4.2 to 4.3.2 style it often loses the architectures required for the target you are building for. Usually you just have to add them back or change the target SDK.

Resources