Module from subproject (framework) not found

I am using Xcode 8 + Swift 3.

I created a new iOS project called "MyApp". Then I create a Cocoa touch framework project called "MySubProject". (The idea is to have a MyApp project , access to the MySubProject code.)

They are on a folder of the same level:

- MyApp/ - MySubProject/ 

In MySubProject , I have a MyService.swift file (this is the MyService class) in the service group / folder:

enter image description here

The code is very simple:

 import Foundation public class MyService { public func greeting() -> String { return "Hello my service!" } } 

In MyApp, I added MySubProject.xcproject to the MyApp project as a subproject under MyApp :

enter image description here

Then I dragged MySubProject.framework into the MyApp General project -> Embedded binaries and related structures and libraries:

enter image description here

Now, under MyApp/ViewController.swift , I import the MyService class from MySubProject : enter image description here

But when I create a MyApp project, I always get a compiler error " There is no such module" MyService ", as you see in the picture above.

Why? How to make MyApp access to MySubProject code?

+5
source share
3 answers

import MySubProject! not myService ... after this framework for the application, see the snapshot, please. I can not send the image. snapshot

+2
source

Does MySubProject include the option "Defines module"?

0
source

EDIT:
There are a few things you can check:

To find in your main project, your structure must be compiled for the same purpose, that is, if your main project has iOS as the target, your subproject must also have iOS as the target (and not, for example, watchOS).
Include the project in the navigator project. This shows a panel with design and target settings. Activate your goal and select the "General" tab. In the Deployment Information section, you can check the type of target.

To be imported into your main project, your infrastructure must be built when your main project begins to build, i.e. this must be done in the correct sequence. This sequence can be selected appropriately: in the upper line of the Xcode window (the one with the red / yellow / green buttons for controlling the window to the left), to the right of the stop button, there is a field with an active circuit on the left and the selected device to the right. Clicking on a diagram opens a submenu. Select an editing scheme (this can also be done from the Xcode main menu using the Product / Scheme / Edit scheme). Select Build in the left pane. On the right side you will see your goals. They will be built from top to bottom. Therefore, your infrastructure should be on top, since your main project needs to be imported when it begins to build. You can change the sequence by dragging the targets accordingly.

There is one more thing: there is a “Parallelize Build” checkbox above the goals. This should not be verified! If it is checked, your main project and your subproject can be created at the same time, which will not work, since the subproject must be compiled completely when the main project starts building.

And in the end, you need to import your framework (like the hasayakey suggested in this answer, +1), and not a specific framework file).

Previous offer :
Does your subproject file "MyService" (or, nevertheless, it is called) include the target membership for "MyService"?

0
source

Source: https://habr.com/ru/post/1269947/


All Articles