I have a project that has two targets one for iOS and other OSX. When I run the project it builds successfully. But Its nit running.I want to run this ample project in any of the platform. How can I do this.
This won't work, because iOS and OS X are based on different frameworks.iOS needs UIKit. But if you compile a project for Mac that contains UIKit, you will get an error. You cant just set Xcode to compile for Mac if you use the wrong 'base classes'.
Just create 2 Xcode projects that contain all the classes you want to use, one for OS X, one for iOS.
Related
I am writing a program in Swift using Mac OS Sierra and Xcode 8.3.2 and am using the RandomKit module from: https://github.com/nvzqz/RandomKit. I am using the basic Swift Package Manager to import the package into my project.
My program builds and runs fine, but when I go to archive it, I get an error saying "No such module 'RandomKit'
It highlights my code:
import RandomKit
Does anyone know why this would build and run but fail when I attempt to archive?
By default, when you Run in XCode, it uses the Debug configuration, and when you Archive, it uses the Release configuration. In Build Settings, look at the Build Active Architecture Only setting. By default, it is Yes for Debug, and No for Release.
This means that when you Run, XCode only builds for the simulator's architecture, but when you Archive, it builds for all possible iOS architectures.
Now, look at the settings for RandomKit to see what architectures it is built for. It needs to include all of the iOS architectures, like arm64, armv7, and armv7s.
After probably 4 hours I finally figured it out. I think this must be a bug in Xcode, but here is my workaround.
In this folder:
~/Library/Developer/Xcode/DerivedData/<My App Name>/Build/Products/Debug
I found RandomKit.framework and ShiftOperations.framework. I copied those two files into the root directory of my Xcode Project, and then linked the frameworks under General in my Xcode Project.
Linking Frameworks
How would I go about setting everything up to cross compile from my OSX 10.6 Macbook pro with xcode to my jailbroken 4th generation iPod touch. I'm mainly aiming to be able to port open source libraries to iphone. I can't seem to find any good/recent articles on cross compiling for iOS 4.
If you think about it, all projects built in XCode are cross-compiled for the iPhone. All you have to do is open an ios project, include your sources and build it.
More specifically, when you have a project in XCode, in the Build Settings tab there is an option for you to specify the architecture to compile - this is automatically set to something like 'armv7' for ios projects.
I have two iOS projects that under Xcode 3 built properly and these iPhone been on sale in the app store for some time. After upgrading to Xcode 4, Xcode now thinks these are Mac OS projects!
When I select Project Settings > Info, it actually says at the top "Mac OS Deployment Target" with a drop down allowing me to select 10.4, 10.5 or 10.6! These are not nor ever have been Mac OS projects.
In my build settings, Xcode allows me to select 32 bit or 64 bit Intel architecture. not armv6 or armv7.
You need to change your build settings. Fortunately, this is really easy to do.
Start by clicking on your project's name in the Project Navigator.
Now, click on your Project Name as it comes up in the list. (You may need to do this for your build as well.)
Next, click on Build Settings. Finally, you should be able to change your Base SDK to the appropriate one.
Note that you might need to repeat steps 3 and 4 after selecting your Target in the screen shown below.
Have you restarted Xcode since the upgrade? Often times Xcode 4 seems to need to be restarted after SDK changes.
I didn't face any issues opening the projects in Xcode 4 which are built in Xcode 3. However there can be wired issue with the Xcode 4 you are using. Try resetting the architecture to armv6 or armv7 and base SDK to latest iOS SDK using the build settings. Also set the deployment target properly. This should allow you to run the application in Xcode 4.
Also, try uninstalling the xcode and install Xcode 4 again. This should fix the wired issue you have with your xcode 4.
I created a project with two targets, one for iPhone and another for Mac OsX. They both build and run well when I build them the first time (I built the OsX target first then iPhone target next).
However, if I build the iPhone target and switch back to OsX target, the OsX target now thinks that it uses the iPhone SDK rather than it's own mac OsX SDK, and doesn't compile anymore (can't find the OSX SDK header files).
My build settings of the project and targets are setup correctly and the ".pbxproj" file is not changed in the process of switching targets. But I tracked down the problem to the ".pbxuser" file, specifically in the parameter "activeSDKPreference =".
Basically when I switch to iPhone target this parameter gets changed from macosx10.6 to iphonesimulator4.0, but when I switch back to OsX target it stays on iphonesimulator4.0. The only way to get it to work again is to close the project, manually change that param to macosx10.6, and reopen the project. This would solve it until I switch to iPhone again.
Is it a bug in XCode? anyone has a solution or a work around?
The same question is asked and answered at http://lists.apple.com/archives/xcode-users/2010/Oct/msg00132.html
It says there: "you can Opt-Click your "Overview" combo box ([in the] Xcode Project [window], in the toolbar). You should see a more complete list of Active SDKs; pick an explicit OSX SDK".
it is a bug in xCode, so you use the latest version of xCode
when you build this it set all your target. you can solve this by clean all target than build it. you wil find this in xcode build manu >> clean all target. than build this. it will work.
I have a static lib project with targets for iPhone and for os x.
With Xcode 3.2.2 and earlier versions all worked just fine, but in 3.2.3 apple seems to have introduced changes in how to handle target settings.
In 3.2.2 I just could choose "base-sdk" from drop-down menu and set up a target for each, iPhone simulator, iPhone device and Mac and xcode would always automatically build for the correct platform and architecture for that target.
Now, with xcode 3.2.3 and later you can't choose this option any more.
Switching between targets for simulator or device does not have influence on the platform, you build for, anymore. You always have to choose the platform separately and then all targets are build for that platform.
This issue is already described for simulator vs device here:
Targeting multiple platforms in iPhone SDK 4
For iPhone only projects I could live with it and just only have one target and choose the platform separately from the target.
The real issue with that change is with having an iPhone and a mac target in the project:
if the mac target is chosen, you do not have the option anymore, to switch between device and simulator, but they still affect the mac target.
If the platform has been set to device prior to switching active target from iPhone to mac, than xcode does not find the CoreServices for the mac target, because it is searching in iPhone device frameworks, where this isn't existing. Xcode even builds for arm in this case, also the target settings clearly tell it to build for i386.
If switching back to iPhone target an setting the platform to simulator and then switching back again to mac target, CoreServices framework is found, but the simulator one is used, not the os x one, which leads into the issue of dozens of "error: expected declaration specifiers or '...' before 'CFXMLTreeRef'" errors in the iphone simulator core services framework, where this is not defined, although I do of course want to use the mac version of the framework for mac target.
As I already mentioned, this was all working fine before Xcode version 3.2.3. Projects only for iPhone or only for mac are still building fine.
Any ideas, how I can get projects with static libs targets for iPhone and for mac, to build with Xcode 3.2.3 and later versions?
this guy has the solution...
http://blog.vucica.net/2010/09/single-xcode-project-for-ios-and-mac-os-x.html