我已经创建了自定义框架,可以在我当前的iOS应用程序中使用。
现在都是profileManager.Framework& messagemanager.Framework实际上是使用requestManager.Framework方法所以我想要的是在我的应用程序的Xcode项目中我只想保留requestManager.Framework代码的一个物理副本。我希望我的请求管理器代码应该只有一个副本每个应用程序和引用应该与其他框架链接。
我们已经在本地机器上创建了这个框架。现在我的问题是我们无法在profileManager.Framework中添加依赖项,或者在messagemanager.Framework中添加依赖项。我想知道我的两个框架如何能够使用应用程序中的网络管理器以及应用程序的单个副本。
答案 0 :(得分:1)
在单一视图应用程序级别拥有该框架,并确保在App和Framework的构建设置中正确地给出框架路径。
通过这种方式,您只能在项目级别维护一个框架副本,并且可以在项目或项目框架级别中自由使用。
答案 1 :(得分:1)
如何尝试使用CocoaPods管理这些框架的依赖关系?
在UserManager.Framework
和InboxManager.Framework
的podspec中,配置依赖项s.dependency 'NetworkManager', '~> 1.0'
。这样,您的应用程序中只能有一个NetworkManager.framework代码的物理副本。
例如,AlamofireImage
和Alamofire-SwiftyJSON
都依赖于Alamofire
,但只有Alamofire.framework
的一个物理副本在应用中安装pod install
并运行public class MainActivity extends AppCompatActivity {
private static final String TAG = "bluetooth";
private BluetoothAdapter bluetoothAdapter;
private Button mBTEnableButton;
private BroadcastReceiver mReceiver;
private TextView mShowDevices;
private ProgressBar mProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBTEnableButton = findViewById(R.id.enable_bt_button);
mShowDevices = findViewById(R.id.show_connected_devices);
mProgressBar = findViewById(R.id.progressbar);
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mReceiver = new BlueToothReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
intentFilter.addAction(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, intentFilter);
mProgressBar.setVisibility(View.INVISIBLE);
if (bluetoothAdapter == null) {
Toast.makeText(this, "Device does not support bluetooth", Toast.LENGTH_SHORT).show();
}
mBTEnableButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!bluetoothAdapter.isEnabled()) {
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intent, 1000);
bluetoothAdapter.startDiscovery();
}
}
});
}
private class BlueToothReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("bluetooth", "onReceive");
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String deviceName = device.getName();
String deviceAddress = device.getAddress();
mShowDevices.setText("action : " + action + "\n device name: " + deviceName + "\ndevice address : " + deviceAddress);
Log.d("bluetooth", "action : " + action + "\n device name: " + deviceName + "\ndevice address : " + deviceAddress);
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
mProgressBar.setVisibility(View.VISIBLE);
Log.d(TAG, "discovery start: ");
} else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
mProgressBar.setVisibility(View.INVISIBLE);
Log.d(TAG, "discovery finish: ");
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mReceiver);
}}