So I've been tasked by my company to develop our CI and testing, but I'm completely new to testing in iOS. I added a target, set as a testing unit, but I need access to the code within the primary target; however, my tests always fail, despite having added the primary app as a target(and vice versa) and checking that 'Symbols Hidden by Default' is off. Anyone have any advice? Really stuck until I can get those files working in my test target...thanks!
Have you checked that your source files also have a target membership for the tests application?You can do so by selecting one or more source files in the project navigator, opening the File Inspector (option+command+1) and enabling the target membership for your test application.
If you're using Xcode 6.4 or earlier (i.e. Swift 1.2), you need to make your classes and methods public. This is fixed in Xcode 7 / Swift 2.0.
Related
I'm having a weird issue. I'm trying to merge two projects (one iOS and one tvOS, both with a mix of objective-c and Swift) into a new single xcode project so that going forward they can share code.
I created a new project, created an iOS target and tvOS target, and brought all of the iOS code over, pretty quickly it was compiling fine for the iOS target. When bringing all of the code from the previous iOS project over I set all of the files to only be accessible to the iOS target.
Then I did the same with the tvOS code, once again only setting the files to be accessible to the tvOS target.
So because both of these code bases are very similar there are a lot of duplicated classes, but that over time have slightly diverged. Eventually my goal is to unify these, but for now I just need to get all the code in the same place. So I have classes with the same name, I was hoping that just having files only accessible to the relevant target would solve this problem for me, but it only kind of does.
After migrating all of the code, the iOS target (which I got working before starting with the tvOS code) still compiles, however, the tvOS target doesn't. It fails on errors that should only be accessible to the iOS target, because the classnames and method are already used ('Duplicate interface definition for class' and similar errors).
So I really don't understand what's happening here -
Why does the the tvOS target have access to code that is only supposed to be available to the iOS target, but not the other way around? What can I do to fix this? (besides just wrapping all of the code in #if Target_OS_ios).
One other thing, the tvOS target only seems to have access to objective-c files from the iOS target, none of the errors have come up in any of the swift classes. Not sure if that is relevant or not.
I have read about two possibilities for that:
To build the framework as debug, to add it to main app project, and run the main project also as debug. Breakpoints should allow you to inspect the frameworks code stepping into it.
To add somehow the framework project itself to the main app project
I tried first one and it is not working for me. I get an Couldn't Generate Swift Representation when trying to step into framework's code. If this option should still work in Xcode 8 and Xcode 8.1, what settings should I check?
If the best/only option now is the second one, how should I properly set that?
before Xcode 7, I were able to build a Framework for (development) distribution for both device and simulator (usually as a fat-binary) and include it into any of my projects. When I now try to build and integrate the Framework I still can see my classes and the Framework-Module and use both in my code, but when I try to reference them from within my Storyboard, they are no longer visible.
Correct me if I am wrong - I've been working with Frameworks since swift was released, but my memories might deceive me here - but I remember being able to use classes from a Framework and reference them in an InterfaceBuilder-file in the previous versions. Referencing a framework-class is no problem when the Framework-target is build from within the same Project.
To test this, I simply set up a Framework-Project and added a custom UIViewController. Then I've build the Framework and imported it into another SingleView-Application. I already checked if there is a possible setting preventing the Framework-module from being visible (BitCode, SDK, Deployment Target) and configured the ViewController as public.
Maybe I'm just missing some new setting Apple introduced in Xcode 7 ;-)
I'm trying to create one Xcode workspace that includes 3 projects:
- 2 different iOS apps
- One dynamic framework project
The two iOS apps should use the framework.
Sounds very easy and reasonable thing to do, but I just can't seem to make it to work.
When I add the framework to the iOS app target as linked library, the build process works but when running I get an exception that the framework could not be found.
If I go to the Embed Binaries -> click add -> choose the framework from the framework project, nothing happens (the embed binaries section stays empty.
I tried to do first add the framework as linked library, then add it to the embed binaries. Now compilation doesn't work (can't find the framework).
What am I missing? Every single example in the documentation shows how to add a framework as a new target under the same project. But that's doesn't help. I want the framework to be a separate project that a team can work on separately.
Open Xcode, so you can see Xcode in the menu bar.
Then go File>New>Workspace.
I believe you just drag and drop other projects into the workspace.
I've never really used a workspace, although I have made one before.
I am working on Worklight version 6.1.I have created a native ios environment.I added controller classes in the Xcode project and added native functionalities. I have added .js files in the eclipse project.Now I need build my iPhone environment.But I am afraid that native content (Xcode project) will get lost,after building the environment.What is the solution for this.
I should build at the same time native content shouldn't be lost.
How to do this...
Your explanation is VERY raw... it doesn't make much sense to me.
have created a native ios environment
What is that exactly? do you mean that you:
Created a Worklight project and added a Native API for iPhone, or
Created a Worklight project, added a Hybrid app and then added the iPhone environment to that application
Created a fully native project in Xcode?
The distinction between the 3 is important, and you need to mention this in your question in clear wording.
If what you mean is that you went with option 2 above, then your JS, CSS and HTML can be either in the common folder or in the environment folder.
If you then want to add native code, you need to first build your project and then open the generated Xcode project in Xcode, write native code and make sure to copy it back to your Worklight project in Eclipse.
I added controller classes in the Xcode project and added native
functionalities
Where did you add this? In which file? in the classes provided by Worklight in option 2 above, or in a new Class.
Either way, you need to bring these files back into Eclipse.
In Eclipse, you can create a iphone\nativeResources\Classes folder. During build-time in Eclipse, the files in this folder will be copied into the iphone\native\Classes folder, and when opened again in Xcode - your native code will be there...
Note: if you created your own class file, you will need to reference it in Xcode (right-click > add files...). Worklight cannot do this for you.
I believe your customizations should not be lost. Have you tried making the build already and your resources were overwritten?