Adding External Libraries Within Cameo Systems Modeler - libraries

I need to import some external libraries within Cameo. My issue is that I don't know how to import and utilize an external library like yaml in Cameo Systems Modeler. I tried importing the library through the project options as specified in the User Manual: "options" > "project" > "general project options" > "external libraries" and adding a .zip of the library I need. However, whenever I try to run the import within code in a constraint block it throws the error of "ImportError: No module named yaml".
Any help would be appreciated.

Related

Import custom static library in Xcode project

I created a static library in Swift and the goal is of course to distribute this and reuse this library in another project. In the project where I want to import this static library I do the following:
Drag xcode project from static library in Project Navigator
Drag xxxx.a (inside Products folder) to Build Phases > Link binaries with libraries
In the class where I want to use this library add: import MyStaticLib
Unfortunately I get an error saying: No such module 'MyStaticLib'.
But then when I create a new project in Xcode and do the exact same steps there's no error at all and I'm able to use the library in any class that imports this library. I looked at both project settings and can't seem to find anything weird.
Settings like Header Search Path and Library Search Path are empty in both projects.
Can someone point me in the right direction?

How to use a custom framework with a playground in Xcode 9

I am trying to use a custom framework in a playground as described in this Apple documentation:
http://help.apple.com/xcode/mac/9.0/#/devc9b33111c
However, I am unable to get the playground to recognize the framework (https://github.com/gk-brown/MarkupKit). It is a 64-bit Objective-C framework that defines a module.
Here is what I have tried:
Create a new "single view" playground
As directed in the document, open the playground and choose File > Save As Workspace
Close the playground
Open the workspace containing the playground
Attempt to choose File > Add Files to [Workspace Name]
The menu item is actually named "Add Files..." and is disabled. I'm able to work around this by opening the Navigator panel and selecting Project Navigator. The menu item changes to "Add Files to TestPlayground" and becomes enabled.
Moving on, as directed in the document:
Navigate to the directory containing the framework, select the framework, and click "Add"
In the editor, open the desired playground source file
Add an import statement for the framework (e.g. "import MarkupKit")
The console displays the following error:
error: TestPlayground.playground:5:8: error: no such module 'MarkupKit'
The document additionally notes that the workspace must contain at least one active scheme that builds a target. However, adding a project to the workspace and building it does not resolve the problem. The playground is still unable to see the framework.
Based on what I've read elsewhere on SO, it seems like this should be possible. However, most of the information I have found is 2-3 years old and may be out of date. The framework is a universal binary, and I have tried trimming it using lipo as suggested in some other posts. Specifically, I did this:
https://github.com/gk-brown/MarkupKit/wiki/Deployment
Unfortunately, it didn't help.
Any suggestions would be very much appreciated.
You steps looks okay but
Only missing part I see here is adding a .swift Empty file in the project.
This actually compiles below project so after this framework will be ready to import into the playground.

Can't run tests in a Xcode project that imports another framework

I'm trying to write an open source app to show how you can write client + server code in Swift.
The source code is located here: https://github.com/haaakon/QuizWorld (QW for short)
The app is using a framework, located here: https://github.com/haaakon/QuizWorld-API (QWAPI) to access the API. I've imported the QWAAPI as a project into the QW app, it runs fine in simulator, but when running the tests, it doesn't compile because of this Error:
Undefined symbols for architecture x86_64:
"QuizWorld.QuestionViewModel.__allocating_init () -> QuizWorld.QuestionViewModel", referenced from
This is from only one line of code in the test:
let a = QuestionViewModel()
This means that the test target does not correctly get the imported module in. The imports are:
#testable import QuizWorld
#testable import QuizWorldAPI
import Prelude
import ReactiveSwift
import ReactiveExtensions
import Result
I've tried adding alot of different imports, even for the Frameworks used in the API Framework, but nothing seems to fix this. The QW-Tests target also has the correct target dependency setup. Anyone have a clue where i can go next with this? All the code is open source in the repos linked to.
In your test target, you have nothing set in Test Host and Bundle loader build settings. During linking phase it basically fails (doesn't know where from) to load the symbols. Target dependencies only says what should be built before, and "Link binary with libraries" has no effect for dynamic frameworks.
Set following build settings in your test target:
Test Host: $(BUILT_PRODUCTS_DIR)/QuizWorld.app/QuizWorld
Bundle Loader: $(TEST_HOST)
The docs for the latter:
Specifies the executable that will be loading the bundle output file being linked. Undefined symbols from the bundle are checked against the specified executable like it was one of the dynamic libraries the bundle was linked with.
I tried this on your project and it works.
UPD: In your second commit "setup for first test" you have removed these lines, so you might just reverse deletion of those individual lines.
UPD2: Regarding your general project setup. Try running your app on a real device, with this setup it won't find 3rd party frameworks included from QWAPI project, as they are not copied automatically. You will need to setup "Copy frameworks" build phase, to make sure that dynamic frameworks are copied in to the app bundle.

Xcode Swift: how to import a Swift project

I have made an Xcode Swift project ("Project1"). In a new project ("Project2"), I have trouble adding project 1.
I have tried adding project 1 to project 2's build phases (target dependancies, compiled sources, link binary with libraries); didn't work. When adding to the compiled sources, it wouldn't work no matter which option I chose (folder references, groups, copy if needed).
I get no compiler errors at:
import Project1
But when I try to use a class from project 1, I get the error "Use of undeclared type".
I have also tried to following links with no success:
External library usage in xcode
Xcode : Adding a project as a build dependency
Xcode how to add an external project
Both projects are in Swift (iOS).
I'd be very thankful if someone helped me with this issue.
Update: Project 1 is not a framework - it's an iOS app. I need to use some of its classes in project 2. The problem is that project 1 uses the Objective C library Common Crypto via a bridging header. When I manually add project 1 classes into project 2, I get an error ("unresolved identifier") in the project 1 Swift code that uses Common Crypto.
So in a nutshell: I have an iOS app (project 1), which is in Swift but uses Common Crypto via bridging header. When I add a number of classes from project 1 into project 2, it cannot resolve the references (in project 1) to Common Crypto variables.
Assuming Project1is a Framework and Project2 is an application using the framework:
Create a virgin Workspace (Xcode File -> new -> Workspace) named TestWorkspace
From the Finder, drag the Project1.xcodeprojfile to the TestWorkspace
From the Finder, drag the Project2.xcodeprojfile to the TestWorkspace, above Project1
Edit your TestWorkspace schemas Build setup:
Add Project1 and Project2
make sure Project1 is above Project2
Untick "Paralellize Build" to assure Project1 is build first
Build
Select Project2s target -> General
Drag artefact project1.framework(in Productsgroup) to "Linked Framworks and Libraries"
Note: To be visible for the client, all classes and methods in your project1.framework have to be public or open. Finde detailed information in Apples documentation.
Edit: As you have CommonCrypto as a dependency you will have to add the module to your Project2 project instead to solve your issues ( this is the easiest without resorting to an umbrella framework ). Add a run script build phase and include http://pastebin.com/1vmiqffu
-- Credits: Script 'stolen' from: https://github.com/henrinormak/Heimdall
Ok so I'm going to assume here that Project1 actually has a framework as a target. What are the access permissions set on the types you are trying to use?
Here are a couple of catchya's with Swift and frameworks as I encountered them:
You do not have a bridging header, instead your framework includes headers of non-Swift dependencies inside the header file of your framework ( ModuleName.h ). This also means these will be available to whatever project you import them to. As far as I know you need to use a module.modulemap in order to make use of private headers and includes.
All Swift Classes / Structs / Definitions in general are internal by default. It is a very good design choice and it forces you to think about the access rights on every component you write. Keeping things private by default makes it easier to only open stuff that really needs to be open ( public, open ), allowing for easier code maintenance since you know that private things are only accessed within the same context. ( Otherwise: error )
For some more assistance this link might be of help to you on how to do some fundamentals:
your first ios framewok (swift)

Import a static library as a subproject

I watch this video to know how to create a static library, I just watched until the 4:05 minute video (which have already been enough to learn how to create a static library).
But I learned that there's another way to import a static library for the project called subproject, for this I open my iphone project and add my library project (MuitosAlertas.xcodeproj), Then I added two references to my library inside the tab Target Dependencies and Link Binary with libraries as you can see below:
When I compile and run, Xcode give me the problem
Lexical or preprocessor issue 'MuitosAlertas.h' file not found
I try to put inside Other linker flags the code -ObjC but without results, how can I solve this problem
You must add Header Search Path to your target. In build setting search "Header Search Path" and add relative link to your static library project. How to add relative path read more here
You may need to search path with recursive option.
Once you have created your Library then make a build from the target added separately for the Universal support and then by right clicking on to the .a file from bundle navigate to folder and look for Universal and copy Include folder and your StaticLibrary.a file, then where you want to use it paste in that project and add reference to it and in bundle setting you need to set the HeaderSearchPath of the library where it is kept and the OtherLinkerFlag to -ObjC.
Then import the headers of your library and use your methods.

Resources