Equivalents of c# solutions and projects in xcode - ios

Newly I am switched from xamarin.iOS to Xcode.
In C# a good feature is that you have a solution that contains several projects and you can define debug/build configurations and based on them build separate projects with each other.
Now, I want to know that is there any mechanism like this in the Xcode too?
Actually I want to develop 3 apps that they have many shared codes. So I want to create a base project that contains shared codes (and contents) and then 3 sub projects. Now with some thing like build configuration, I can build each of them that I want for publishing.
Does Xcode support mechanisms for this porpose?
UPDATE
By reading below answers I created a workspace with below structure:
I also added ../testproject/testproject to the build settings of link1Project but when I want to use files in testproject the autosuggest is not working and also when I build the link1Project I face with:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ShowAlertView", referenced from:
objc-class-ref in mftTbnFlipsideViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Am I wrong in creating the workspace? Does the structure is right or I missed something?

You can have multiple targets for the same project, and each target can have different settings or files.

You can include this base project as a sub-project to each of those 3 projects (just drag it). And create a workspace to include all three child project in it, although it is not necessary - including project as a sub-project is enougth to share code between projects.

Related

Cocoa Pods - Multiple Dependencies

I'm new to working with cocoa pods and having a trouble of getting work another dependency which is given in the same Podfile.
The issue I persume is that, it's seeking for headers of the second dependency within the first dependency.
Podfile:
Error:
Thanks in advance.
The problem is that your project references an old framework that you had in your Downloads folder, but it is now missing. Remove the reference and try to build again.
It's important to understand how to read those errors.
For example, this error:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FLAnimatedImage", refereced from:
objc-class-ref in SampleViewController.o
meaning that an objective-c object which called "FLAnimatedImage", in "SampleViewController.m" file has a broken reference for x86_64 architecrues (different devices working with different proccessor architectures).
You should enter this class (SampleViewController), and try to understand where this object (FLAnimatedImage) is declared (one of the "import ..."). In your case, i think it's just because your old library or project doesn't support in the x86_64 architecture.
so, for your project file and all library files (all file with ".xcodeproj" suffix):
click on the .xcodeProj
choose your currect target (usually you should update your architectures to all targets, then choose your project instead).
choose tab "build settings"
find "valid architectures" (you can search it in search bar)
add "x86_64" to existing architectures.
make sure that "build debug architectures"=no.
Good Luck !

Cocoa Touch Framework architecture issue / production build

I built an iOS Framework.
After I added the framework to my project and run on my device, it worked fine. But when I try to run it on the Simulator, I got some error.
ld: warning: ignoring file MyFramework.framework/Framework, missing required architecture x86_64 in file MyFramework.framework/MyFramework (2 slices)
Also got this one:
Undefined symbols for architecture x86_64:
With a list of strings/methods and such that were referenced from.
How could I fix that?
Also, I want my Framework to run on all devices/simulators since iOS7+ (Production), I've read this post here that tells me to use lipo, but I understand that I have to create an Aggregate target. I just don't have this in my Other section of XCode 6.2.
How can I do this?
So, after 2 days of search, a lot of reading on the web and mostly at StackOverflow.com I found this question:
Xcode - symbol(s) not found for architecture x86_64 (iOS Lib)
Select your Target and in Build Setting it should look like that:
Now, select the Aggregate Target, click on the Build Settings and should look like that:
If you want to better understand how to create a framework, read this question and the answer of this question, there is a lot of information there, this is what helped me:
Running 1 of 1 custom shell scripts freeze
Enjoy and good luck!

Xcode 6 linker error - Undefined symbols for architecture armv7

After upgrading to Xcode 6 beta 7 (and now still with Xcode 6 GM) I am unable to link my Swift app. I receive errors such as:
Undefined symbols for architecture armv7:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
...
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have seen the other SO posts that recommend deleting the Derived Data folder and/or using the Clean Build Folder option to get past this error, but that solution didn't help at all in my case. Nothing has changed about my code or the CocoaPods I'm using since Xcode 6 beta 5 which is the last time it worked.
Any ideas?
EDIT:
A full posting of the error log:
Undefined symbols for architecture arm64:
"_swift_stdlib_compareNSStringDeterministicUnicodeCollation", referenced from:
TFC12MyProject21BarcodeViewController13captureOutputfS0_FTGSQCSo15AVCaptureOutput_24didOutputMetadataObjectsGSQGSaPSs9AnyObject___14fromConnectionGSQCSo19AVCaptureConnection__T_ in BarcodeViewController.o
"__TFSs21_arrayConditionalCastU___FGSaQ__GSqGSaQ0_", referenced from:
TFC12MyProject27SessionsTableViewController17viewWillDisappearfS0_FSbT_ in SessionsTableViewController.o
"__TFSs15_arrayForceCastU___FGSaQ__GSaQ0", referenced from:
__TFC12MyProject7RestApi12tokenMappingfS0_FT_CSo15RKEntityMapping in RestApi.o
__TFC12MyProject28AttendeesTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in AttendeesTableViewController.o
__TFC12MyProject27SessionsTableViewControllerg24fetchedResultsControllerCSo26NSFetchedResultsController in SessionsTableViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
"__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
__TFC12MyProject7RestApi12resetRestKitfS0_FT_T_ in RestApi.o
__TFC12MyProject16BluetoothManager17_startAdvertisingfS0_FT_T_ in BluetoothManager.o
__TFC12MyProject19LoginViewController32registerForKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController35deregisterFromKeyboardNotificationsfS0_FT_T_ in LoginViewController.o
__TFC12MyProject19LoginViewController16callProcessLoginfS0_FT_T_ in LoginViewController.o
__TFC12MyProject21CheckinViewController16enableBeaconModefS0_FT_T_ in CheckinViewController.o
__TFC12MyProject21BarcodeViewController13startScanningfS0_FT_Sb in BarcodeViewController.o
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What's happening here has nothing to do with your Derived Data location.
When a swift application is built, it goes through several steps:
Write auxiliary files
Create product structure
Compile swift source for each architecture
Copy resource rules plist
Copy application bridging header
Link against swift runtime libraries for each architecture
Copy application swift module for each architecture
Create the application binary
Copy resources build phase
Copy the swift standard libraries into the application
Package it up
Sign it
Whew! That's a lot. Your build is failing when linking against the swift runtime libraries. They live in Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos inside the Xcode developer directory. Specifically, the library that is not being correctly linked is libswiftCore.dylib. If you use nm on that library, you can see it defines your first missing symbol:
quellish% nm /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib | grep compareNSStringDeterministicUnicodeCollation
00197c8c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
000000000018352c T _swift_stdlib_compareNSStringDeterministicUnicodeCollation
You can also use lipo to see what architectures are in the file:
quellish% xcrun lipo -info /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib
Architectures in the fat file: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib are: armv7 arm64
It contains armv7 and arm64. It's not the library architecture that's the problem.
Linking against the swift standard library is not working. It's possible that source control or migrating Xcode versions has caused your project file to drop part of the linking step, or it's simply not able to find the libraries it needs to link against. Xcode project files are complex and use a lot of references - it's possible that a merge, etc. caused a critical reference to be come dissociated from the linking step. Without a full build log and a look at your machine it may not be possible to tell.
This library, as you might guess, has nothing to do with the project's derived data location.
The best way to move forward would unfortunately be to recreate the project file. Comparing the build log of the broken project to a swift project that does build correctly may provide some insights, but it may also be a waste of time - something fixable may be the problem, but more likely not.
I would encourage you to file a bug and include the troublesome project file with it.
I have solved my issue by deleting all the data in the ~/Library/Developer/Xcode/DerivedData folder. I read about that in another thread, but ignored it thinking a clean included that process!
I have Updated on Yosemite, Xcode 6.1.
I have updated gem xcodeproj (0.19.4) and cocoapods (0.34.4).
I have resolve my conflict by :
Clearing the Library/Developer/Xcode/DerivedData folder
replace in Target -> Build Settings -> Linking -> Other Linker Flags : $(OTHER_LDFLAGS)
Check in Target -> Build Phases -> Copy Pods Resources : "${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh"
1) I face the same problem but just clear the applications from derived data from User/Library/Developer/Xcode/DerivedData and I am able to run the code.
2) In your case may be, it will run by removing armv7 architecture from build settings. And make sure your compiler is Default Compiler in Build Settings.
Thanks I hope this helpful to you and everyone.
This seems to be caused (for most) by linking a third-party library that does not support the requested architecture.
I had somewhat similar problem (a linker error from Apple's framework). As it turned out, the problem was that I was missing the library LocalAuthentication.framework. I am wondering if maybe you need to delete the Foundation.framework from the Build Phase tab (in the Link Libraries section), and then re-add it? Maybe that will solve the problem?
'Upgraded' to xcode 6 and swift app wouldn't build for simulator yet would build fine on an iPad - Linker error, undefined symbols for i386 for the simulator.
Clearing the Library/Developer/Xcode/DerivedData folder worked for me.
There appears to be a bug in Xcode 6.0.1 that is causing the linker to drop dependencies in existing project files. I have had this same problem across several different projects, new and old, since the 6.0.1 update.
The easy 'fix' is to just trash your entire 'Derrived Data' and all build files (i.e. manually clean the project) and then rebuild after a fresh Xcode restart. Magically, the linker now finds all the missing architectures/symbols.
NOTE: I have had several incompatible v-table crashes caused by this same bug. The C++ linker appears to be generating incomplete linkages, causing absurd errors where there are no real errors to be found. Again, just rebuild from a clean state and .. ta da.. save yourself a LOT of headache and wasted time tracking down a non-issue.
I solved this issue after trying all that was suggested here with no luck.
Like someone said earlier, it's a SourceControl issue.
One of my project files (the one referenced in the error message) was missing from the project browser. However, XCode still had a reference to it (I was going to the class definition when I was selecting "jump to definition" from Xcode GUI).
As a matter of fact, the project.pbxproj was not listing it. This was probably a Git Issue. In any event, I just recreated the file in the same directory it has been recreated and voila.
I am a filly when it comes to iOS Objective C, though I have been coding in several other languages for many years. So I am stabbing around in the dark most of the time with Objective C.
I started having this error, "Undefined symbols for architecture armv7", directly after declaring some "global" variables in my .h file like so:
extern NSString *globalNotes;
extern NSString *globalUserCountry;
I was then referring to these variables from the .m file like so:
globalNotes= #"Error (Marker 1010)";
globalUserCountry= #"No result";
THE FIX - To correct this, I changed them to object properties like so:
#property(nonatomic, strong, readwrite) NSString *globalNotes;
#property(nonatomic, strong, readwrite) NSString *globalUserCountry;
And referred to them like so:
self.globalNotes= #"Error (Marker 1010)";
self.globalUserCountry= #"No result";
That seemed to fix my problem.

Trouble Adding OCUnit Testing Framework to Existing Xcode Project

I am trying to integrate Unit Tests in my current Xcode project using the OCUnit Testing Framework. I have been following Apple's documentation:
http://developer.apple.com/library/mac/#documentation/developertools/Conceptual/UnitTesting/02-Setting_Up_Unit_Tests_in_a_Project/setting_up.html,
regarding setting up Logic Tests. When I switch to my testing scheme and run 'Test' under the 'Product' tab, I am receive two errors:
Error 1: Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.o
Error 2: ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried cleaning my build and also using application tests but nothing seems to work. The tutorials I've views on Lynda seems not to run into these errors. Adding a target and linking it to my current project seems like all that needs to happen in order to start utilizing Unit Tests within Xcode. What do these errors mean and what do they refer to? All input is appreciated!
1) Create a new iOS project say one view controller type, and specify you want unit tests at creation, now you can see how Xcode has wired it - you will have a reference.
2) create a new project of the type and name as your current one in a temp folder. Move your original project file to another temp folder, move the new one to where original one was, then import all files checking unit test target.

Trying to integrate unit tests into Xcode for iOS 5.0 project, but cannot get files to link correctly

I am trying to add unit tests into my Xcode project for an iOS app that I am working on. I have SenTest working with basic examples, but the second I try to test any of the project code, I get linker errors like so:
"_OBJC_CLASS_$_Account", referenced from:
objc-class-ref in Tests.o
ld: symbol(s) not found for architecture i386
Obviously, I could solve this by duplicating my app target configuration into my test configuration, making all of the compile sources the same and such, but this will make two different targets that I will have to maintain, which is very unappealing. Also, I could refactor the project to use a static library and share between the app and the test targets, but that also is undesirable.
Is there any way that I can use the built objects from the app target in the test target? This sure seems like a lot of work to get unit testing in my project...
Thanks for any and all help!

Resources